forked from Bremaweb/landrush
-
Notifications
You must be signed in to change notification settings - Fork 3
/
claims.lua
46 lines (43 loc) · 1.05 KB
/
claims.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
landrush.claimFile = worldpath.."/landrush-claims"
landrush.claims = {}
function landrush.load_claims()
local file = io.open(landrush.claimFile, "r")
if file then
for line in file:lines() do
if line ~= "" then
local area = line:split(" ")
local shared = {}
if area[3] and area[3] ~= "*" then
for k,v in ipairs(area[3]:split(",")) do
shared[v] = v
end
end
local claimtype
if area[4] then
claimtype = area[4]
else
claimtype = "landrush:landclaim"
end
landrush.claims[area[1]] = {owner=area[2], shared=shared, claimtype=claimtype}
end
end
file:close()
end
end
function landrush.save_claims()
local file = io.open(landrush.claimFile, "w")
for key,value in pairs(landrush.claims) do
local sharedata = ""
for k,v in pairs(value.shared) do
sharedata = sharedata..v..","
end
local sharestring
if sharedata == "" then
sharestring = "*"
else
sharestring = sharedata:sub(1,-2)
end
file:write(key.." "..value.owner.." "..sharestring.." "..value.claimtype.."\n")
end
file:close()
end