The version of script.ldf that is contained in patch.003 contains an erroneous declaration for Deprecated_ExecuteScript(), which makes it take the script name as a resource instead of as a string. When the engine pops the script name and finds a string tagged as 'resource' instead of as 'string', it panics and quietly aborts execution of the guilty script.
One way around this is to use HandleEvent() or HandleEvent_String() instead, e.g. by passing Event(0) as the first parameter. However, that doesn't work if the script must be run on a certain object, to which it refers using OBJECT_SELF. In that case you need a fixed declaration for ExecuteScript() for the benefit of the toolset's compiler.
Extract script.ldf from patch.003 and add the following line:
void Corrected_ExecuteScript( string rScript, object oTarget ) = 8;
Then put the file into an override directory.
Here's a little test script that I used to figure out what's what. Replace my "aa_dump_args" guinea pig with something of yours that's suitable, something that has a visible effect (e.g. by printing floaties or whatever).
// aa_ExecuteScript.nss
// 2014-07-31
#include "core_h"
// The extension for the resource doesn't matter as it is stripped internally, but the compiler
// wants something with no more than three characters after the dot. By contrast, script name
// *strings* must not contain an extension.
const resource SCRIPT_RES_ = R"aa_dump_args.foo";
const string SCRIPT_STR_ = "aa_dump_args";
void main ()
{
string[] argv = SplitString(GetLocalString(GetModule(), "RUNSCRIPT_VAR"));
string cmd = argv[0];
SetLocalString(GetModule(), "RUNSCRIPT_VAR", "parameters...");
if (cmd == "emulated")
{
// HandleEvent() needs a properly constructed event; a blank stack variable won't do.
// Note: IsValidEvent() is broken and returns FALSE for events of type 0; there seems
// to be no way of distinguishing between an invalid event and one of type 0, apart
// from passing it to a function like HandleEvent() to see what happens.
HandleEvent(Event(0), SCRIPT_RES_);
}
else if (cmd == "string")
{
HandleEvent_String(Event(0), SCRIPT_STR_);
}
else if (cmd == "string_with_ext")
{
// specifying an extension b0rkens things...
HandleEvent_String(Event(0), SCRIPT_STR_ + ".nss");
HandleEvent_String(Event(0), SCRIPT_STR_ + ".ncs");
}
else if (cmd == "corrected")
{
// properly declared version of function #8 (ExecuteScript)
Corrected_ExecuteScript(SCRIPT_STR_, GetMainControlled());
}
else if (cmd == "corrected_with_ext")
{
// specifying an extension b0rkens things...
Corrected_ExecuteScript(SCRIPT_STR_ + ".nss", GetMainControlled());
Corrected_ExecuteScript(SCRIPT_STR_ + ".ncs", GetMainControlled());
}
else if (cmd == "original" || cmd == "")
{
// The declaration of Deprecated_ExecuteScript() in script.ldf is broken. The function expects
// the script name as a plain string, not as a string that is tagged as 'resource'. Since it
// finds the latter instead of the former, it aborts the script quietly as is usual for this
// sorry mess, and the RUNSCRIPT command misleadingly prints "Success".
Deprecated_ExecuteScript(SCRIPT_RES_, GetMainControlled());
}
else
{
DisplayFloatyMessage(GetMainControlled(), "unknown cmd: '" + cmd + "'", FLOATY_MESSAGE, 0xFF0000);
}
DisplayFloatyMessage(GetMainControlled(), "reached the end of the script", FLOATY_MESSAGE, 0xFFFF);
}





Nach oben






