Adding generic player events ?
Adding generic player events ?
As you know i have to attach every script to object to make it work. But how can i attach a script that contains events for ALL players ? For example onSpeech for all players: when i say "om om om", i will fly onto spirituality shrine or a special word that does something else. Can i add events on all players ?
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
Yep! You can create a "global" script (for all objects - whether characters or items) by giving it scriptID 0 in jse_fileassociations.scp. Any events in that file will run (if appropriate) for all objects on your shard. To avoid this script becoming to large to maintain, it might be an idea to use TriggerEvent to trigger other, larger script-files from the events in the global one.
-= Ho Eyo He Hum =-
thanks!Xuri wrote:Yep! You can create a "global" script (for all objects - whether characters or items) by giving it scriptID 0 in jse_fileassociations.scp. Any events in that file will run (if appropriate) for all objects on your shard. To avoid this script becoming to large to maintain, it might be an idea to use TriggerEvent to trigger other, larger script-files from the events in the global one.
will it work even on objects with another script ? i mean:
can i attach multiple scripts to an object ? for example, player uses generic event: script ID 0, and when he wears a cloak, it will give him damage resistance, script ID 1.
- Xuri
- Site Admin
- Posts: 3704
- Joined: Mon Jun 02, 2003 9:11 am
- Location: Norway
- Has thanked: 48 times
- Been thanked: 8 times
- Contact:
Hey, sorry for the slow reply.
The global-script (ID 0) should be usable alongside other scripts attached to objects - though only one such other unique script can be attached to each object, so your example of generic event script (global) versus a unique one should work. I'm not sure which script will run (global vs unique) in cases where the same event is present in both scripts, though.
The global-script (ID 0) should be usable alongside other scripts attached to objects - though only one such other unique script can be attached to each object, so your example of generic event script (global) versus a unique one should work. I'm not sure which script will run (global vs unique) in cases where the same event is present in both scripts, though.
-= Ho Eyo He Hum =-
Xuri wrote:Hey, sorry for the slow reply.
The global-script (ID 0) should be usable alongside other scripts attached to objects - though only one such other unique script can be attached to each object, so your example of generic event script (global) versus a unique one should work. I'm not sure which script will run (global vs unique) in cases where the same event is present in both scripts, though.
i think i will change scriptTrig thing in sources and add script triggers on a BaseObj as a vector<> and add JS functions like attachscript() detach().