Move files to subfolders

This commit is contained in:
ShadowNinja
2013-07-11 12:19:09 -04:00
parent afc84d6a8d
commit 5d470cd753
63 changed files with 80 additions and 2276 deletions

View File

@ -0,0 +1,344 @@
minetest.register_craft({
type = "shapeless",
output = 'technic:constructor_mk1_off 1',
recipe = {'technic:nodebreaker_off', 'technic:deployer_off'},
})
minetest.register_craft({
type = "shapeless",
output = 'technic:constructor_mk2_off 1',
recipe = {'technic:constructor_mk1_off', 'technic:constructor_mk1_off'},
})
minetest.register_craft({
type = "shapeless",
output = 'technic:constructor_mk3_off 1',
recipe = {'technic:constructor_mk2_off', 'technic:constructor_mk2_off'},
})
mk1_on = function(pos, node)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
if node.param2==3 then pos1.x=pos1.x+1 end
if node.param2==2 then pos1.z=pos1.z+1 end
if node.param2==1 then pos1.x=pos1.x-1 end
if node.param2==0 then pos1.z=pos1.z-1 end
if node.name == "technic:constructor_mk1_off" then
hacky_swap_node(pos,"technic:constructor_mk1_on")
nodeupdate(pos)
local node1=minetest.env:get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node)
end
end
mk1_off = function(pos, node)
if node.name == "technic:constructor_mk1_on" then
hacky_swap_node(pos,"technic:constructor_mk1_off")
nodeupdate(pos)
end
end
minetest.register_node("technic:constructor_mk1_off", {
description = "Constructor MK1",
tile_images = {"technic_constructor_mk1_top_off.png","technic_constructor_mk1_bottom_off.png","technic_constructor_mk1_side2_off.png","technic_constructor_mk1_side1_off.png",
"technic_constructor_back.png","technic_constructor_front_off.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
mesecons= {effector={action_on=mk1_on}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Constructor MK1]"..
"label[5,0;Slot 1]"..
"list[current_name;slot1;6,0;1,1;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Constructor MK1")
local inv = meta:get_inventory()
inv:set_size("slot1", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
return inv:is_empty("slot1")
end,
})
minetest.register_node("technic:constructor_mk1_on", {
description = "Constructor MK1",
tile_images = {"technic_constructor_mk1_top_on.png","technic_constructor_mk1_bottom_on.png","technic_constructor_mk1_side2_on.png","technic_constructor_mk1_side1_on.png",
"technic_constructor_back.png","technic_constructor_front_on.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon = 2,not_in_creative_inventory=1},
mesecons= {effector={action_off=mk1_off}},
sounds = default.node_sound_stone_defaults(),
})
--Constructor MK2
mk2_on = function(pos, node)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
local pos2={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos2.x=pos.x
pos2.y=pos.y
pos2.z=pos.z
if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 end
if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 end
if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 end
if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end
if node.name == "technic:constructor_mk2_off" then
hacky_swap_node(pos,"technic:constructor_mk2_on")
nodeupdate(pos)
local node1=minetest.env:get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node)
local node1=minetest.env:get_node(pos2)
deploy_node (inv,"slot2",pos2,node1,node)
end
end
mk2_off = function(pos, node)
if node.name == "technic:constructor_mk2_on" then
hacky_swap_node(pos,"technic:constructor_mk2_off")
nodeupdate(pos)
end
end
minetest.register_node("technic:constructor_mk2_off", {
description = "Constructor MK2",
tile_images = {"technic_constructor_mk2_top_off.png","technic_constructor_mk2_bottom_off.png","technic_constructor_mk2_side2_off.png","technic_constructor_mk2_side1_off.png",
"technic_constructor_back.png","technic_constructor_front_off.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
mesecons= {effector={action_on=mk2_on}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Constructor MK2]"..
"label[5,0;Slot 1]"..
"list[current_name;slot1;6,0;1,1;]"..
"label[5,1;Slot 2]"..
"list[current_name;slot2;6,1;1,1;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Constructor MK2")
local inv = meta:get_inventory()
inv:set_size("slot1", 1)
inv:set_size("slot2", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
return true
end,
})
minetest.register_node("technic:constructor_mk2_on", {
description = "Constructor MK2",
tile_images = {"technic_constructor_mk2_top_on.png","technic_constructor_mk2_bottom_on.png","technic_constructor_mk2_side2_on.png","technic_constructor_mk2_side1_on.png",
"technic_constructor_back.png","technic_constructor_front_on.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2, not_in_creative_inventory=1},
mesecons= {effector={action_off=mk2_off}},
sounds = default.node_sound_stone_defaults(),
})
-- Constructor MK3
mk3_on = function(pos, node)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local pos1={}
local pos2={}
local pos3={}
local pos4={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos2.x=pos.x
pos2.y=pos.y
pos2.z=pos.z
pos3.x=pos.x
pos3.y=pos.y
pos3.z=pos.z
pos4.x=pos.x
pos4.y=pos.y
pos4.z=pos.z
if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 pos3.x=pos3.x+3 pos4.x=pos4.x+4 end
if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 pos3.z=pos3.z+3 pos4.z=pos4.z+4 end
if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 pos3.x=pos3.x-3 pos4.x=pos4.x-4 end
if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end
if node.name == "technic:constructor_mk3_off" then
hacky_swap_node(pos,"technic:constructor_mk3_on")
nodeupdate(pos)
local node1=minetest.env:get_node(pos1)
deploy_node (inv,"slot1",pos1,node1,node)
local node1=minetest.env:get_node(pos2)
deploy_node (inv,"slot2",pos2,node1,node)
local node1=minetest.env:get_node(pos3)
deploy_node (inv,"slot3",pos3,node1,node)
local node1=minetest.env:get_node(pos4)
deploy_node (inv,"slot4",pos4,node1,node)
end
end
mk3_off = function(pos, node)
if node.name == "technic:constructor_mk3_on" then
hacky_swap_node(pos,"technic:constructor_mk3_off")
nodeupdate(pos)
end
end
minetest.register_node("technic:constructor_mk3_off", {
description = "Constructor MK3",
tile_images = {"technic_constructor_mk3_top_off.png","technic_constructor_mk3_bottom_off.png","technic_constructor_mk3_side2_off.png","technic_constructor_mk3_side1_off.png",
"technic_constructor_back.png","technic_constructor_front_off.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2},
mesecons= {effector={action_on=mk3_on}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Constructor MK2]"..
"label[5,0;Slot 1]"..
"list[current_name;slot1;6,0;1,1;]"..
"label[5,1;Slot 2]"..
"list[current_name;slot2;6,1;1,1;]"..
"label[5,2;Slot 3]"..
"list[current_name;slot3;6,2;1,1;]"..
"label[5,3;Slot 4]"..
"list[current_name;slot4;6,3;1,1;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Constructor MK3")
local inv = meta:get_inventory()
inv:set_size("slot1", 1)
inv:set_size("slot2", 1)
inv:set_size("slot3", 1)
inv:set_size("slot4", 1)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos)
local inv = meta:get_inventory()
if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end
return true
end,
})
minetest.register_node("technic:constructor_mk3_on", {
description = "Constructor MK3",
tile_images = {"technic_constructor_mk3_top_on.png","technic_constructor_mk3_bottom_on.png","technic_constructor_mk3_side2_on.png","technic_constructor_mk3_side1_on.png",
"technic_constructor_back.png","technic_constructor_front_on.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,not_in_creative_inventory=1},
mesecons= {effector={action_off=mk3_off}},
sounds = default.node_sound_stone_defaults(),
})
deploy_node =function (inv, slot_name, pos1, node1, node)
if node1.name == "air" then
if not inv:is_empty(slot_name) then
stack1=inv:get_list(slot_name)
local def = stack1[1]:get_definition()
if def.type == "node" then
node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
minetest.env:set_node(pos1,node_to_be_placed)
stack1[1]:take_item()
inv:set_stack(slot_name, 1, stack1[1])
elseif def.type == "craft" then
if def.on_place then
-- print("deploy_node: item has on_place. trying...")
local ok, stk = pcall(def.on_place, stack1[1], nil, {
-- Fake pointed_thing
type = "node",
above = pos1,
under = { x=pos1.x, y=pos1.y-1, z=pos1.z },
})
if ok then
-- print("deploy_node: on_place succeeded!")
inv:set_stack(slot_name, 1, stk or stack1[1])
return
-- else
-- print("deploy_node: WARNING: error while running on_place: "..tostring(stk))
end
end
minetest.item_place_object(stack1[1], nil, {
-- Fake pointed_thing
type = "node",
above = pos1,
under = pos1,
})
inv:set_stack(slot_name, 1, nil)
end
end
return
end
if node1.name == "ignore" or
node1.name == "default:lava_source" or
node1.name == "default:lava_flowing" or
node1.name == "default:water_source" or
node1.name == "default:water_flowing"
then return end
if inv:room_for_item(slot_name,node1) then
local def = minetest.registered_nodes[node1.name]
if not def then return end
local drop = def.drop or node1.name
if type(drop) == "table" then
local pr = PseudoRandom(math.random())
local c = 0
local loop = 0 -- Prevent infinite loop
while (c < (drop.max_items or 1)) and (loop < 1000) do
local i = math.floor(pr:next(1, #drop.items))
if pr:next(1, drop.items[i].rarity or 1) == 1 then
for _,item in ipairs(drop.items[i].items) do
inv:add_item(slot_name,item)
end
c = c + 1
end
loop = loop + 1
end
minetest.env:remove_node(pos1)
elseif type(drop) == "string" then
inv:add_item(slot_name,drop)
minetest.env:remove_node(pos1)
end
end
end

View File

@ -0,0 +1,113 @@
minetest.register_craft({
output = 'technic:deployer_off 1',
recipe = {
{'default:wood', 'default:chest','default:wood'},
{'default:stone', 'mesecons:piston','default:stone'},
{'default:stone', 'mesecons:mesecon','default:stone'},
}
})
deployer_signal_on = function(pos, node)
local pos1={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
if node.param2==3 then pos1.x=pos1.x+1 end
if node.param2==2 then pos1.z=pos1.z+1 end
if node.param2==1 then pos1.x=pos1.x-1 end
if node.param2==0 then pos1.z=pos1.z-1 end
if node.name == "technic:deployer_off" then
local node1=minetest.env:get_node(pos1)
if node1.name == "air" then
hacky_swap_node(pos,"technic:deployer_on")
nodeupdate(pos)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
local i=0
for _,stack in ipairs(inv:get_list("main")) do
i=i+1
if stack:get_name() ~=nil and minetest.registered_nodes[stack:get_name()]~=nil then
node1={name=stack:get_name(), param1=0, param2=node.param2}
minetest.env:place_node(pos1,node1)
stack:take_item(1);
inv:set_stack("main", i, stack)
return
end
end
end
end
end
deployer_signal_off = function(pos, node)
if node.name == "technic:deployer_on" then
hacky_swap_node(pos,"technic:deployer_off")
nodeupdate(pos)
end
end
minetest.register_node("technic:deployer_off", {
description = "Deployer",
tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
"technic_deployer_back.png","technic_deployer_front_off.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
mesecons = {effector={action_on=deployer_signal_on}},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("main",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("main",stack)
end,
input_inventory="main"},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Deployer]"..
"list[current_name;main;4,1;3,3;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Deployer")
local inv = meta:get_inventory()
inv:set_size("main", 3*3)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
if not inv:is_empty("main") then
return false
end
return true
end,
})
minetest.register_node("technic:deployer_on", {
description = "Deployer",
tile_images = {"technic_deployer_top.png","technic_deployer_bottom.png","technic_deployer_side2.png","technic_deployer_side1.png",
"technic_deployer_back.png","technic_deployer_front_on.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1,not_in_creative_inventory=1},
mesecons = {effector={action_off=deployer_signal_off}},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("main",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("main",stack)
end,
input_inventory="main"},
sounds = default.node_sound_stone_defaults(),
})

View File

@ -0,0 +1,439 @@
frames={}
function get_face(pos,ppos,pvect)
ppos={x=ppos.x-pos.x,y=ppos.y-pos.y+1.5,z=ppos.z-pos.z}
if pvect.x>0 then
local t=(-0.5-ppos.x)/pvect.x
local y_int=ppos.y+t*pvect.y
local z_int=ppos.z+t*pvect.z
if y_int>-0.4 and y_int<0.4 and z_int>-0.4 and z_int<0.4 then return 1 end
elseif pvect.x<0 then
local t=(0.5-ppos.x)/pvect.x
local y_int=ppos.y+t*pvect.y
local z_int=ppos.z+t*pvect.z
if y_int>-0.4 and y_int<0.4 and z_int>-0.4 and z_int<0.4 then return 2 end
end
if pvect.y>0 then
local t=(-0.5-ppos.y)/pvect.y
local x_int=ppos.x+t*pvect.x
local z_int=ppos.z+t*pvect.z
if x_int>-0.4 and x_int<0.4 and z_int>-0.4 and z_int<0.4 then return 3 end
elseif pvect.y<0 then
local t=(0.5-ppos.y)/pvect.y
local x_int=ppos.x+t*pvect.x
local z_int=ppos.z+t*pvect.z
if x_int>-0.4 and x_int<0.4 and z_int>-0.4 and z_int<0.4 then return 4 end
end
if pvect.z>0 then
local t=(-0.5-ppos.z)/pvect.z
local x_int=ppos.x+t*pvect.x
local y_int=ppos.y+t*pvect.y
if x_int>-0.4 and x_int<0.4 and y_int>-0.4 and y_int<0.4 then return 5 end
elseif pvect.z<0 then
local t=(0.5-ppos.z)/pvect.z
local x_int=ppos.x+t*pvect.x
local y_int=ppos.y+t*pvect.y
if x_int>-0.4 and x_int<0.4 and y_int>-0.4 and y_int<0.4 then return 6 end
end
end
for xm=0,1 do
for xp=0,1 do
for ym=0,1 do
for yp=0,1 do
for zm=0,1 do
for zp=0,1 do
local a=8/16
local b=7/16
local nodeboxes= {
{ -a, -a, -a, -b, a, -b },
{ -a, -a, b, -b, a, a },
{ b, -a, b, a, a, a },
{ b, -a, -a, a, a, -b },
{ -b, b, -a, b, a, -b },
{ -b, -a, -a, b, -b, -b },
{ -b, b, b, b, a, a },
{ -b, -a, b, b, -b, a },
{ b, b, -b, a, a, b },
{ b, -a, -b, a, -b, b },
{ -a, b, -b, -b, a, b },
{ -a, -a, -b, -b, -b, b },
}
if yp==0 then
table.insert(nodeboxes, {-b,b,-b, b,a,b})
end
if ym==0 then
table.insert(nodeboxes, {-b,-a,-b, b,-b,b})
end
if xp==0 then
table.insert(nodeboxes, {b,b,b,a,-b,-b})
end
if xm==0 then
table.insert(nodeboxes, {-a,-b,-b,-b,b,b})
end
if zp==0 then
table.insert(nodeboxes, {-b,-b,b, b,b,a})
end
if zm==0 then
table.insert(nodeboxes, {-b,-b,-a, b,b,-b})
end
local nameext=tostring(xm)..tostring(xp)..tostring(ym)..tostring(yp)..tostring(zm)..tostring(zp)
local groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
if nameext~="111111" then groups.not_in_creative_inventory=1 end
minetest.register_node("technic:frame_"..nameext,{
description = "Frame",
tiles = {"technic_frame.png"},
groups=groups,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed=nodeboxes,
},
selection_box = {
type="fixed",
fixed={-0.5,-0.5,-0.5,0.5,0.5,0.5}
},
paramtype = "light",
frame=1,
drop="technic:frame_111111",
frame_connect_all=function(pos)
local nodename=minetest.env:get_node(pos).name
l2={}
l1={{x=-1,y=0,z=0},{x=1,y=0,z=0},{x=0,y=-1,z=0},{x=0,y=1,z=0},{x=0,y=0,z=-1},{x=0,y=0,z=1}}
for i,dir in ipairs(l1) do
if string.sub(nodename,-7+i,-7+i)=="1" then
l2[#(l2)+1]=dir
end
end
return l2
end,
on_punch=function(pos,node,puncher)
local ppos=puncher:getpos()
local pvect=puncher:get_look_dir()
local pface=get_face(pos,ppos,pvect)
if pface==nil then return end
local nodename=node.name
local newstate=tostring(1-tonumber(string.sub(nodename,-7+pface,-7+pface)))
if pface<=5 then
nodename=string.sub(nodename,1,-7+pface-1)..newstate..string.sub(nodename,-7+pface+1)
else
nodename=string.sub(nodename,1,-2)..newstate
end
node.name=nodename
minetest.env:set_node(pos,node)
end
})
end
end
end
end
end
end
function frame_motor1_on(pos,node)
local npos={x=pos.x,y=pos.y+1,z=pos.z}
local nnode=minetest.env:get_node(npos)
if node.param2==0 then
dir={x=1,y=0,z=0}
elseif node.param2==1 then
dir={x=0,y=0,z=-1}
elseif node.param2==2 then
dir={x=-1,y=0,z=0}
else
dir={x=0,y=0,z=1}
end
if minetest.registered_nodes[nnode.name].frame==1 then
local connected_nodes=get_connected_nodes(npos)
move_nodes_vect(connected_nodes,dir)
end
end
function frame_motor2_on(pos,node)
local npos={x=pos.x,y=pos.y-1,z=pos.z}
local nnode=minetest.env:get_node(npos)
if node.param2==0 then
dir={x=1,y=0,z=0}
elseif node.param2==1 then
dir={x=0,y=0,z=-1}
elseif node.param2==2 then
dir={x=-1,y=0,z=0}
else
dir={x=0,y=0,z=1}
end
if minetest.registered_nodes[nnode.name].frame==1 then
local connected_nodes=get_connected_nodes(npos)
move_nodes_vect(connected_nodes,dir)
end
end
function frame_motor3_on(pos,node)
local npos={x=pos.x,y=pos.y,z=pos.z}
if node.param2==0 then
dir={x=1,y=0,z=0}
npos.z=npos.z-1
elseif node.param2==1 then
dir={x=0,y=0,z=-1}
npos.x=npos.x-1
elseif node.param2==2 then
dir={x=-1,y=0,z=0}
npos.z=npos.z+1
else
dir={x=0,y=0,z=1}
npos.x=npos.x+1
end
local nnode=minetest.env:get_node(npos)
if minetest.registered_nodes[nnode.name].frame==1 then
local connected_nodes=get_connected_nodes(npos)
move_nodes_vect(connected_nodes,dir)
end
end
function frame_motor4_on(pos,node)
local npos={x=pos.x,y=pos.y,z=pos.z}
if node.param2==0 then
dir={x=-1,y=0,z=0}
npos.z=npos.z-1
elseif node.param2==1 then
dir={x=0,y=0,z=1}
npos.x=npos.x-1
elseif node.param2==2 then
dir={x=1,y=0,z=0}
npos.z=npos.z+1
else
dir={x=0,y=0,z=-1}
npos.x=npos.x+1
end
local nnode=minetest.env:get_node(npos)
if minetest.registered_nodes[nnode.name].frame==1 then
local connected_nodes=get_connected_nodes(npos)
move_nodes_vect(connected_nodes,dir)
end
end
function frame_motor5_on(pos,node)
local npos={x=pos.x,y=pos.y,z=pos.z}
if node.param2==0 then
npos.z=npos.z-1
elseif node.param2==1 then
npos.x=npos.x-1
elseif node.param2==2 then
npos.z=npos.z+1
else
npos.x=npos.x+1
end
dir={x=0,y=1,z=0}
local nnode=minetest.env:get_node(npos)
if minetest.registered_nodes[nnode.name].frame==1 then
local connected_nodes=get_connected_nodes(npos)
move_nodes_vect(connected_nodes,dir)
end
end
function frame_motor6_on(pos,node)
local npos={x=pos.x,y=pos.y,z=pos.z}
if node.param2==0 then
npos.z=npos.z-1
elseif node.param2==1 then
npos.x=npos.x-1
elseif node.param2==2 then
npos.z=npos.z+1
else
npos.x=npos.x+1
end
dir={x=0,y=-1,z=0}
local nnode=minetest.env:get_node(npos)
if minetest.registered_nodes[nnode.name].frame==1 then
local connected_nodes=get_connected_nodes(npos)
move_nodes_vect(connected_nodes,dir)
end
end
minetest.register_node("technic:frame_motor1",{
description = "Frame motor 1",
tiles = {"pipeworks_filter_top.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
paramtype2 = "facedir",
mesecons={effector={action_on=frame_motor1_on}},
frames_can_connect=function(pos,dir)
return dir.y~=-1
end
})
minetest.register_node("technic:frame_motor2",{
description = "Frame motor 2",
tiles = {"technic_lv_cable.png", "pipeworks_filter_top.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
paramtype2 = "facedir",
mesecons={effector={action_on=frame_motor2_on}},
frames_can_connect=function(pos,dir)
return dir.y~=1
end
})
minetest.register_node("technic:frame_motor3",{
description = "Frame motor 3",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
paramtype2 = "facedir",
mesecons={effector={action_on=frame_motor3_on}},
frames_can_connect=function(pos,dir)
local node=minetest.env:get_node(pos)
if node.param2==0 then return dir.z~=1
elseif node.param2==1 then return dir.x~=1
elseif node.param2==2 then return dir.z~=-1
else return dir.x~=-1 end
end
})
minetest.register_node("technic:frame_motor4",{
description = "Frame motor 4",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR180"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
paramtype2 = "facedir",
mesecons={effector={action_on=frame_motor4_on}},
frames_can_connect=function(pos,dir)
local node=minetest.env:get_node(pos)
if node.param2==0 then return dir.z~=1
elseif node.param2==1 then return dir.x~=1
elseif node.param2==2 then return dir.z~=-1
else return dir.x~=-1 end
end
})
minetest.register_node("technic:frame_motor5",{
description = "Frame motor 5",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR90"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
paramtype2 = "facedir",
mesecons={effector={action_on=frame_motor5_on}},
frames_can_connect=function(pos,dir)
local node=minetest.env:get_node(pos)
if node.param2==0 then return dir.z~=1
elseif node.param2==1 then return dir.x~=1
elseif node.param2==2 then return dir.z~=-1
else return dir.x~=-1 end
end
})
minetest.register_node("technic:frame_motor6",{
description = "Frame motor 6",
tiles = {"technic_lv_cable.png", "technic_lv_cable.png", "technic_lv_cable.png",
"technic_lv_cable.png", "technic_lv_cable.png", "pipeworks_filter_top.png^[transformR270"},
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,mesecon=2},
paramtype2 = "facedir",
mesecons={effector={action_on=frame_motor6_on}},
frames_can_connect=function(pos,dir)
local node=minetest.env:get_node(pos)
if node.param2==0 then return dir.z~=1
elseif node.param2==1 then return dir.x~=1
elseif node.param2==2 then return dir.z~=-1
else return dir.x~=-1 end
end
})
function add_table(table,toadd)
local i=1
while true do
o=table[i]
if o==toadd then return end
if o==nil then break end
i=i+1
end
table[i]=toadd
end
function move_nodes_vect(poslist,vect)
for _,pos in ipairs(poslist) do
local npos=frames.addVect(pos,vect)
local name = minetest.env:get_node(npos).name
if (name~="air" and minetest.registered_nodes[name].liquidtype=="none") and not(pos_in_list(poslist,npos)) then
return end
end
nodelist={}
for _,pos in ipairs(poslist) do
local node=minetest.env:get_node(pos)
local meta=minetest.env:get_meta(pos):to_table()
nodelist[#(nodelist)+1]={pos=pos,node=node,meta=meta}
end
objects={}
for _,pos in ipairs(poslist) do
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
add_table(objects,object)
end
end
for _,obj in ipairs(objects) do
obj:setpos(frames.addVect(obj:getpos(),vect))
le=obj:get_luaentity()
if le and le.name == "pipeworks:tubed_item" then
le.start_pos=frames.addVect(le.start_pos,vect)
end
end
for _,n in ipairs(nodelist) do
local npos=frames.addVect(n.pos,vect)
minetest.env:set_node(npos,n.node)
local meta=minetest.env:get_meta(npos)
meta:from_table(n.meta)
for __,pos in ipairs(poslist) do
if npos.x==pos.x and npos.y==pos.y and npos.z==pos.z then
table.remove(poslist, __)
break
end
end
end
for __,pos in ipairs(poslist) do
minetest.env:remove_node(pos)
end
end
function get_connected_nodes(pos)
c={pos}
local nodename=minetest.env:get_node(pos).name
connected(pos,c,minetest.registered_nodes[nodename].frame_connect_all(pos))
return c
end
function frames.addVect(pos,vect)
return {x=pos.x+vect.x,y=pos.y+vect.y,z=pos.z+vect.z}
end
function pos_in_list(l,pos)
for _,p in ipairs(l) do
if p.x==pos.x and p.y==pos.y and p.z==pos.z then return true end
end
return false
end
function connected(pos,c,adj)
for _,vect in ipairs(adj) do
local pos1=frames.addVect(pos,vect)
local nodename=minetest.env:get_node(pos1).name
if not(pos_in_list(c,pos1)) and nodename~="air" and
(minetest.registered_nodes[nodename].frames_can_connect==nil or
minetest.registered_nodes[nodename].frames_can_connect(pos1,vect)) then
c[#(c)+1]=pos1
if minetest.registered_nodes[nodename].frame==1 then
local adj=minetest.registered_nodes[nodename].frame_connect_all(pos1)
connected(pos1,c,adj)
end
end
end
end

View File

@ -0,0 +1,8 @@
local path = technic.modpath.."/machines/other"
-- mesecons and tubes related
dofile(path.."/injector.lua")
dofile(path.."/node_breaker.lua")
dofile(path.."/deployer.lua")
dofile(path.."/constructor.lua")
dofile(path.."/frames.lua")

View File

@ -0,0 +1,117 @@
minetest.register_craftitem("technic:injector", {
description = "Injector",
stack_max = 99,
})
minetest.register_craft({
output = 'technic:injector 1',
recipe = {
{'', 'technic:control_logic_unit',''},
{'', 'default:chest',''},
{'', 'pipeworks:tube_000000',''},
}
})
minetest.register_node("technic:injector", {
description = "Injector",
tiles = {"technic_injector_top.png", "technic_injector_bottom.png", "technic_injector_side.png",
"technic_injector_side.png", "technic_injector_side.png", "technic_injector_side.png"},
groups = chest_groups1,
tube = tubes_properties,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Injector]"..
"button[0,1;.8,.8;mode;]"..
"label[.8,1;Mode: single items]"..
"list[current_name;main;0,2;8,2;]"..
"list[current_player;main;0,5;8,4;]")
meta:set_string("infotext", "Injector")
local inv = meta:get_inventory()
inv:set_size("main", 8*4)
meta:set_string("mode","single items")
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
on_receive_fields = function(pos, formanme, fields, sender)
local meta = minetest.env:get_meta(pos)
local mode=meta:get_string("mode")
if fields.mode then
if mode=="single items" then mode="whole stacks"
else mode="single items"
end
local mode=meta:set_string("mode",mode)
end
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Injector]"..
"button[0,1;.8,.8;mode;]"..
"label[.8,1;Mode: "..mode.."]"..
"list[current_name;main;0,2;8,2;]"..
"list[current_player;main;0,5;8,4;]")
end,
})
minetest.register_abm({
nodenames = {"technic:injector"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local pos1={}
pos1.x = pos.x
pos1.y = pos.y-1
pos1.z = pos.z
local meta=minetest.env:get_meta(pos1)
if meta:get_int("tubelike")==1 then inject_items (pos) end
end,
})
function inject_items (pos)
local meta=minetest.env:get_meta(pos)
local inv = meta:get_inventory()
local mode=meta:get_string("mode")
if mode=="single items" then
local i=0
for _,stack in ipairs(inv:get_list("main")) do
i=i+1
if stack then
local item0=stack:to_table()
if item0 then
item0["count"]="1"
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
item1:setvelocity({x=0, y=-1, z=0})
item1:setacceleration({x=0, y=0, z=0})
stack:take_item(1);
inv:set_stack("main", i, stack)
return
end
end
end
end
if mode=="whole stacks" then
local i=0
for _,stack in ipairs(inv:get_list("main")) do
i=i+1
if stack then
local item0=stack:to_table()
if item0 then
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},item0)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
item1:setvelocity({x=0, y=-1, z=0})
item1:setacceleration({x=0, y=0, z=0})
stack:clear()
inv:set_stack("main", i, stack)
return
end
end
end
end
end

View File

@ -0,0 +1,89 @@
minetest.register_craft({
output = 'technic:nodebreaker_off 1',
recipe = {
{'default:wood', 'default:pick_mese','default:wood'},
{'default:stone', 'mesecons:piston','default:stone'},
{'default:stone', 'mesecons:mesecon','default:stone'},
}
})
node_breaker_on = function(pos, node)
if node.name == "technic:nodebreaker_off" then
hacky_swap_node(pos,"technic:nodebreaker_on")
break_node (pos,node.param2)
nodeupdate(pos)
end
end
node_breaker_off = function(pos, node)
if node.name == "technic:nodebreaker_on" then
hacky_swap_node(pos,"technic:nodebreaker_off")
nodeupdate(pos)
end
end
minetest.register_node("technic:nodebreaker_off", {
description = "Node Breaker",
tile_images = {"technic_nodebreaker_top_off.png","technic_nodebreaker_bottom_off.png","technic_nodebreaker_side2_off.png","technic_nodebreaker_side1_off.png",
"technic_nodebreaker_back.png","technic_nodebreaker_front_off.png"},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1},
mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
end,
})
minetest.register_node("technic:nodebreaker_on", {
description = "Node Breaker",
tile_images = {"technic_nodebreaker_top_on.png","technic_nodebreaker_bottom_on.png","technic_nodebreaker_side2_on.png","technic_nodebreaker_side1_on.png",
"technic_nodebreaker_back.png","technic_nodebreaker_front_on.png"},
mesecons= {effector={action_on=node_breaker_on, action_off=node_breaker_off}},
is_ground_content = true,
paramtype2 = "facedir",
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
})
function break_node (pos,n_param)
local pos1={}
local pos2={}
pos1.x=pos.x
pos1.y=pos.y
pos1.z=pos.z
pos2.x=pos.x
pos2.y=pos.y
pos2.z=pos.z
--param2 3=x+ 1=x- 2=z+ 0=z-
local x_velocity=0
local z_velocity=0
if n_param==3 then pos2.x=pos2.x+1 pos1.x=pos1.x-1 x_velocity=-1 end
if n_param==2 then pos2.z=pos2.z+1 pos1.z=pos1.z-1 z_velocity=-1 end
if n_param==1 then pos2.x=pos2.x-1 pos1.x=pos1.x+1 x_velocity=1 end
if n_param==0 then pos2.z=pos2.z-1 pos1.x=pos1.z+1 z_velocity=1 end
local node=minetest.env:get_node(pos2)
if node.name == "air" then return nil end
if node.name == "default:lava_source" then return nil end
if node.name == "default:lava_flowing" then return nil end
if node.name == "default:water_source" then minetest.env:remove_node(pos2) return nil end
if node.name == "default:water_flowing" then minetest.env:remove_node(pos2) return nil end
if node.name == "ignore" then minetest.env:remove_node(pos2) return nil end
local drops = minetest.get_node_drops(node.name, "default:pick_mese")
local _, dropped_item
for _, dropped_item in ipairs(drops) do
local item1=tube_item({x=pos.x,y=pos.y,z=pos.z},dropped_item)
item1:get_luaentity().start_pos = {x=pos.x,y=pos.y,z=pos.z}
item1:setvelocity({x=x_velocity, y=0, z=z_velocity})
item1:setacceleration({x=0, y=0, z=0})
end
minetest.env:remove_node(pos2)
end

View File

@ -0,0 +1,17 @@
minetest.register_node("technic:tetris_machine_node1", {
tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front1.png",
"tetris_machine_side1B.png", "tetris_machine_side1P.png", "tetris_machine_side1L.png"},
tile_images = {"technic_tetris_machine.png",},
is_ground_content = true,
groups = {cracky=1},
sounds = default.node_sound_stone_defaults(),
})
minetest.register_node("technic:tetris_machine_node2", {
tiles = {"tetris_machine_top.png", "technic_mv_battery_box_bottom.png", "tetris_machine_front2.png",
"tetris_machine_side2B.png", "tetris_machine_side2P.png", "tetris_machine_side2L.png"},
tile_images = {"technic_tetris_machine.png",},
is_ground_content = true,
groups = {cracky=1},
sounds = default.node_sound_stone_defaults(),
})