Add the loading code too
This commit is contained in:
parent
f32d463c7c
commit
aa22858cfa
1
depends.txt
Normal file
1
depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
worldedit
|
42
init.lua
Normal file
42
init.lua
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
local timer = 0
|
||||||
|
|
||||||
|
local function load(pos)
|
||||||
|
local filename = minetest.get_worldpath().."/blocks/"..math.floor(pos.x/16).."."..math.floor(pos.y/16).."."..math.floor(pos.z/16)..".we"
|
||||||
|
local pos1 = {x = math.floor(pos.x/16)*16, y = math.floor(pos.y/16)*16, z = math.floor(pos.z/16)*16}
|
||||||
|
local pos2 = vector.add(pos1, {x=15, y=15, z=15})
|
||||||
|
local file, err
|
||||||
|
file, err = io.open(filename, "rb")
|
||||||
|
if err then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
worldedit.set(pos1, pos2, "air")
|
||||||
|
local content = file:read("*a")
|
||||||
|
file:close()
|
||||||
|
os.remove(filename)
|
||||||
|
worldedit.deserialize(pos1, content)
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
timer = timer + dtime
|
||||||
|
if timer < 5 then return end
|
||||||
|
timer = 0
|
||||||
|
|
||||||
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
|
local pos = player:getpos()
|
||||||
|
|
||||||
|
load(pos)
|
||||||
|
load({x=pos.x-16, y=pos.y, z=pos.z})
|
||||||
|
load({x=pos.x, y=pos.y-16, z=pos.z})
|
||||||
|
load({x=pos.x, y=pos.y, z=pos.z-16})
|
||||||
|
load({x=pos.x+16, y=pos.y, z=pos.z})
|
||||||
|
load({x=pos.x, y=pos.y+16, z=pos.z})
|
||||||
|
load({x=pos.x, y=pos.y, z=pos.z+16})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_tool("mcimport:test", {
|
||||||
|
description = "Test",
|
||||||
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
print(dump(minetest.get_node(pointed_thing.under)))
|
||||||
|
end,
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user