Hi friends.
i've had good fun learning to use the toolset. Now i'd like to keep my stuff compatible with others'.
If someone else overrides the core event script with their placeable script, i want to delegate to their script from within my script.
Calling
HandleEvent(GetCurrentEvent(), RESOURCE_SCRIPT_PLACEABLE_CORE) or HandleEvent(GetCurrentEvent())
breaks the others' mod.
Is there any way to retrieve the script name of their placeable, so that this can be done:
event ev = GetCurrentEvent();
object target = GetEventTarget(ev);
string targetScript = _function_to_get_script_name(target);
HandleEvent(ev, targetScript);
(My mod item sits in group inventory and passively works on placeables, hence the need to override the placeable_core script. I tried using SignalEvent, but since i am overriding the placeable_core script myself, it just means that my placeable_core script will also receive the signal, causing a loop).
Any help would be great! Thanks
How to retrieve the Script name of a placeable
Débuté par
DragonSiege
, févr. 12 2011 09:38
#1
Posté 12 février 2011 - 09:38
#2
Posté 14 février 2011 - 05:08
I haven't tried this...
According to the wiki, HandleEvent with no script parameter runs the object's "default" event script.
I suspect that means the script coded on the object template, rather than the core script.
Let us know if that works!
According to the wiki, HandleEvent with no script parameter runs the object's "default" event script.
I suspect that means the script coded on the object template, rather than the core script.
Let us know if that works!
#3
Posté 14 février 2011 - 09:24
Thank you for replying, Proleric! It's nice to see there is still interest to discuss, even thought i am late to the party. So much of the latest activity dates from one year ago!
Yes, i have tried what you advised. As far as i can tell, the result is the same as HandleEvent(GetCurrentEvent(), RESOURCE_SCRIPT_PLACEABLE_CORE).
Since i have already overidden RESOURCE_SCRIPT_PLACEABLE_CORE, it then creates a loop.
According to the wiki (http://social.biowar.../Item#Variables), [quote]Item ScriptThe purpose of the item event script (if any) is not clear. Events involving items (acquire, lose, equip, unequip, etc…) are received by the event script for the creature or placeable owning the item, but are not received by the item script.[endquote]Hence, i seek how to retrieve this variable (of other mods) so that i may chain to it.
(BTW, I had a quick look at the the links in your signature -- awesome!!)
Yes, i have tried what you advised. As far as i can tell, the result is the same as HandleEvent(GetCurrentEvent(), RESOURCE_SCRIPT_PLACEABLE_CORE).
Since i have already overidden RESOURCE_SCRIPT_PLACEABLE_CORE, it then creates a loop.
According to the wiki (http://social.biowar.../Item#Variables), [quote]Item ScriptThe purpose of the item event script (if any) is not clear. Events involving items (acquire, lose, equip, unequip, etc…) are received by the event script for the creature or placeable owning the item, but are not received by the item script.[endquote]Hence, i seek how to retrieve this variable (of other mods) so that i may chain to it.
(BTW, I had a quick look at the the links in your signature -- awesome!!)
#4
Posté 15 février 2011 - 09:16
That's strange. My testing seems to show that the "default" script is the one on the placeable template.
To demonstrate this, I changed my custom placeable script so that on first entry, it displayed "Entry 1", set a flag, then HandleEvent(ev). On second entry (determined by the flag setting), it displayed "Entry 2" and marked the event as handled.
The second entry message was displayed. The core script did not execute (I was using a container, but it didn't open). So I conclude that my custom script was the default.
I haven't tested whether this works if the event is overridden in the 2DA.
To demonstrate this, I changed my custom placeable script so that on first entry, it displayed "Entry 1", set a flag, then HandleEvent(ev). On second entry (determined by the flag setting), it displayed "Entry 2" and marked the event as handled.
The second entry message was displayed. The core script did not execute (I was using a container, but it didn't open). So I conclude that my custom script was the default.
I haven't tested whether this works if the event is overridden in the 2DA.
#5
Posté 15 février 2011 - 10:02
Now I've tested what happens if you override EVENT_TYPE_USE in the engineevents 2DA.
A = script specified in engineevents
B = script specified on the placeable template
C = core script
Script A executes first. If it issues HandleEvent(ev), script B executes next.
If script B issues HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE) then script C executes.
I think that's the solution you want?
A = script specified in engineevents
B = script specified on the placeable template
C = core script
Script A executes first. If it issues HandleEvent(ev), script B executes next.
If script B issues HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE) then script C executes.
I think that's the solution you want?
Modifié par Proleric1, 15 février 2011 - 10:03 .
#6
Posté 17 février 2011 - 12:08
Just popped in to say that i will check and get back to you. I'm certainly wondering what i did differently from you. The A,B,C scenario you posed is exactly what i need, so now i'm extremely hopeful





Retour en haut






