1 local world_path = minetest.get_worldpath()
2 local org_file = world_path .. "/beds_spawns"
3 local file = world_path .. "/beds_spawns"
6 -- check for PA's beds mod spawns
7 local cf = io.open(world_path .. "/beds_player_spawns", "r")
10 file = world_path .. "/beds_player_spawns"
14 function beds.read_spawns()
15 local spawns = beds.spawn
16 local input = io.open(file, "r")
17 if input and not bkwd then
19 local x = input:read("*n")
23 local y = input:read("*n")
24 local z = input:read("*n")
25 local name = input:read("*l")
26 spawns[name:sub(2)] = {x = x, y = y, z = z}
27 until input:read(0) == nil
29 elseif input and bkwd then
30 beds.spawn = minetest.deserialize(input:read("*all"))
33 os.rename(file, file .. ".backup")
40 function beds.save_spawns()
41 if not beds.spawn then
44 local output = io.open(org_file, "w")
45 for i, v in pairs(beds.spawn) do
46 output:write(v.x.." "..v.y.." "..v.z.." "..i.."\n")
51 function beds.set_spawns()
52 for name,_ in pairs(beds.player) do
53 local player = minetest.get_player_by_name(name)
54 local p = player:getpos()