summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-30 22:16:40 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-31 21:50:49 +0100
commit4cd1957231605e976c5cf001eddea80d5e49272f (patch)
tree1fd13522adeb62c408562a4ff76c98ee2e254342 /example
parentbc291713c56a2bc27ec10cef52dd3a52a0579c7d (diff)
downloadmanaserv-4cd1957231605e976c5cf001eddea80d5e49272f.tar.gz
manaserv-4cd1957231605e976c5cf001eddea80d5e49272f.tar.bz2
manaserv-4cd1957231605e976c5cf001eddea80d5e49272f.tar.xz
manaserv-4cd1957231605e976c5cf001eddea80d5e49272f.zip
Use a full user data object for MapObject references
Based on a templated helper class, MapObject references in Lua scripts are now full user data objects. Using the '__index' member of their metatable, a library is associated with it so that member functions can be called directly on the object. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
Diffstat (limited to 'example')
-rw-r--r--example/serverdata/scripts/npcs/merchant.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/example/serverdata/scripts/npcs/merchant.lua b/example/serverdata/scripts/npcs/merchant.lua
index 23035b11..c3bd36a0 100644
--- a/example/serverdata/scripts/npcs/merchant.lua
+++ b/example/serverdata/scripts/npcs/merchant.lua
@@ -48,6 +48,7 @@ function Merchant(npc, ch, buy_sell_table)
else
table.insert (choice_table, "Can you make me a price for what I have?")
end
+ table.insert (choice_table, "Tell me about the objects on this map")
table.insert (choice_table, "Nevermind...")
local v = do_choice(npc, ch, choice_table)
@@ -94,6 +95,15 @@ function Merchant(npc, ch, buy_sell_table)
end
end
+ elseif v == 3 then
+
+ local objects = mana.map_get_objects()
+ do_message(npc, ch, "There are " .. #objects .. " objects on this map, their names are:")
+ for i=1,#objects do
+ do_message(npc, ch, tostring(i) .. ": " .. objects[i]:name())
+ end
+
end
+
do_message(npc, ch, "See you later!")
end