server/src/scripts/eressea.lua

114 lines
2.3 KiB
Lua
Raw Normal View History

2005-03-23 19:55:47 +01:00
function loadscript(name)
local script = scriptpath .. "/" .. name
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)
end
end
function change_locales()
2005-09-09 00:25:56 +02:00
-- local localechange = { }
local localechange = { de = { "bLub" } }
for loc, flist in localechange do
for index, name in flist do
f = get_faction(atoi36(name))
if f ~= nil then
f.locale = loc
print("LOCALECHANGE ", f, loc)
end
end
end
end
function run_scripts()
scripts = {
"spells.lua",
"extensions.lua",
2005-11-27 14:40:09 +01:00
"write_emails.lua",
"eressea/eternath.lua",
"eressea/wedding-jadee.lua",
2005-12-11 13:33:57 +01:00
"eressea/ponnuki.lua",
"eressea/xmas2004.lua",
2005-12-18 19:09:53 +01:00
"eressea/xmas2005.lua",
"eressea/embassy.lua",
"eressea/ents.lua"
}
for index in scripts do
2005-03-23 19:55:47 +01:00
loadscript(scripts[index])
end
end
function process(orders)
-- initialize starting equipment for new players
equipment_setitem("new_faction", "conquesttoken", "1");
equipment_setitem("new_faction", "log", "30");
equipment_setitem("new_faction", "stone", "30");
equipment_setitem("new_faction", "money", "4200");
file = "" .. get_turn()
if read_game(file)~=0 then
print("could not read game")
return -1
end
init_summary()
2005-07-23 22:38:14 +02:00
-- kill multi-players (external script)
loadscript("eressea/multis.lua")
2005-07-23 22:38:14 +02:00
-- run the turn:
2005-04-24 23:54:57 +02:00
if read_orders(orders) ~= 0 then
print("could not read " .. orders)
return -1
end
run_scripts()
-- create new monsters:
spawn_dragons()
spawn_undead()
spawn_braineaters(0.25)
spawn_ents()
plan_monsters()
process_orders()
-- post-turn updates:
2005-12-11 13:33:57 +01:00
update_embassies()
update_guards()
update_scores()
change_locales()
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", false)
2005-03-13 11:05:51 +01:00
write_passwords()
write_reports()
write_emails()
write_summary()
file = "" .. get_turn()
if write_game(file)~=0 then
print("could not write game")
return -1
end
end
-- demo: how to add a special familiars-constructor
function initfamiliar_lynx(u)
print("a lynx is born ;-)")
end
--
-- main body of script
--
-- orderfile: contains the name of the orders.
if orderfile==nil then
print "you must specify an orderfile"
else
process(orderfile)
end