From 5eb4f6a222e34dbcea5c834f8528b15d2d95a5e7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 4 Jan 2005 07:50:36 +0000 Subject: [PATCH] base lua script for the hse game (needs more stuff) --- src/scripts/hse05-01.lua | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/scripts/hse05-01.lua diff --git a/src/scripts/hse05-01.lua b/src/scripts/hse05-01.lua new file mode 100644 index 000000000..c020391d6 --- /dev/null +++ b/src/scripts/hse05-01.lua @@ -0,0 +1,70 @@ +function run_scripts() + scripts = { + } + for index in scripts do + local script = scriptpath .. "/" .. scripts[index] + print("- loading " .. script) + if pcall(dofile, script)==0 then + print("Could not load " .. script) + end + end +end + +function write_emails() + local locales = { "de", "en" } + local files = {} + local key + for key in locales do + local locale = locales[key] + files[locale] = io.open(basepath .. "/emails." .. locale, "w") + end + + local faction + for faction in factions() do + -- print(faction.id .. " - " .. faction.locale) + files[faction.locale]:write(faction.email .. "\n") + end + + for key in files do + files[key]:close() + end +end + +function process(orders) + file = "" .. get_turn() + if read_game(file)~=0 then + print("could not read game") + return -1 + end + + -- run the turn: + read_orders(orders) + run_scripts() + + plan_monsters() + process_orders() + + write_passwords() + write_reports() + + write_emails() + + file = "" .. get_turn() + if write_game(file)~=0 then + print("could not write game") + return -1 + end +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 +