factions/convert.lua

46 lines
1.1 KiB
Lua
Raw Normal View History

2019-01-26 07:21:05 +01:00
function ip_convert()
local path = minetest.get_worldpath() .. "/factions_iplist.txt"
local file, error = io.open(path, "r")
if file ~= nil then
local raw_data = file:read("*a")
local ips = minetest.deserialize(raw_data)
file:close()
for i, k in pairs(ips) do
factions.player_ips.set(i, k)
end
os.rename(path, minetest.get_worldpath() .. "/factions_iplist_old.txt")
end
end
function faction_convert()
local path = minetest.get_worldpath() .. "/factions.conf"
local file, error = io.open(path, "r")
if file ~= nil then
local raw_data = file:read("*a")
local tabledata = minetest.deserialize(raw_data)
file:close()
if tabledata then
for facname, faction in pairs(tabledata) do
factions.factions.set(facname, faction)
for player, rank in pairs(faction.players) do
factions.players.set(player, facname)
end
for parcelpos, val in pairs(faction.land) do
factions.parcels.set(parcelpos, facname)
end
end
2019-01-26 18:03:09 +01:00
os.rename(path, minetest.get_worldpath() .. "/factions_old.conf")
2019-01-26 07:21:05 +01:00
end
end
end
ip_convert()
faction_convert()