forked from github/server
BUG 2334 and 2339: fix script update and init calls
Ponnuki and Portals scripts are working. Ponnuki may still attack? More testing required.
This commit is contained in:
parent
3ec1476da2
commit
eed93b7470
|
@ -10,23 +10,25 @@ local jokes = {
|
|||
}
|
||||
|
||||
local function ponnuki_brain(u)
|
||||
u:clear_orders()
|
||||
local i = math.random(#jokes)
|
||||
u:add_notice("Eine Botschaft von " .. tostring(u) .. ": " ..jokes[i])
|
||||
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:clear_orders()
|
||||
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
|
||||
end
|
||||
|
||||
return ponnuki
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue