From eed93b747070033e80b291074cc60da93f7ce2b7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Jun 2017 12:23:19 +0200 Subject: [PATCH] BUG 2334 and 2339: fix script update and init calls Ponnuki and Portals scripts are working. Ponnuki may still attack? More testing required. --- scripts/eressea/ponnuki.lua | 25 ++++++++++++++----------- scripts/run-turn.lua | 10 ++++------ 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts/eressea/ponnuki.lua b/scripts/eressea/ponnuki.lua index 1a5d1959e..b5ba58fbe 100644 --- a/scripts/eressea/ponnuki.lua +++ b/scripts/eressea/ponnuki.lua @@ -10,23 +10,25 @@ local jokes = { } local function ponnuki_brain(u) - local i = math.random(#jokes) - u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i]) - local d = math.random(6) - local r = u.region:next(d-1) - if r.terrain == 'glacier' then u:clear_orders() - u:add_order("NACH " .. directions[d]) - end + local i = math.random(#jokes) + u:add_order("BOTSCHAFT REGION \"" .. jokes[i] .. "\"") + eressea.log.info("Ponnuki is telling jokes in " .. tostring(u.region)) + local d = math.random(6) + local r = u.region:next(d-1) + if r.terrain == 'glacier' then + u:add_order("NACH " .. directions[d]) + eressea.log.info("Ponnuki is walking to " .. tostring(r)) + end end function ponnuki.init() -- initialize other scripts + local f = get_faction(666) local u = get_unit(atoi36("ponn")) if not u then eressea.log.error("Ponnuki is missing, will re-create") local home = get_region(-67, -5) - local f = get_faction(666) if home and f then if home.terrain~="glacier" then home.terrain="glacier" @@ -44,10 +46,11 @@ function ponnuki.init() else eressea.log.error("Ponnuki cannot find Magrathea") end + elseif u.faction==f then + eressea.log.info("Ponnuki is in " .. tostring(u.region)) + u.status = 5 -- FLIEHE end - if u then - ponnuki_brain(u) - end + ponnuki_brain(u) end return ponnuki diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index 3ec87c045..4099c7976 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -144,7 +144,6 @@ function process(rules, orders) turn_begin() init_summary() - callbacks(rules, 'init') -- run the turn: if eressea.read_orders(orders) ~= 0 then @@ -152,19 +151,18 @@ function process(rules, orders) return -1 end - plan_monsters() - if nmr_check(config.maxnmrs or 80)~=0 then return -1 end - - callbacks(rules, 'update') + plan_monsters() + callbacks(rules, 'init') turn_process() + callbacks(rules, 'update') + turn_end() -- ageing, etc. write_files(config.locales) dbupdate() - turn_end() file = '' .. get_turn() .. '.dat' if eressea.write_game(file)~=0 then eressea.log.error("could not write game")