forked from github/server
just a script for fixing broken familiar links between releases
This commit is contained in:
parent
1122bb70a4
commit
a795226368
|
@ -0,0 +1,30 @@
|
||||||
|
require 'config'
|
||||||
|
|
||||||
|
function write_fam(file)
|
||||||
|
for f in factions() do for u in f.units do if u.familiar then
|
||||||
|
file:write(u.id .. " " .. u.familiar.id .. "\n")
|
||||||
|
end end end
|
||||||
|
end
|
||||||
|
|
||||||
|
function read_fam(file)
|
||||||
|
m, f = file:read("*n", "*n")
|
||||||
|
while m and f do
|
||||||
|
mag = get_unit(m)
|
||||||
|
fam = get_unit(f)
|
||||||
|
if mag and fam then
|
||||||
|
mag.familiar = fam
|
||||||
|
end
|
||||||
|
m, f = file:read("*n", "*n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
eressea.read_game(get_turn()..".dat")
|
||||||
|
file = io.open("familiars.txt", "r")
|
||||||
|
if file then
|
||||||
|
read_fam(file)
|
||||||
|
eressea.write_game(get_turn()..".fix")
|
||||||
|
else
|
||||||
|
file = io.open("familiars.txt", "w")
|
||||||
|
write_fam(file)
|
||||||
|
end
|
||||||
|
file:close()
|
Loading…
Reference in New Issue