Fix
This commit is contained in:
parent
9462e0b79b
commit
d214ee9d6b
1 changed files with 191 additions and 189 deletions
380
init.lua
380
init.lua
|
@ -1,190 +1,192 @@
|
||||||
local v=vector
|
local v=vector
|
||||||
local function get_node_force(pos)
|
local function get_node_force(pos)
|
||||||
local node=minetest.get_node(pos)
|
local node=minetest.get_node(pos)
|
||||||
if node.name=="ignore" then
|
if node.name=="ignore" then
|
||||||
minetest.get_voxel_manip(pos,pos)
|
minetest.get_voxel_manip(pos,pos)
|
||||||
return minetest.get_node(pos)
|
return minetest.get_node(pos)
|
||||||
end
|
end
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tochest(fpos,tpos)
|
local function tochest(fpos,tpos)
|
||||||
local finv=minetest.get_meta(fpos):get_inventory()
|
if v.equals(fpos,tpos) then return end
|
||||||
local tinv=minetest.get_meta(tpos):get_inventory()
|
local finv=minetest.get_meta(fpos):get_inventory()
|
||||||
for listn,items in pairs(finv:get_lists()) do
|
local tinv=minetest.get_meta(tpos):get_inventory()
|
||||||
for index,item in pairs(items) do
|
for listn,items in pairs(finv:get_lists()) do
|
||||||
local size=tinv:get_size("main")
|
for index,item in pairs(items) do
|
||||||
if size==0 or not tinv:get_stack("main",size):is_empty() then
|
local size=tinv:get_size("main")
|
||||||
tinv:set_size("main",size+1)
|
if size==0 or not tinv:get_stack("main",size):is_empty() then
|
||||||
end
|
tinv:set_size("main",size+1)
|
||||||
tinv:add_item("main",item)
|
end
|
||||||
end
|
tinv:add_item("main",item)
|
||||||
end
|
end
|
||||||
local fnode=get_node_force(fpos)
|
end
|
||||||
for _,item in pairs(minetest.get_node_drops(fnode)) do
|
local fnode=get_node_force(fpos)
|
||||||
local size=tinv:get_size("main")
|
for _,item in pairs(minetest.get_node_drops(fnode)) do
|
||||||
if size==0 or not tinv:get_stack("main",size):is_empty() then
|
local size=tinv:get_size("main")
|
||||||
tinv:set_size("main",size+1)
|
if size==0 or not tinv:get_stack("main",size):is_empty() then
|
||||||
end
|
tinv:set_size("main",size+1)
|
||||||
tinv:add_item("main",item)
|
end
|
||||||
end
|
tinv:add_item("main",item)
|
||||||
minetest.remove_node(fpos)
|
end
|
||||||
end
|
minetest.remove_node(fpos)
|
||||||
|
end
|
||||||
minetest.register_chatcommand("/itemstochest",{
|
|
||||||
params="<blocks/seconds>",
|
minetest.register_chatcommand("/itemstochest",{
|
||||||
func=function(n,p)
|
params="<blocks/seconds>",
|
||||||
local s=tonumber(p) or 250 -- 250 b/s
|
privs={worldedit=true},
|
||||||
local p=minetest.get_player_by_name(n)
|
func=function(n,p)
|
||||||
if not p then return end
|
local s=tonumber(p) or 250 -- 250 b/s
|
||||||
local pos1,pos2=worldedit.pos1[n],worldedit.pos2[n]
|
local p=minetest.get_player_by_name(n)
|
||||||
if not pos1 or not pos2 then
|
if not p then return end
|
||||||
return true,"WorldEdit -!- no region selected"
|
local pos1,pos2=worldedit.pos1[n],worldedit.pos2[n]
|
||||||
end
|
if not pos1 or not pos2 then
|
||||||
local ppos=v.round(p:get_pos())
|
return true,"WorldEdit -!- no region selected"
|
||||||
minetest.set_node(ppos,{name="worldedit:container",param2=minetest.dir_to_facedir(p:get_look_dir())})
|
end
|
||||||
local pos1,pos2=v.sort(pos1,pos2)
|
local ppos=v.round(p:get_pos())
|
||||||
local nodes={}
|
minetest.set_node(ppos,{name="worldedit:container",param2=minetest.dir_to_facedir(p:get_look_dir())})
|
||||||
for x=pos1.x,pos2.x do
|
local pos1,pos2=v.sort(pos1,pos2)
|
||||||
for y=pos1.y,pos2.y do
|
local nodes={}
|
||||||
for z=pos1.z,pos2.z do
|
for x=pos1.x,pos2.x do
|
||||||
table.insert(nodes,v.new(x,y,z))
|
for y=pos1.y,pos2.y do
|
||||||
end
|
for z=pos1.z,pos2.z do
|
||||||
end
|
table.insert(nodes,v.new(x,y,z))
|
||||||
end
|
end
|
||||||
local function run()
|
end
|
||||||
for _=1,s do
|
end
|
||||||
local pos=nodes[#nodes]
|
local function run()
|
||||||
if not pos then
|
for _=1,s do
|
||||||
local vmanip=minetest.get_voxel_manip(pos1,pos2)
|
local pos=nodes[#nodes]
|
||||||
vmanip:write_to_map()
|
if not pos then
|
||||||
vmanip:update_map()
|
local vmanip=minetest.get_voxel_manip(pos1,pos2)
|
||||||
return
|
vmanip:write_to_map()
|
||||||
end
|
vmanip:update_map()
|
||||||
nodes[#nodes]=nil
|
return
|
||||||
tochest(pos,ppos)
|
end
|
||||||
end
|
nodes[#nodes]=nil
|
||||||
minetest.after(1,run)
|
tochest(pos,ppos)
|
||||||
end
|
end
|
||||||
minetest.after(1,run)
|
minetest.after(1,run)
|
||||||
return true,"WorldEdit -!- "..#nodes.." nodes will be moved to the chest within seconds"
|
end
|
||||||
end
|
minetest.after(1,run)
|
||||||
})
|
return true,"WorldEdit -!- "..#nodes.." nodes will be moved to the chest within seconds"
|
||||||
|
end
|
||||||
local function formspec(pos,f)
|
})
|
||||||
local meta=minetest.get_meta(pos)
|
|
||||||
local inv=meta:get_inventory()
|
local function formspec(pos,f)
|
||||||
inv:set_size("main",math.max(8*4,inv:get_size("main")))
|
local meta=minetest.get_meta(pos)
|
||||||
local i=meta:get_int("index")
|
local inv=meta:get_inventory()
|
||||||
local limit=math.floor((inv:get_size("main")+8*4-1)/(8*4))
|
inv:set_size("main",math.max(8*4,inv:get_size("main")))
|
||||||
if f.next then
|
local i=meta:get_int("index")
|
||||||
i=i+1
|
local limit=math.floor((inv:get_size("main")+8*4-1)/(8*4))
|
||||||
if i>=limit then i=0 end
|
if f.next then
|
||||||
elseif f.ret then
|
i=i+1
|
||||||
i=i-1
|
if i>=limit then i=0 end
|
||||||
if i<0 then i=limit-1 end
|
elseif f.ret then
|
||||||
elseif f.fnext then
|
i=i-1
|
||||||
i=limit-1
|
if i<0 then i=limit-1 end
|
||||||
elseif f.fret then
|
elseif f.fnext then
|
||||||
i=0
|
i=limit-1
|
||||||
end
|
elseif f.fret then
|
||||||
meta:set_int("index",i)
|
i=0
|
||||||
meta:set_string("infotext","Container")
|
end
|
||||||
meta:set_string("formspec","size[8,9]"..
|
meta:set_int("index",i)
|
||||||
((default and default.gui_bg) or "")..
|
meta:set_string("infotext","Container")
|
||||||
((default and default.gui_bg_img) or "")..
|
meta:set_string("formspec","size[8,9]"..
|
||||||
((default and default.gui_slots) or "")..
|
((default and default.gui_bg) or "")..
|
||||||
"list[current_name;main;0,0;8,4;"..(i*8*4).."]"..
|
((default and default.gui_bg_img) or "")..
|
||||||
((default and default.get_hotbar_bg) and default.get_hotbar_bg(0,6) or "")..
|
((default and default.gui_slots) or "")..
|
||||||
"list[current_player;main;0,5;8,4;]"..
|
"list[current_name;main;0,0;8,4;"..(i*8*4).."]"..
|
||||||
"button[0,4;2,1;fret;|<<]button[2,4;1,1;ret;<]"..
|
((default and default.get_hotbar_bg) and default.get_hotbar_bg(0,6) or "")..
|
||||||
"button[3,4;2,1;info;"..(i+1).."/"..limit.."]"..
|
"list[current_player;main;0,5;8,4;]"..
|
||||||
"button[5,4;1,1;next;>]button[6,4;2,1;fnext;>>|]"..
|
"button[0,4;2,1;fret;|<<]button[2,4;1,1;ret;<]"..
|
||||||
"listring[]")
|
"button[3,4;2,1;info;"..(i+1).."/"..limit.."]"..
|
||||||
end
|
"button[5,4;1,1;next;>]button[6,4;2,1;fnext;>>|]"..
|
||||||
|
"listring[]")
|
||||||
local c="^[colorize:blue:150"
|
end
|
||||||
local c2="digtron_digger_yb_frame.png"
|
|
||||||
local s=7
|
local c="^[colorize:blue:150"
|
||||||
local nodebox={{-s/16,-s/16,-s/16,s/16,s/16,s/16}}
|
local c2="digtron_digger_yb_frame.png"
|
||||||
for n=1,4 do
|
local s=7
|
||||||
local a,b=v.new(-8/16,-8/16,-8/16),v.new(-7/16,-7/16,8/16)
|
local nodebox={{-s/16,-s/16,-s/16,s/16,s/16,s/16}}
|
||||||
for _=2,n do
|
for n=1,4 do
|
||||||
a=v.new(-a.z,a.y,a.x)
|
local a,b=v.new(-8/16,-8/16,-8/16),v.new(-7/16,-7/16,8/16)
|
||||||
b=v.new(-b.z,b.y,b.x)
|
for _=2,n do
|
||||||
end
|
a=v.new(-a.z,a.y,a.x)
|
||||||
local a,b=v.sort(a,b)
|
b=v.new(-b.z,b.y,b.x)
|
||||||
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
end
|
||||||
|
local a,b=v.sort(a,b)
|
||||||
local a,b=v.new(-8/16,7/16,-8/16),v.new(-7/16,8/16,8/16)
|
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
||||||
for _=2,n do
|
|
||||||
a=v.new(-a.z,a.y,a.x)
|
local a,b=v.new(-8/16,7/16,-8/16),v.new(-7/16,8/16,8/16)
|
||||||
b=v.new(-b.z,b.y,b.x)
|
for _=2,n do
|
||||||
end
|
a=v.new(-a.z,a.y,a.x)
|
||||||
local a,b=v.sort(a,b)
|
b=v.new(-b.z,b.y,b.x)
|
||||||
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
end
|
||||||
|
local a,b=v.sort(a,b)
|
||||||
local a,b=v.new(-8/16,-8/16,-8/16),v.new(-7/16,8/16,-7/16)
|
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
||||||
for _=2,n do
|
|
||||||
a=v.new(-a.z,a.y,a.x)
|
local a,b=v.new(-8/16,-8/16,-8/16),v.new(-7/16,8/16,-7/16)
|
||||||
b=v.new(-b.z,b.y,b.x)
|
for _=2,n do
|
||||||
end
|
a=v.new(-a.z,a.y,a.x)
|
||||||
local a,b=v.sort(a,b)
|
b=v.new(-b.z,b.y,b.x)
|
||||||
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
end
|
||||||
|
local a,b=v.sort(a,b)
|
||||||
local a,b=v.new(-8/16,-8/16,-8/16),v.new(-5/16,-5/16,-5/16)
|
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
||||||
for _=2,n do
|
|
||||||
a=v.new(-a.z,a.y,a.x)
|
local a,b=v.new(-8/16,-8/16,-8/16),v.new(-5/16,-5/16,-5/16)
|
||||||
b=v.new(-b.z,b.y,b.x)
|
for _=2,n do
|
||||||
end
|
a=v.new(-a.z,a.y,a.x)
|
||||||
local a,b=v.sort(a,b)
|
b=v.new(-b.z,b.y,b.x)
|
||||||
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
end
|
||||||
|
local a,b=v.sort(a,b)
|
||||||
local a,b=v.new(-8/16,5/16,-8/16),v.new(-5/16,8/16,-5/16)
|
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
||||||
for _=2,n do
|
|
||||||
a=v.new(-a.z,a.y,a.x)
|
local a,b=v.new(-8/16,5/16,-8/16),v.new(-5/16,8/16,-5/16)
|
||||||
b=v.new(-b.z,b.y,b.x)
|
for _=2,n do
|
||||||
end
|
a=v.new(-a.z,a.y,a.x)
|
||||||
local a,b=v.sort(a,b)
|
b=v.new(-b.z,b.y,b.x)
|
||||||
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
end
|
||||||
end
|
local a,b=v.sort(a,b)
|
||||||
|
table.insert(nodebox,{a.x,a.y,a.z,b.x,b.y,b.z})
|
||||||
minetest.register_node(":worldedit:container",{
|
end
|
||||||
tiles={
|
|
||||||
"default_chest_top.png"..c.."^"..c2,
|
minetest.register_node(":worldedit:container",{
|
||||||
"default_chest_top.png"..c.."^"..c2,
|
tiles={
|
||||||
"default_chest_side.png"..c.."^"..c2,
|
"default_chest_top.png"..c.."^"..c2,
|
||||||
"default_chest_side.png"..c.."^"..c2,
|
"default_chest_top.png"..c.."^"..c2,
|
||||||
"default_chest_side.png"..c.."^("..c2.."^[transformR90)",
|
"default_chest_side.png"..c.."^"..c2,
|
||||||
"default_chest_lock.png"..c.."^("..c2.."^[transformR90)",
|
"default_chest_side.png"..c.."^"..c2,
|
||||||
},
|
"default_chest_side.png"..c.."^("..c2.."^[transformR90)",
|
||||||
drawtype="nodebox",paramtype="light",
|
"default_chest_lock.png"..c.."^("..c2.."^[transformR90)",
|
||||||
node_box={type="fixed",fixed=nodebox},
|
},
|
||||||
|
drawtype="nodebox",paramtype="light",
|
||||||
paramtype2="facedir",
|
node_box={type="fixed",fixed=nodebox},
|
||||||
legacy_facedir_simple=true,
|
|
||||||
groups={choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
paramtype2="facedir",
|
||||||
sounds=default and default.node_sound_wood_defaults() or nil,
|
legacy_facedir_simple=true,
|
||||||
drop="",
|
groups={choppy=2,oddly_breakable_by_hand=2,tubedevice=1,tubedevice_receiver=1},
|
||||||
on_construct=function(pos) formspec(pos,{}) end,
|
sounds=default and default.node_sound_wood_defaults() or nil,
|
||||||
on_rightclick=function(pos) formspec(pos,{}) end,
|
drop="",
|
||||||
on_receive_fields=function(pos,_,f) formspec(pos,f) end,
|
on_construct=function(pos) formspec(pos,{}) end,
|
||||||
tube={
|
on_rightclick=function(pos) formspec(pos,{}) end,
|
||||||
connect_sides={left=1,right=1,back=1,front=1,bottom=1,top=1},
|
on_receive_fields=function(pos,_,f) formspec(pos,f) end,
|
||||||
input_inventory="main",
|
tube={
|
||||||
},
|
connect_sides={left=1,right=1,back=1,front=1,bottom=1,top=1},
|
||||||
allow_metadata_inventory_move=function() return 0 end,
|
input_inventory="main",
|
||||||
allow_metadata_inventory_put=function() return 0 end,
|
},
|
||||||
allow_metadata_inventory_take=function(pos,l,i,s,p)
|
allow_metadata_inventory_move=function() return 0 end,
|
||||||
return not minetest.is_protected(pos,p:get_player_name()) and s:get_count() or 0
|
allow_metadata_inventory_put=function() return 0 end,
|
||||||
end,
|
allow_metadata_inventory_take=function(pos,l,i,s,p)
|
||||||
can_dig=function(pos)
|
return not minetest.is_protected(pos,p:get_player_name()) and s:get_count() or 0
|
||||||
return minetest.get_meta(pos):get_inventory():is_empty("main")
|
end,
|
||||||
end,
|
can_dig=function(pos)
|
||||||
})
|
return minetest.get_meta(pos):get_inventory():is_empty("main")
|
||||||
|
end,
|
||||||
minetest.register_on_punchnode(function(pos)
|
})
|
||||||
local vmanip=minetest.get_voxel_manip(pos,v.add(pos,v.new(0,50,0)))
|
|
||||||
vmanip:write_to_map()
|
minetest.register_on_punchnode(function(pos)
|
||||||
vmanip:update_map()
|
local vmanip=minetest.get_voxel_manip(pos,v.add(pos,v.new(0,50,0)))
|
||||||
|
vmanip:write_to_map()
|
||||||
|
vmanip:update_map()
|
||||||
end)
|
end)
|
Loading…
Reference in a new issue