summaryrefslogtreecommitdiff
path: root/example/scripts/crafting.lua
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-11 18:16:16 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-03-11 19:27:32 +0100
commit5ff34fd2458dff28d664c90fb93f455231f8633c (patch)
tree533151e5f3002c1e24ce4d44e5cd32c66c026b51 /example/scripts/crafting.lua
parentb822dcee52d15d41c4186a250e73b85b16c9dc39 (diff)
downloadmanaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.gz
manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.bz2
manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.tar.xz
manaserv-5ff34fd2458dff28d664c90fb93f455231f8633c.zip
Register Lua script API functions into the global namespace
Scripts mostly execute the Mana script API, and it seems like just unnecessary verbosity to refer to the 'mana' table all the time. This table no longer exists now. Reviewed-by: Erik Schilling
Diffstat (limited to 'example/scripts/crafting.lua')
-rw-r--r--example/scripts/crafting.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/example/scripts/crafting.lua b/example/scripts/crafting.lua
index db8c76dd..afe1e1b5 100644
--- a/example/scripts/crafting.lua
+++ b/example/scripts/crafting.lua
@@ -9,14 +9,14 @@ local function craft_strict(ch, recipe)
if (recipe[1].id == 8 and recipe[1].amount == 2 and -- has two iron
recipe[2].id == 9 and recipe[2].amount == 1) -- and one wood
then
- mana.chr_inv_change(ch,
+ chr_inv_change(ch,
8, -2, --take away the iron
9, -1, --take away the wood
5, 1 ) -- give a sword
- mana.chat_message(ch, "You've crafted a sword")
+ chat_message(ch, "You've crafted a sword")
return
end
- mana.chat_message(ch, "This wouldn't create anything useful")
+ chat_message(ch, "This wouldn't create anything useful")
end
-- this turns multiple occurences of the same item into one by adding up
@@ -56,19 +56,19 @@ local function craft_lax(ch, recipe)
if (recipe[1].id == 8 and recipe[1].amount >= 2 and -- has at least two iron
recipe[2].id == 9 and recipe[2].amount >= 1) -- and at least one wood
then
- mana.chr_inv_change(ch,
+ chr_inv_change(ch,
8, -2, -- take away the iron
9, -1, -- take away the wood
5, 1 ) -- give a sword
- mana.chat_message(ch, "You've crafted a sword")
+ chat_message(ch, "You've crafted a sword")
return
end
- mana.chat_message(ch, "This wouldn't create anything useful")
+ chat_message(ch, "This wouldn't create anything useful")
end
-- This function is registered with the game engine to use when a character
-- tries to craft something from items in its inventory.
-local function on_craft(ch, recipe)
+local function craft(ch, recipe)
-- ch is the crafting character
--
-- recipe is a table with the ingredients.
@@ -80,9 +80,9 @@ local function on_craft(ch, recipe)
-- uncomment one (but not both!) of the following three lines to enable the
-- example crafting systems
- mana.chat_message(ch, "There is no crafting in this game world.")
+ chat_message(ch, "There is no crafting in this game world.")
--craft_strict(ch, recipe)
--craft_lax(ch, recipe)
end
-mana.on_craft(on_craft)
+on_craft(craft)