Lua 5.1 has deprecated the old for-syntax for tables.

This commit is contained in:
Enno Rehling 2007-06-13 12:38:15 +00:00
parent 9d72640755
commit 0c05d8f978
13 changed files with 62 additions and 66 deletions

View File

@ -10,8 +10,9 @@ function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key in locales do
local locale = locales[key]
local locale
local file
for key, locale in pairs(locales) do
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
@ -21,8 +22,8 @@ function write_emails()
files[faction.locale]:write(faction.email .. "\n")
end
for key in files do
files[key]:close()
for key, file in pairs(files) do
file:close()
end
end

View File

@ -10,8 +10,8 @@ function change_locales()
-- local localechange = { }
local localechange = { de = { "bLub" } }
for loc, flist in localechange do
for index, name in flist do
for loc, flist in pairs(localechange) do
for index, name in pairs(flist) do
f = get_faction(atoi36(name))
if f ~= nil then
f.locale = loc
@ -38,8 +38,8 @@ function run_scripts()
"eressea/embassy.lua",
"eressea/ents.lua"
}
for index in scripts do
loadscript(scripts[index])
for index, value in pairs(scripts) do
loadscript(value)
end
end

View File

@ -1,8 +1,8 @@
function teleport_all(map, grave)
print("- teleporting all quest members to the grave")
local index
for index in map do
local r = map[index]
local r
for index, r in pairs(map) do
local u
for u in r.units do
u.region = grave
@ -36,8 +36,8 @@ function wyrm()
end
local index
for index in map do
local r = map[index]
local r
for index, r in pairs(map) do
if r~=grave then
if (math.mod(r.x,2)==math.mod(get_turn(),2)) then
r:add_notice("Eine Botschaft von Igjarjuk, Herr der Wyrme: 'Die Zeit des Wartens ist beinahe vorrüber. Euer Fürst kehrt aus dem Grabe zurück.'")

View File

@ -4,7 +4,9 @@ local function kill_multis()
-- ["amam"]="Wird wegen Missbrauch von Sonnensegeln geloescht",
-- ["jr81"]="Wird wegen Missbrauch von Sonnensegeln geloescht"
}
for k, v in multis do
local k
local v
for k, v in pairs(multis) do
local f = get_faction(atoi36(k))
if f~=nil then
print("- marking " .. tostring(f) .. " as a multi-player.")

View File

@ -4,7 +4,7 @@
function gate_travel(b, units)
-- we've found which units we want to exchange, now swap them:
local u
for u in units do
for key, u in pairs(units) do
u.region = b.region
u.building = b
end
@ -16,7 +16,7 @@ function gate_units(b, maxsize)
local u
for u in b.units do
if u.number<=size and u.weight<=u.capacity then
if u.number<=size and u.weight<=u.capacity then
units[u] = u
size = size - u.number
end

View File

@ -1,25 +1,27 @@
function write_buildings(file)
types = { "sawmill", "quarry", "mine", "lighthouse", "castle", "monument" }
for index, tname in types do
count = 0
best = nil
local index
local tname
for index, tname in pairs(types) do
count = 0
best = nil
for r in regions() do
for b in r.buildings do
if b.type == tname then
count = count + 1
count = count + 1
if best == nil then
best = b
else
if best.size<b.size then
best = b
end
end
best = b
else
if best.size<b.size then
best = b
end
end
end
end
end
if best ~= nil then
file:write("\n" .. count .. " x " .. get_string("de", best.type) .. "\n")
file:write("- " .. fname(best) .. ", Groesse " .. best.size .. "\n")
end
end
if best ~= nil then
file:write("\n" .. count .. " x " .. get_string("de", best.type) .. "\n")
file:write("- " .. fname(best) .. ", Groesse " .. best.size .. "\n")
end
end
end

View File

@ -4,7 +4,9 @@ end
function write_spoils(file)
items = { "elfspoil", "demonspoil", "goblinspoil", "dwarfspoil", "halflingspoil", "humanspoil", "aquarianspoil", "insectspoil", "catspoil", "orcspoil", "trollspoil" }
for index, iname in items do
local index
local iname
for index, iname in pairs(items) do
printed = false
for f in factions() do
trophies = 0

View File

@ -6,21 +6,6 @@ function loadscript(name)
end
end
function change_locales()
-- 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",
@ -28,8 +13,8 @@ function run_scripts()
"familiars.lua",
"write_emails.lua"
}
for index in scripts do
loadscript(scripts[index])
for index, name in pairs(scripts) do
loadscript(name)
end
end
@ -70,8 +55,6 @@ function process(orders)
update_guards()
update_scores()
change_locales()
-- use newfactions file to place out new players
autoseed(basepath .. "/newfactions", false)

View File

@ -285,9 +285,11 @@ function test_rewards()
items = { "hornofdancing", "trappedairelemental",
"aurapotion50", "bagpipeoffear",
"instantartacademy", "instantartsculpture" }
for index in items do
u:add_item(items[index], 1)
u:add_order('@BENUTZEN "' .. get_string("de", items[index]) .. '"')
local index
local item
for index, item in pairs(items) do
u:add_item(item, 1)
u:add_order('@BENUTZEN "' .. get_string("de", item) .. '"')
end
u:add_order("NUMMER PARTEI eviL")
@ -365,8 +367,10 @@ function run_scripts()
scripts = {
"xmas2004.lua"
}
for index in scripts do
local script = scriptpath .. "/" .. scripts[index]
local index
local name
for index, name in pairs(scripts) do
local script = scriptpath .. "/" .. name
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)

View File

@ -67,8 +67,10 @@ scripts = {
if orderfile==nil then
print "you must specify an orderfile"
else
for index in scripts do
local script = scriptpath .. "/" .. scripts[index]
local name
local index
for index, name in pairs(scripts) do
local script = scriptpath .. "/" .. name
print("- loading " .. script)
if pcall(dofile, script)==0 then
print("Could not load " .. script)

View File

@ -77,7 +77,8 @@ function make_faction(position, alliance, number, email, race)
end
local sk
for sk in skills do
local skill
for sk, skill in pairs(skills) do
u = add_unit(f, position)
-- anzahl personen berechnen
@ -86,7 +87,6 @@ function make_faction(position, alliance, number, email, race)
skillno = skillno - 1
u.number = number
local skill = skills[sk]
u:set_skill(skill, 3)
print("- " .. number .. " x " .. skill)

View File

@ -22,11 +22,12 @@ function write_standings()
log(file, "** Erfüllte Siegbedingungen **")
local condition
for condition in conditions do
local index
for index, condition in pairs(conditions) do
local none = true
log(file, conditions[condition])
log(file, condition)
for alliance in alliances() do
if victorycondition(alliance, condition)==1 then
if victorycondition(alliance, index)==1 then
log(file, " - " .. alliance.name .. " (" .. alliance.id .. ")")
none = false
end

View File

@ -3,8 +3,7 @@ function write_emails()
local locales = { "de", "en" }
local files = {}
local key
for key in locales do
local locale = locales[key]
for key, locale in pairs(locales) do
files[locale] = io.open(basepath .. "/emails." .. locale, "w")
end
@ -14,8 +13,8 @@ function write_emails()
files[faction.locale]:write(faction.email .. "\n")
end
for key in files do
files[key]:close()
for key, file in pairs(files) do
file:close()
end
end