From 646fb10397e440ab67fb5a678bf034c53b050109 Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Fri, 23 Dec 2011 23:46:05 +0800 Subject: Made do_npc_close to be called by default after the end of the talk function Reviewed-by: Bertram. --- example/serverdata/scripts/maps/desert.lua | 1 - example/serverdata/scripts/npcs/banker.lua | 1 - example/serverdata/scripts/npcs/barber.lua | 4 +--- example/serverdata/scripts/npcs/debugger.lua | 1 - example/serverdata/scripts/npcs/emotemaker.lua | 1 - example/serverdata/scripts/npcs/healer.lua | 2 -- example/serverdata/scripts/npcs/merchant.lua | 1 - example/serverdata/scripts/npcs/postman.lua | 1 - scripts/lua/libmana.lua | 7 ++++++- 9 files changed, 7 insertions(+), 12 deletions(-) diff --git a/example/serverdata/scripts/maps/desert.lua b/example/serverdata/scripts/maps/desert.lua index 8977b54f..753375ba 100644 --- a/example/serverdata/scripts/maps/desert.lua +++ b/example/serverdata/scripts/maps/desert.lua @@ -60,7 +60,6 @@ function Harmony(npc, ch, list) end do_message(npc, ch, "Have fun!") mana.effect_create(EMOTE_HAPPY, npc) - do_npc_close(npc, ch) -- Make Harmony disappear for a while... with a small earthquake effect! local shakeX = mana.posX(npc) local shakeY = mana.posY(npc) diff --git a/example/serverdata/scripts/npcs/banker.lua b/example/serverdata/scripts/npcs/banker.lua index bd11ba55..7a6e6b40 100644 --- a/example/serverdata/scripts/npcs/banker.lua +++ b/example/serverdata/scripts/npcs/banker.lua @@ -76,5 +76,4 @@ function Banker(npc, ch) end do_message(npc, ch, "Thank you. Come again!") - do_npc_close(npc, ch) end diff --git a/example/serverdata/scripts/npcs/barber.lua b/example/serverdata/scripts/npcs/barber.lua index 0ef0e50a..fbb2862c 100644 --- a/example/serverdata/scripts/npcs/barber.lua +++ b/example/serverdata/scripts/npcs/barber.lua @@ -47,8 +47,7 @@ function Barber(npc, ch, data) -- Nothing to show? Then we can return if #color_ids == 0 and #style_ids == 0 then - return -- Since we haven't shown any windows, we can safely - -- return without a do_npc_close + return end local result = 0 @@ -137,5 +136,4 @@ function Barber(npc, ch, data) -- Let's close up do_message(npc, ch, "Thank you. Come again!") - do_npc_close(npc, ch) end diff --git a/example/serverdata/scripts/npcs/debugger.lua b/example/serverdata/scripts/npcs/debugger.lua index 6bb86d0a..142c3fd8 100644 --- a/example/serverdata/scripts/npcs/debugger.lua +++ b/example/serverdata/scripts/npcs/debugger.lua @@ -96,6 +96,5 @@ function npc1_talk(npc, ch) end do_message(npc, ch, "See you later!") - do_npc_close(npc, ch) end diff --git a/example/serverdata/scripts/npcs/emotemaker.lua b/example/serverdata/scripts/npcs/emotemaker.lua index 2e68aa2c..83d2f56f 100644 --- a/example/serverdata/scripts/npcs/emotemaker.lua +++ b/example/serverdata/scripts/npcs/emotemaker.lua @@ -34,7 +34,6 @@ function emote_talk(npc, ch) elseif (v == 3) then emo_state = EMOTE_SURPRISE end - do_npc_close(npc, ch) end function emote_update(npc) diff --git a/example/serverdata/scripts/npcs/healer.lua b/example/serverdata/scripts/npcs/healer.lua index 96d29111..88335c23 100644 --- a/example/serverdata/scripts/npcs/healer.lua +++ b/example/serverdata/scripts/npcs/healer.lua @@ -18,6 +18,4 @@ function Healer(npc, ch) elseif c == 2 then mana.being_heal(ch, 100) end - - do_npc_close(npc, ch) end diff --git a/example/serverdata/scripts/npcs/merchant.lua b/example/serverdata/scripts/npcs/merchant.lua index 46f85545..3b80298b 100644 --- a/example/serverdata/scripts/npcs/merchant.lua +++ b/example/serverdata/scripts/npcs/merchant.lua @@ -95,5 +95,4 @@ function Merchant(npc, ch, buy_sell_table) end do_message(npc, ch, "See you later!") - do_npc_close(npc, ch) end diff --git a/example/serverdata/scripts/npcs/postman.lua b/example/serverdata/scripts/npcs/postman.lua index 68546bf8..712ea993 100644 --- a/example/serverdata/scripts/npcs/postman.lua +++ b/example/serverdata/scripts/npcs/postman.lua @@ -27,5 +27,4 @@ function post_talk(npc, ch) if answer == 2 then do_post(npc, ch) end - do_npc_close(npc, ch) end diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua index f9f28575..d0d8666f 100644 --- a/scripts/lua/libmana.lua +++ b/scripts/lua/libmana.lua @@ -42,7 +42,12 @@ local timer -- Note: Cannot be called until map initialization has started. function create_npc(name, id, x, y, talkfunct, updatefunct) local npc = mana.npc_create(name, id, x, y) - if talkfunct then npc_talk_functs[npc] = talkfunct end + if talkfunct then + npc_talk_functs[npc] = function(npc, ch) + talkfunct(npc, ch) + do_npc_close(npc, ch) + end + end if updatefunct then npc_update_functs[npc] = updatefunct end return npc end -- cgit v1.2.3-70-g09d2