forked from github/server
always call close() in lua when you're done with a file.
This commit is contained in:
parent
cb36224e30
commit
fdb5ecc68b
|
@ -39,13 +39,17 @@ local function read_players()
|
||||||
-- return {{ email = "noreply@mailinator.com", race = "dwarf", lang = "de" }}
|
-- return {{ email = "noreply@mailinator.com", race = "dwarf", lang = "de" }}
|
||||||
local players = {}
|
local players = {}
|
||||||
local input = io.open("newfactions", "r")
|
local input = io.open("newfactions", "r")
|
||||||
while input do
|
if input then
|
||||||
local str = input:read("*line")
|
local str = input:read("*line")
|
||||||
if str==nil then break end
|
while str do
|
||||||
local email, race, lang = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
|
if str==nil then break end
|
||||||
if email and string.char(string.byte(email, 1))~='#' then
|
local email, race, lang = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
|
||||||
table.insert(players, { race = race, lang = lang, email = email })
|
if email and string.char(string.byte(email, 1))~='#' then
|
||||||
|
table.insert(players, { race = race, lang = lang, email = email })
|
||||||
|
end
|
||||||
|
str = input:read("*line")
|
||||||
end
|
end
|
||||||
|
input:close()
|
||||||
end
|
end
|
||||||
return players
|
return players
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,7 @@ function cursed.init()
|
||||||
if f then
|
if f then
|
||||||
print("found cursed.txt")
|
print("found cursed.txt")
|
||||||
curse(f)
|
curse(f)
|
||||||
|
f:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -124,30 +124,33 @@ end
|
||||||
|
|
||||||
function seed()
|
function seed()
|
||||||
local input = io.open(config.basepath .. "/parteien.txt")
|
local input = io.open(config.basepath .. "/parteien.txt")
|
||||||
for f in factions() do
|
if input then
|
||||||
if f.race=="vampunicorn" then
|
for f in factions() do
|
||||||
local str = input:read("*line")
|
if f.race=="vampunicorn" then
|
||||||
if str==nil then break end
|
local str = input:read("*line")
|
||||||
local race, lang, email = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
|
if str==nil then break end
|
||||||
f.race = race:lower()
|
local race, lang, email = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
|
||||||
f.options = f.options + 4096
|
f.race = race:lower()
|
||||||
f.email = email
|
f.options = f.options + 4096
|
||||||
f.locale = lang
|
f.email = email
|
||||||
for u in f.units do
|
f.locale = lang
|
||||||
u.race = race:lower()
|
for u in f.units do
|
||||||
u.hp = u.hp_max
|
u.race = race:lower()
|
||||||
local b = building.create(u.region, "castle")
|
u.hp = u.hp_max
|
||||||
if lang=="de" then
|
local b = building.create(u.region, "castle")
|
||||||
u.name = "Entdecker"
|
if lang=="de" then
|
||||||
b.name = "Heimat"
|
u.name = "Entdecker"
|
||||||
else
|
b.name = "Heimat"
|
||||||
u.name = "Explorer"
|
else
|
||||||
b.name = "Home"
|
u.name = "Explorer"
|
||||||
|
b.name = "Home"
|
||||||
|
end
|
||||||
|
b.size = 10
|
||||||
|
u.building = b
|
||||||
|
end
|
||||||
end
|
end
|
||||||
b.size = 10
|
|
||||||
u.building = b
|
|
||||||
end
|
end
|
||||||
end
|
input:close()
|
||||||
end
|
end
|
||||||
for r in regions() do
|
for r in regions() do
|
||||||
r:set_resource("sapling", r:get_resource("tree")/4)
|
r:set_resource("sapling", r:get_resource("tree")/4)
|
||||||
|
|
|
@ -27,27 +27,29 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
local f=assert(io.open("factions", "r"))
|
local f=assert(io.open("factions", "r"))
|
||||||
line=f:read("*line")
|
if f then
|
||||||
players = {}
|
|
||||||
emails = {}
|
|
||||||
patrons = {}
|
|
||||||
nplayers = 0
|
|
||||||
while line~=nil do
|
|
||||||
fields = {}
|
|
||||||
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
|
||||||
line=f:read("*line")
|
line=f:read("*line")
|
||||||
email = fields[1]
|
players = {}
|
||||||
if fields[2]=='yes' then
|
emails = {}
|
||||||
table.insert(patrons, email)
|
patrons = {}
|
||||||
else
|
nplayers = 0
|
||||||
table.insert(emails, email)
|
while line~=nil do
|
||||||
|
fields = {}
|
||||||
|
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
||||||
|
line=f:read("*line")
|
||||||
|
email = fields[1]
|
||||||
|
if fields[2]=='yes' then
|
||||||
|
table.insert(patrons, email)
|
||||||
|
else
|
||||||
|
table.insert(emails, email)
|
||||||
|
end
|
||||||
|
if fields[3]=='German' then lang='de' else lang='en' end
|
||||||
|
race=string.gsub(fields[4], "/.*", ''):lower()
|
||||||
|
players[email] = { ['lang'] = lang, ['race'] = race }
|
||||||
|
nplayers = nplayers + 1
|
||||||
end
|
end
|
||||||
if fields[3]=='German' then lang='de' else lang='en' end
|
f:close()
|
||||||
race=string.gsub(fields[4], "/.*", ''):lower()
|
|
||||||
players[email] = { ['lang'] = lang, ['race'] = race }
|
|
||||||
nplayers = nplayers + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, r in ipairs(homes) do
|
for k, r in ipairs(homes) do
|
||||||
print(k, r)
|
print(k, r)
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,27 +27,29 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
local f=assert(io.open("factions", "r"))
|
local f=assert(io.open("factions", "r"))
|
||||||
line=f:read("*line")
|
if f then
|
||||||
players = {}
|
|
||||||
emails = {}
|
|
||||||
patrons = {}
|
|
||||||
nplayers = 0
|
|
||||||
while line~=nil do
|
|
||||||
fields = {}
|
|
||||||
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
|
||||||
line=f:read("*line")
|
line=f:read("*line")
|
||||||
email = fields[1]
|
players = {}
|
||||||
if fields[2]=='yes' then
|
emails = {}
|
||||||
table.insert(patrons, email)
|
patrons = {}
|
||||||
else
|
nplayers = 0
|
||||||
table.insert(emails, email)
|
while line~=nil do
|
||||||
|
fields = {}
|
||||||
|
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
||||||
|
line=f:read("*line")
|
||||||
|
email = fields[1]
|
||||||
|
if fields[2]=='yes' then
|
||||||
|
table.insert(patrons, email)
|
||||||
|
else
|
||||||
|
table.insert(emails, email)
|
||||||
|
end
|
||||||
|
if fields[3]=='German' then lang='de' else lang='en' end
|
||||||
|
race=string.gsub(fields[4], "/.*", ''):lower()
|
||||||
|
players[email] = { ['lang'] = lang, ['race'] = race }
|
||||||
|
nplayers = nplayers + 1
|
||||||
end
|
end
|
||||||
if fields[3]=='German' then lang='de' else lang='en' end
|
f:close()
|
||||||
race=string.gsub(fields[4], "/.*", ''):lower()
|
|
||||||
players[email] = { ['lang'] = lang, ['race'] = race }
|
|
||||||
nplayers = nplayers + 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, r in ipairs(homes) do
|
for k, r in ipairs(homes) do
|
||||||
print(k, r)
|
print(k, r)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue