diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-26 22:06:10 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-02 18:12:07 +0100 |
commit | 34ac0d64e23f2b2d3981dbb0ea72157f334805dd (patch) | |
tree | 114b1f7a65956c097f7a59078292c9fa29c6451f /example/scripts | |
parent | e896d0b0125b48e12d43d99ace4498e56d968d50 (diff) | |
download | manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.tar.gz manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.tar.bz2 manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.tar.xz manaserv-34ac0d64e23f2b2d3981dbb0ea72157f334805dd.zip |
Merged all the different Lua states into one
No more Lua state for each status effect, monster, item effect or map. All
scripts are loaded into the same state. This should be more efficient overall
and make it easier to implement dynamic reloading of the scripts in the
future.
Now, this introduces the problem of name collisions between different Lua
scripts. For now this is solved by using more specific function names, like
'tick_plague' and 'tick_jump' rather than just 'tick'. The plan is however
to get rid of these globals, and register these callbacks from the script,
so that they can be local functions without the danger of colliding with
other scripts.
Reviewed-by: Erik Schilling
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'example/scripts')
-rw-r--r-- | example/scripts/items/candy.lua | 2 | ||||
-rw-r--r-- | example/scripts/monster/testmonster.lua | 4 | ||||
-rw-r--r-- | example/scripts/status/jump.lua | 2 | ||||
-rw-r--r-- | example/scripts/status/plague.lua | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/example/scripts/items/candy.lua b/example/scripts/items/candy.lua index a740ce6a..5ab7c9a4 100644 --- a/example/scripts/items/candy.lua +++ b/example/scripts/items/candy.lua @@ -12,6 +12,6 @@ -- under the terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2 of the License, or any later version. -- ---------------------------------------------------------------------------------- -function use(user) +function use_candy(user) mana.being_say(user, "*munch*munch*munch*") end diff --git a/example/scripts/monster/testmonster.lua b/example/scripts/monster/testmonster.lua index 9938943b..fa094a8d 100644 --- a/example/scripts/monster/testmonster.lua +++ b/example/scripts/monster/testmonster.lua @@ -8,14 +8,14 @@ -- Software Foundation; either version 2 of the License, or any later version. -- ---------------------------------------------------------------------------------- -function update(mob) +function update_monster(mob) local r = math.random(0, 200); if r == 0 then mana.being_say(mob, "Roar! I am a boss") end end -function strike(mob, victim, hit) +function on_maggot_strike(mob, victim, hit) if hit > 0 then mana.being_say(mob, "Take this! "..hit.." damage!") mana.being_say(victim, "Oh Noez!") diff --git a/example/scripts/status/jump.lua b/example/scripts/status/jump.lua index 3410747a..10ad9288 100644 --- a/example/scripts/status/jump.lua +++ b/example/scripts/status/jump.lua @@ -12,7 +12,7 @@ ---------------------------------------------------------------------------------- -function tick(target, ticknumber) +function tick_jump(target, ticknumber) if (ticknumber % 10 == 0) then mana.being_say(target, "I have the jumping bug!") end diff --git a/example/scripts/status/plague.lua b/example/scripts/status/plague.lua index 5f98268e..5f33eb87 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(target, ticknumber) +function tick_plague(target, ticknumber) if (ticknumber % 10 == 0) then mana.being_say(target, "I have the plague! :( = " .. ticknumber) end |