summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--data/scripts/test.lua8
2 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index cab87991..bba74ea0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
* src/scripting/lua.cpp: Added functions for getting being name and
attributes in scripts.
+ * data/scripts/test.lua: Added example of using above functions.
2008-10-22 Chuck Miller <shadowmil@gmail.com>
diff --git a/data/scripts/test.lua b/data/scripts/test.lua
index 4dcb9eb6..7be03653 100644
--- a/data/scripts/test.lua
+++ b/data/scripts/test.lua
@@ -23,6 +23,8 @@ atinit(function()
create_npc("Scorpion Tamer", 126, 45 * TILESIZE + 16, 25 * TILESIZE + 16, npc5_talk, nil)
create_npc("Guard", 122, 58 * TILESIZE + 16, 15 * TILESIZE + 16, npc6_talk, npc6_update)
create_npc("Fire Demon", 202, 58 * TILESIZE + 16, 35 * TILESIZE + 16, firedemon_talk, firedemon_update)
+ create_npc("Post Box", 158, 45 * TILESIZE + 16, 22 * TILESIZE + 16,
+post_talk)
tmw.trigger_create(56 * TILESIZE, 32 * TILESIZE, 64, 64, "patrol_waypoint", 1, true)
tmw.trigger_create(63 * TILESIZE, 32 * TILESIZE, 64, 64, "patrol_waypoint", 2, true)
@@ -181,3 +183,9 @@ function firedemon_update(npc)
npclib.walkaround_map(npc)
end
+
+function post_talk(npc, ch)
+ do_message(npc, ch, "Hello " .. tmw.being_get_name(ch))
+ local strength = tmw.being_get_attribute(ch, 2)
+ do_message(npc, ch, "You have " .. tostring(strength) .. " strength")
+end