diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-02 23:17:07 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-03 21:24:45 +0100 |
commit | 84c87cc99be29a694f0ffe83ab7a06ae433bb0cd (patch) | |
tree | 9180b67970e62707ee0fe2fee19cbe2e0b829122 /example/scripts/status/plague.lua | |
parent | f872528771f0b71741fb36ddf70f2ae23f54c1e3 (diff) | |
download | manaserv-84c87cc99be29a694f0ffe83ab7a06ae433bb0cd.tar.gz manaserv-84c87cc99be29a694f0ffe83ab7a06ae433bb0cd.tar.bz2 manaserv-84c87cc99be29a694f0ffe83ab7a06ae433bb0cd.tar.xz manaserv-84c87cc99be29a694f0ffe83ab7a06ae433bb0cd.zip |
Use callbacks for items, monsters and status effects
Previously, global function names were defined in the respective XML
definitions of items, monsters and status effects. This was reasonable when
they all had the same state, but now they're sharing the single global
Lua state.
Now the Lua API provides access to the ItemClass, MonsterClass and
StatusEffect instances, on which callbacks for both standard and custom
events can be explicitly set.
Reviewed-by: Erik Schilling
Diffstat (limited to 'example/scripts/status/plague.lua')
-rw-r--r-- | example/scripts/status/plague.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/example/scripts/status/plague.lua b/example/scripts/status/plague.lua index 5f33eb87..a43b9d40 100644 --- a/example/scripts/status/plague.lua +++ b/example/scripts/status/plague.lua @@ -12,7 +12,7 @@ -- Software Foundation; either version 2 of the License, or any later version. -- ---------------------------------------------------------------------------------- -function tick_plague(target, ticknumber) +local function tick(target, ticknumber) if (ticknumber % 10 == 0) then mana.being_say(target, "I have the plague! :( = " .. ticknumber) end @@ -26,3 +26,5 @@ function tick_plague(target, ticknumber) i = i + 1 end end + +mana.get_status_effect("plague"):on_tick(tick) |