From f0a9cc8233aae9f0d24f2c94900937aa6fc24123 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 31 Aug 2015 11:19:16 +0200 Subject: [PATCH] added a lua module that marks factions as cursed --- scripts/eressea/cursed.lua | 28 ++++++++++++++++++++++++++++ scripts/eressea/e2/init.lua | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scripts/eressea/cursed.lua diff --git a/scripts/eressea/cursed.lua b/scripts/eressea/cursed.lua new file mode 100644 index 000000000..795d7aeb3 --- /dev/null +++ b/scripts/eressea/cursed.lua @@ -0,0 +1,28 @@ +require 'bit32' + +local function curse(file) + for line in file:lines() do + f = get_faction(line) + if not f then + print("no such faction: " .. line) + elseif bit32.band(16, f.flags)==0 then + print("cursing " .. tostring(f)) + f.flags = f.flags + 16 + else + print("already cursed: " .. tostring(f)) + end + end +end + +local cursed = {} + +function cursed.init() + print("curses!") + local f = io.open("cursed.txt", "r") + if f then + print("found cursed.txt") + curse(f) + end +end + +return cursed diff --git a/scripts/eressea/e2/init.lua b/scripts/eressea/e2/init.lua index 581836147..2bdc79b64 100644 --- a/scripts/eressea/e2/init.lua +++ b/scripts/eressea/e2/init.lua @@ -14,5 +14,6 @@ return { require('eressea.astral'), require('eressea.locales'), require('eressea.jsreport'), - require('eressea.ents') + require('eressea.ents'), + require('eressea.cursed') }