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