server/scripts/eressea/cursed.lua
Enno Rehling 552f32ff97 bugfix https://bugs.eressea.de/view.php?id=2133
era in the CR is wrong for E2
build in the CR should be a string (did not have quotes)
Lua < 5.2 does not have bit32 (and Windows build uses 5.1)
2015-09-04 14:39:44 +02:00

31 lines
714 B
Lua

local function bitset(flags, bit)
-- TODO: use bit32 when we no longer have to consider lua 5.1 compatibility
local x = flags % (bit*2)
return x >= bit
end
local function curse(file)
for line in file:lines() do
f = get_faction(line)
if not f then
print("no such faction: " .. line)
elseif bitset(f.flags, 16) then
print("cursing " .. tostring(f))
f.flags = f.flags + 16
else
print("already cursed: " .. tostring(f))
end
end
end
local cursed = {}
function cursed.init()
local f = io.open("cursed.txt", "r")
if f then
print("found cursed.txt")
curse(f)
end
end
return cursed