From 1151e39d73793923ecd7a044e7116e6d2077c756 Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Sat, 26 Feb 2011 12:18:58 +0100 Subject: Show a way to make monsters speak at spawn time. Even when events are inserted before game state update time, the monsters don't speak since they still don't have an id (-1). As I thought that reworking the mapcomposite engine for that particular point was ineffective, here is another working way to make monsters speak at spawn time by using the schedule_in function with 0.3 second (or 3 ticks). Resolves: Mana-Mantis #205. Reviewed-by: Thorbjorn. --- example/serverdata/scripts/maps/desert.lua | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'example/serverdata') diff --git a/example/serverdata/scripts/maps/desert.lua b/example/serverdata/scripts/maps/desert.lua index 70db78c..a838ee1 100644 --- a/example/serverdata/scripts/maps/desert.lua +++ b/example/serverdata/scripts/maps/desert.lua @@ -35,9 +35,11 @@ atinit(function() smith_buy_table = { {5, 10, 50}, {7, 10, 70} } create_npc("Smith", 5, 15 * TILESIZE + TILESIZE / 2, 16 * TILESIZE + TILESIZE / 2, npclib.talk(Merchant, smith_buy_table), nil) - -- The most simple NPC - Welcoming new ones around. create_npc("Harmony", 11, 4 * TILESIZE + TILESIZE / 2, 25 * TILESIZE + TILESIZE / 2, npclib.talk(Harmony, "Welcome in the template world!\nI hope you'll find here whatever you were searching for.", "Do look around to find some interesting things coming along!"), Harmony_update) + + -- Creates a Monster an let it talk for testing purpose. + create_npc("Tamer", 9, 28 * TILESIZE + TILESIZE / 2, 21 * TILESIZE + TILESIZE / 2, Tamer, nil) end) -- Global variable used to know whether Harmony talked to someone. @@ -74,4 +76,11 @@ function Harmony_update(npc) mana.being_say(npc, "Hey! You're new! Come here...") end end -end \ No newline at end of file +end + +function Tamer(npc, ch, list) + mana.being_say(npc, "I will now spawn a monster for your training session.") + + local m1 = mana.monster_create(1, mana.posX(ch), mana.posY(ch)) + schedule_in(0.3, function() mana.being_say(m1, "Roaaarrrr!!!") end) +end -- cgit