summaryrefslogtreecommitdiff
path: root/example/serverdata/scripts/maps/desert.lua
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-31 02:04:29 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-01-31 02:04:29 +0100
commit6a3e510e4b40fcb1554cdd57e7ddc49edd89fa3f (patch)
treea23bd9d9ecefa539022143588690fb65567c4b74 /example/serverdata/scripts/maps/desert.lua
parentb2209cbe93aa12dcd4e4e3b9a7cd8b13ed5713e9 (diff)
downloadmanaserv-6a3e510e4b40fcb1554cdd57e7ddc49edd89fa3f.tar.gz
manaserv-6a3e510e4b40fcb1554cdd57e7ddc49edd89fa3f.tar.bz2
manaserv-6a3e510e4b40fcb1554cdd57e7ddc49edd89fa3f.tar.xz
manaserv-6a3e510e4b40fcb1554cdd57e7ddc49edd89fa3f.zip
Added first visible npcs and play with them a bit.
Diffstat (limited to 'example/serverdata/scripts/maps/desert.lua')
-rw-r--r--example/serverdata/scripts/maps/desert.lua42
1 files changed, 36 insertions, 6 deletions
diff --git a/example/serverdata/scripts/maps/desert.lua b/example/serverdata/scripts/maps/desert.lua
index 4838d0cd..7ce46f72 100644
--- a/example/serverdata/scripts/maps/desert.lua
+++ b/example/serverdata/scripts/maps/desert.lua
@@ -17,16 +17,46 @@ require "scripts/npcs/banker"
require "scripts/npcs/barber"
atinit(function()
- create_npc("Barber", 100, 14 * TILESIZE + TILESIZE / 2, 9 * TILESIZE + TILESIZE / 2, Barber, nil)
- create_npc("Barber 2", 100, 20 * TILESIZE + TILESIZE / 2, 11 * TILESIZE + TILESIZE / 2, npclib.talk(Barber, {14, 15, 16}, {}), nil)
- create_npc("Banker", 149, 35 * TILESIZE + TILESIZE / 2, 24 * TILESIZE + TILESIZE / 2, Banker, nil)
-
- create_npc("Test", 102, 4 * TILESIZE + TILESIZE / 2, 25 * TILESIZE + TILESIZE / 2, npclib.talk(Test, "String1", "String2", "String3", "Etc"), nil)
+ -- Barber examples
+ create_npc("Barber Twin", 1, 14 * TILESIZE + TILESIZE / 2, 9 * TILESIZE + TILESIZE / 2, Barber, nil)
+ create_npc("Barber Twin", 1, 20 * TILESIZE + TILESIZE / 2, 11 * TILESIZE + TILESIZE / 2, npclib.talk(Barber, {14, 15, 16}, {}), nil)
+ -- A simple banker
+ create_npc("Banker", 8, 35 * TILESIZE + TILESIZE / 2, 24 * TILESIZE + TILESIZE / 2, Banker, 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)
end)
-function Test(npc, ch, list)
+-- Global variable used to know whether Harmony talked to someone.
+harmony_have_talked_to_someone = false
+function Harmony(npc, ch, list)
+ -- Say all the messages in the messages list.
for i = 1, #list do
do_message(npc, ch, list[i])
end
+ --- Give the player 100 units of money the first time.
+ if harmony_have_talked_to_someone == false then
+ if mana.chr_money_change(ch, 100) then
+ do_message(npc, ch, "Here is some money for you to find some toys to play with.\nEh Eh!")
+ do_message(npc, ch, string.format("You now have %d shiny coins!", mana.chr_money(ch)))
+ harmony_have_talked_to_someone = true
+ else
+ do_message(npc, ch, "Ah, it seems something went wrong...")
+ end
+ end
+ do_message(npc, ch, "Have fun!")
+ mana.effect_create(EMOTE_HAPPY, npc)
do_npc_close(npc, ch)
end
+
+-- Global variable used to control Harmony's updates.
+-- One tick equals to 100ms, so 100 below equals to 10000ms or 10 seconds
+harmony_tick_count = 0
+function Harmony_update(npc)
+ if harmony_have_talked_to_someone == false then
+ harmony_tick_count = harmony_tick_count + 1
+ if harmony_tick_count > 100 then
+ harmony_tick_count = 0
+ mana.being_say(npc, "Hey! You're new! Come here...")
+ end
+ end
+end \ No newline at end of file