Adding Script Events to sys

From The DarkMod Wiki
Revision as of 13:58, 13 September 2006 by Greebo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Originally written by Ishtvan on http://forums.thedarkmod.com/topic/1582

Btw, if anyone's curious how to add new "sys" events, i.e., events you call with $sys.<eventname> from the script, they're located here:

/src/game/script/script_thread.cpp (and .h)

Just add them there as you would add any other script events (see iddevnet.com for a guide to adding script events, there are a lot of steps)

I'm compiling my changes now and still have to test them, but hopefully it'll work. This way you can add events that are global, for example as a frontend for accessing a global object contained in game_local.

The "sys" object is an artificial "global object" within the scripting language. The scripting language only sees actual spawned entities, and the global object. So you can't have abstract objects (like container classes contained within an entity or something). Therefore if you want an object to call functions on without spawning an entity, the "sys" object is a good choice. (It's not a real object in the sdk either, it's just seen that way by scripting, and it can only call methods/events on the idThread class)