• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[XML]Binding lua scripts to raids.

MindRage

Toss Me
Joined
Nov 11, 2008
Messages
474
Reaction score
71
Hello, Im trying to fix a raid which requires a lua script to execute within it

This is taken from the public SVN.

This is what kind of tags i can use in an raid.xml file.
and i noticed you could execute a script from within an raid xml file.

Code:
                RaidEvent* event;
                if(!xmlStrcmp(eventNode->name, (const xmlChar*)[COLOR="red"]"announce"[/COLOR]))
                        event = new AnnounceEvent(this, ref);
                else if(!xmlStrcmp(eventNode->name, (const xmlChar*)[COLOR="red"]"effect"[/COLOR]))
                        event = new EffectEvent(this, ref);
                else if(!xmlStrcmp(eventNode->name, (const xmlChar*)[COLOR="red"]"itemspawn"[/COLOR]))
                        event = new ItemSpawnEvent(this, ref);
                else if(!xmlStrcmp(eventNode->name, (const xmlChar*)[COLOR="red"]"[B]singlespawn[/B]"[/COLOR]))
                        event = new SingleSpawnEvent(this, ref);
                else if(!xmlStrcmp(eventNode->name, (const xmlChar*)[COLOR="red"]"areaspawn"[/COLOR]))
                        event = new AreaSpawnEvent(this, ref);
                else if(!xmlStrcmp(eventNode->name, (const xmlChar*)[COLOR="red"]"script"[/COLOR]))
                        event = new ScriptEvent(this, ref);

As you see i could use script as a tag

"<script delay="1000" file="test.lua">"

But it didn't work so i tried to navigate to the "ScriptEvent" Function

Code:
bool ScriptEvent::configureRaidEvent(xmlNodePtr eventNode)
{
        if(!RaidEvent::configureRaidEvent(eventNode))
                return false;

        std::string scriptsName = Raids::getInstance()->getScriptBaseName();
        if(!m_interface.loadDirectory(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/lib/"))))
                std::cout << "[Warning - ScriptEvent::configureRaidEvent] Cannot load " << scriptsName << "/lib/" << std::endl;

        std::string strValue;
        if(readXMLString(eventNode, [COLOR="red"]"file"[/COLOR], strValue))
        {
                if(!loadScript(getFilePath(FILE_TYPE_OTHER, std::string(scriptsName + "/scripts/" + strValue)), true))
                {
                        std::cout << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script file (" << strValue << ")." << std::endl;
                        return false;
                }
        }
        else if(!parseXMLContentString(eventNode->children, strValue) && !loadBuffer(strValue))
        {
                std::cout << "[Error - ScriptEvent::configureRaidEvent] Cannot load raid script buffer." << std::endl;
                return false;
        }

        return true;
}

shows that the tag "file" is available in the scriptevent thingy.

But all errors i get is

[16:44:12.678] [Error - ScriptEvent::configureRaidEvent] Cannot load raid script
buffer.
[16:44:12.681] [Error - Raid::loadFromXml] Could not configure raid in file: dat
a/raids/example.xml, eventNode: script

as it just skipped this line
if(readXMLString(eventNode, "file", strValue))

and jumped down to xxxx

I've checked all paths and the lua script is correct, but how can i bind it in the xml o.o?
 
Last edited:
, Erm if you read.. Its not to summon a monster.. I actually have to remove a specific npc when excecuting the raid. In this case is i need to execute a lua script,
And i read in the sources that you could use an tag in the raid xml file (not raids.xml) that executed a onRaid() script on x delay.
 
Back
Top