I have to use this function, but I'm not sure I understood how it works.
1) Do AddScriptParameter calls need to be performed before invoking this function?
2) Can the object type parameter you pass to ExecuteScriptEnhanced be refered with OBJECT_SELF within the executed script?
Thanks in advance.
Question on ExecuteScriptEnhanced
Débuté par
Ext3rmin4tor
, nov. 13 2012 01:06
#1
Posté 13 novembre 2012 - 01:06
#2
Posté 13 novembre 2012 - 08:14
From what I gather, this function works by first setting some kind of global or local variable using AddScriptParameter, which ExecuteScriptEnhanced will then read back to use as the parameters for the script. So you need to use AddScriptParameter first, one for each parameter, in the order in which they should appear in the script's main function.
That's how I understand it.
I don't know the second answer, but OBJECT_SELF usually refers to the object that calls any particular script. If a script calls another script, then it's the object that the first script was called by.
Have you considered using an include file instead of ExecuteScript?
That's how I understand it.
I don't know the second answer, but OBJECT_SELF usually refers to the object that calls any particular script. If a script calls another script, then it's the object that the first script was called by.
Have you considered using an include file instead of ExecuteScript?
#3
Posté 14 novembre 2012 - 10:15
Yes, but I thought ExecuteScript launched the script in parallel, while if I call an included function it wil be sequencial. Is that correct?
#4
Posté 14 novembre 2012 - 10:31
not really. Both run sequentially, but the beauty of ExecuteScript() is how easy it is to have some other object ( OBJECT_SELF ) run it ...
#5
Posté 14 novembre 2012 - 10:32
kevL to the rescue!
Modifié par Tchos, 14 novembre 2012 - 10:32 .
#6
Posté 14 novembre 2012 - 10:34
i was bored
#7
Posté 15 novembre 2012 - 07:45
kevL, so do you confirm that the object parameter passed to ExecuteScript can be accessed as OBJECT_SELF inside the script itself?
Also, I know in every game scripts run in pseudo-parallel but in truth they are sequencial, but with "sequential" do you mean pseudo-parallel or really sequential (that is, until the script called with ExecuteScript doesn't end the caller script doesn't go on)?
Also, I know in every game scripts run in pseudo-parallel but in truth they are sequencial, but with "sequential" do you mean pseudo-parallel or really sequential (that is, until the script called with ExecuteScript doesn't end the caller script doesn't go on)?
#8
Posté 15 novembre 2012 - 09:45
Yes. but don't take my word for it; put a line into the executed script:Ext3rmin4tor wrote...
kevL, so do you confirm that the object parameter passed to ExecuteScript can be accessed as OBJECT_SELF inside the script itself?
SendMessageToPC(GetFirstPC(FALSE), "ObjectSelf : " + GetName(OBJECT_SELF));
well, i added this to my Heartbeat script ( nw_c2_default1 )Also, I know in every game scripts run in pseudo-parallel but in truth they are sequencial, but with "sequential" do you mean pseudo-parallel or really sequential (that is, until the script called with ExecuteScript doesn't end the caller script doesn't go on)?
// added this so that if NPC has string_var "kL_sCalmHB" it will
// do those actions here. that script can set a local_int on the NPC
// to tell this script whether it should carry on completing or not.
string sCalmHB = GetLocalString(OBJECT_SELF, "kL_sCalmHB");
if (sCalmHB != "")
{
ExecuteScript(sCalmHB, OBJECT_SELF);
if (GetLocalInt(OBJECT_SELF, "kL_bStopHB"))
{
DeleteLocalInt(OBJECT_SELF, "kL_bStopHB");
// note that this prevents the UserDefinedEvent from firing:
return;
}
}The second part of that, Get/DeleteLocalInt, relies on the executed script to set that variable_int (or not) ... so someday if I get strange behavior it should show up. You can do a test yourself simply by putting in SendMessageToPC() debugs -- put one in the executed script and another in the calling script right below the ExecuteScript() command, and watch which message pops to chat window first
Also, note description: "Make oTarget run sScript and then return execution to the calling script." in nwscript.nss: then return execution to the calling script
( not that i really trust descriptions ..)
as to ExecuteScriptEnhanced(), remember it's just a convenience function. I tried it once, couldn't get it to work, but this was probably my own fault. The reason I didn't try too hard is because you can have a calling script set those ScriptParameter's as local_ints/strings/floats/objects on some available object, like the area or module, anyway and merely use ExecuteScript(). Then delete them in the exectuted script, right?





Retour en haut






