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")
|
||||||
|
while str do
|
||||||
if str==nil then break end
|
if str==nil then break end
|
||||||
local email, race, lang = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
|
local email, race, lang = str:match("([^ ]*) ([^ ]*) ([^ ]*)")
|
||||||
if email and string.char(string.byte(email, 1))~='#' then
|
if email and string.char(string.byte(email, 1))~='#' then
|
||||||
table.insert(players, { race = race, lang = lang, email = email })
|
table.insert(players, { race = race, lang = lang, email = email })
|
||||||
end
|
end
|
||||||
|
str = input:read("*line")
|
||||||
|
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,6 +124,7 @@ end
|
||||||
|
|
||||||
function seed()
|
function seed()
|
||||||
local input = io.open(config.basepath .. "/parteien.txt")
|
local input = io.open(config.basepath .. "/parteien.txt")
|
||||||
|
if input then
|
||||||
for f in factions() do
|
for f in factions() do
|
||||||
if f.race=="vampunicorn" then
|
if f.race=="vampunicorn" then
|
||||||
local str = input:read("*line")
|
local str = input:read("*line")
|
||||||
|
@ -149,6 +150,8 @@ function seed()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
input:close()
|
||||||
|
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)
|
||||||
r:set_resource("seed", 0)
|
r:set_resource("seed", 0)
|
||||||
|
|
|
@ -27,12 +27,13 @@ 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 = {}
|
line=f:read("*line")
|
||||||
emails = {}
|
players = {}
|
||||||
patrons = {}
|
emails = {}
|
||||||
nplayers = 0
|
patrons = {}
|
||||||
while line~=nil do
|
nplayers = 0
|
||||||
|
while line~=nil do
|
||||||
fields = {}
|
fields = {}
|
||||||
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
||||||
line=f:read("*line")
|
line=f:read("*line")
|
||||||
|
@ -46,8 +47,9 @@ while line~=nil do
|
||||||
race=string.gsub(fields[4], "/.*", ''):lower()
|
race=string.gsub(fields[4], "/.*", ''):lower()
|
||||||
players[email] = { ['lang'] = lang, ['race'] = race }
|
players[email] = { ['lang'] = lang, ['race'] = race }
|
||||||
nplayers = nplayers + 1
|
nplayers = nplayers + 1
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
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,12 +27,13 @@ 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 = {}
|
line=f:read("*line")
|
||||||
emails = {}
|
players = {}
|
||||||
patrons = {}
|
emails = {}
|
||||||
nplayers = 0
|
patrons = {}
|
||||||
while line~=nil do
|
nplayers = 0
|
||||||
|
while line~=nil do
|
||||||
fields = {}
|
fields = {}
|
||||||
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
line:gsub("([^\t]*)\t*", function(c) table.insert(fields, c) end)
|
||||||
line=f:read("*line")
|
line=f:read("*line")
|
||||||
|
@ -46,8 +47,9 @@ while line~=nil do
|
||||||
race=string.gsub(fields[4], "/.*", ''):lower()
|
race=string.gsub(fields[4], "/.*", ''):lower()
|
||||||
players[email] = { ['lang'] = lang, ['race'] = race }
|
players[email] = { ['lang'] = lang, ['race'] = race }
|
||||||
nplayers = nplayers + 1
|
nplayers = nplayers + 1
|
||||||
|
end
|
||||||
|
f:close()
|
||||||
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