diff --git a/bt factory/init.lua b/bt factory/init.lua new file mode 100644 index 0000000..d9ce058 --- /dev/null +++ b/bt factory/init.lua @@ -0,0 +1 @@ +dofile(minetest.get_modpath("buildtest").."/bt factory/quarry.lua") diff --git a/bt factory/quarry.lua b/bt factory/quarry.lua new file mode 100644 index 0000000..c5b4101 --- /dev/null +++ b/bt factory/quarry.lua @@ -0,0 +1,76 @@ +minetest.register_node("buildtest:quarry", { + tiles = { + "buildtest_quarry_top.png", + "buildtest_quarry.png", + "buildtest_quarry.png", + "buildtest_quarry.png", + "buildtest_quarry.png", + "buildtest_quarry_front.png", + }, + description = "Buildtest Quarry", + groups = {cracky=1}, + paramtype2 = "facedir", + buildtest = { + pipe_groups = { + type = "transp", + }, + power = { + }, + }, + on_construct = function(pos) + local nextTo = buildtest.landmarks.getNextTo(pos) + local bounds = buildtest.landmarks.getBounds(nextTo) + buildtest.landmarks.removeMarks(nextTo) + local meta = minetest.get_meta(pos) + meta:set_string("pmin", minetest.pos_to_string(bounds.pmin)) + meta:set_string("pmax", minetest.pos_to_string(bounds.pmax)) + meta:set_int("size", (bounds.pmax.x-bounds.pmin.x)*(bounds.pmax.z-bounds.pmin.z)) + meta:set_int("power", 0) + end, + on_place = function(itemstack, placer, pointed_thing) + local itemstk=minetest.item_place(itemstack, placer, pointed_thing) + for i=1,6 do + buildtest.pipes.processNode(vector.add(pointed_thing.above,buildtest.toXY(i))) + end + return itemstk + end +}) + +buildtest.pumps.pumpible["buildtest:quarry"] = { + power = function(pos, speed) + local meta = minetest.get_meta(pos) + local power = meta:get_int("power") + power = power + speed + local size = meta:get_int("size") + if power < size then + meta:set_int("power", power) + end + power = power - size + meta:set_int("power", power) + + local pmin = minetest.string_to_pos(meta:get_string("pmin")) + local pmax = minetest.string_to_pos(meta:get_string("pmax")) + print(meta:get_string("pmin")) + + local topos = buildtest.pumps.findpipe(pos) + local l = pmin.y-1 + while minetest.get_node({x=pmin.x, y=l, z=pmin.z}).name=="air" do + l=l-1 + end + pmin.y = l + + for x=pmin.x,pmax.x do + for z=pmin.z,pmax.z do + local bpos = {x=x, y=pmin.y, z=z} + local n = minetest.get_node(bpos) + if n.name~="ignore" then + minetest.remove_node(bpos) + local itemstacks = minetest.get_node_drops(n.name) + for _, itemname in ipairs(itemstacks) do + buildtest.makeEnt(topos, {name=itemname}, 1, bpos) + end + end + end + end + end, +} \ No newline at end of file diff --git a/crafts.lua b/crafts.lua index ec7e197..c815975 100644 --- a/crafts.lua +++ b/crafts.lua @@ -53,8 +53,18 @@ for name, val in pairs(buildtest.pumps.crafts) do output = "buildtest:engine_"..name.."_blue", recipe = { { val.mat, val.mat, val.mat }, - { "", "default:glass", "" }, + { "", "default:glass", "" }, { val.gear, piston, val.gear }, } }) -end \ No newline at end of file +end + + +minetest.register_craft({ + output = "buildtest:quarry", + recipe = { + { "buildtest:gear_steel", "mesecons:wire_00000000_off", "buildtest:gear_steel" }, + { "buildtest:gear_gold", "buildtest:gear_steel", "buildtest:gear_gold" }, + { "buildtest:gear_diamond", "default:pick_diamond", "buildtest:gear_diamond" }, + } +}) \ No newline at end of file diff --git a/init.lua b/init.lua index cf52822..f17df95 100644 --- a/init.lua +++ b/init.lua @@ -45,6 +45,7 @@ dofile(minetest.get_modpath("buildtest").."/pumps/pump_init.lua") dofile(minetest.get_modpath("buildtest").."/support/entity.lua") dofile(minetest.get_modpath("buildtest").."/support/liquid.lua") dofile(minetest.get_modpath("buildtest").."/misc/init.lua") +dofile(minetest.get_modpath("buildtest").."/bt factory/init.lua") dofile(minetest.get_modpath("buildtest").."/crafts.lua") diff --git a/misc/landmarks.lua b/misc/landmarks.lua index 9272fe9..17eb23f 100644 --- a/misc/landmarks.lua +++ b/misc/landmarks.lua @@ -5,6 +5,81 @@ buildtest.landmarks = { addBeam = function() removeBeam() end, + + getNextTo = function(pos) + local dirs = { + {x= 1,y= 0,z= 0}, + {x=-1,y= 0,z= 0}, + {x= 0,y= 0,z= 1}, + {x= 0,y= 0,z=-1}, + } + + for i=1, #dirs do + local ppos = vector.add(pos, dirs[i]) + if minetest.get_node(ppos).name=="buildtest:landmark" then + return ppos + end + end + + return pos + end, + + getMarkPositions = function(pos) + local dirs = { + {x= 1,y= 0,z= 0}, + {x=-1,y= 0,z= 0}, + {x= 0,y= 0,z= 1}, + {x= 0,y= 0,z=-1}, + } + + local marks = {} + + for i=1, #dirs do + local ppos = pos + for ii=1, 20 do + ppos = vector.add(ppos, dirs[i]) + if minetest.get_node(ppos).name=="buildtest:landmark" then + marks[#marks+1] = ppos + break + end + end + end + + return marks + end, + + removeMarks = function(pos) + local marks = buildtest.landmarks.getMarkPositions(pos) + + for i=1, #marks do + local ppos = marks[i] + minetest.remove_node(ppos) + minetest.add_item(ppos, "buildtest:landmark") + end + + if minetest.get_node(pos).name=="buildtest:landmark" then + minetest.remove_node(pos) + minetest.add_item(pos, "buildtest:landmark") + end + end, + + getBounds = function(pos) + local marks = buildtest.landmarks.getMarkPositions(pos) + + local pmin = {x=pos.x, y=pos.y, z=pos.z} + local pmax = {x=pos.x, y=pos.y, z=pos.z} + + for i=1, #marks do + local ppos = marks[i] + pmin.x = math.min(pmin.x, ppos.x) + pmax.x = math.max(pmax.x, ppos.x) + + pmin.z = math.min(pmin.z, ppos.z) + pmax.z = math.max(pmax.z, ppos.z) + end + + return {pmin=pmin, pmax=pmax} + end, } minetest.register_node("buildtest:landmark", { diff --git a/pipes/pipes_defs.lua b/pipes/pipes_defs.lua index ded3a1f..17f88df 100644 --- a/pipes/pipes_defs.lua +++ b/pipes/pipes_defs.lua @@ -254,6 +254,7 @@ end buildtest.pipes.defaultVPipes = { "buildtest:pump", + "buildtest:quarry", } buildtest.pipes.defaultPipes = { diff --git a/textures/buildtest_gear_diamond.png b/textures/buildtest_gear_diamond.png new file mode 100644 index 0000000..3386c5c Binary files /dev/null and b/textures/buildtest_gear_diamond.png differ diff --git a/textures/buildtest_gear_gold.png b/textures/buildtest_gear_gold.png new file mode 100644 index 0000000..e5741b2 Binary files /dev/null and b/textures/buildtest_gear_gold.png differ diff --git a/textures/buildtest_gear_steel.png b/textures/buildtest_gear_steel.png new file mode 100644 index 0000000..1a27234 Binary files /dev/null and b/textures/buildtest_gear_steel.png differ diff --git a/textures/buildtest_gear_stone.png b/textures/buildtest_gear_stone.png new file mode 100644 index 0000000..1610046 Binary files /dev/null and b/textures/buildtest_gear_stone.png differ diff --git a/textures/buildtest_gear_wood.png b/textures/buildtest_gear_wood.png new file mode 100644 index 0000000..ff8732a Binary files /dev/null and b/textures/buildtest_gear_wood.png differ diff --git a/textures/buildtest_landmark.png b/textures/buildtest_landmark.png new file mode 100644 index 0000000..12b0089 Binary files /dev/null and b/textures/buildtest_landmark.png differ diff --git a/textures/buildtest_quarry.png b/textures/buildtest_quarry.png new file mode 100644 index 0000000..0f6d14d Binary files /dev/null and b/textures/buildtest_quarry.png differ diff --git a/textures/buildtest_quarry_front.png b/textures/buildtest_quarry_front.png new file mode 100644 index 0000000..6e50816 Binary files /dev/null and b/textures/buildtest_quarry_front.png differ diff --git a/textures/buildtest_quarry_top.png b/textures/buildtest_quarry_top.png new file mode 100644 index 0000000..e8c5adb Binary files /dev/null and b/textures/buildtest_quarry_top.png differ diff --git a/textures/xcfs/buildtest_gear_diamond.xcf b/textures/xcfs/buildtest_gear_diamond.xcf new file mode 100644 index 0000000..e9f13a2 Binary files /dev/null and b/textures/xcfs/buildtest_gear_diamond.xcf differ diff --git a/textures/xcfs/buildtest_gear_gold.xcf b/textures/xcfs/buildtest_gear_gold.xcf new file mode 100644 index 0000000..b0f1f22 Binary files /dev/null and b/textures/xcfs/buildtest_gear_gold.xcf differ diff --git a/textures/xcfs/buildtest_gear_steel.xcf b/textures/xcfs/buildtest_gear_steel.xcf new file mode 100644 index 0000000..c720ddc Binary files /dev/null and b/textures/xcfs/buildtest_gear_steel.xcf differ diff --git a/textures/xcfs/buildtest_gear_stone.xcf b/textures/xcfs/buildtest_gear_stone.xcf new file mode 100644 index 0000000..19d5ef8 Binary files /dev/null and b/textures/xcfs/buildtest_gear_stone.xcf differ diff --git a/textures/xcfs/buildtest_gear_wood.xcf b/textures/xcfs/buildtest_gear_wood.xcf new file mode 100644 index 0000000..560d9de Binary files /dev/null and b/textures/xcfs/buildtest_gear_wood.xcf differ diff --git a/textures/xcfs/buildtest_landmark.xcf b/textures/xcfs/buildtest_landmark.xcf new file mode 100644 index 0000000..8e274f2 Binary files /dev/null and b/textures/xcfs/buildtest_landmark.xcf differ diff --git a/textures/xcfs/buildtest_quarry.xcf b/textures/xcfs/buildtest_quarry.xcf new file mode 100644 index 0000000..05bd10c Binary files /dev/null and b/textures/xcfs/buildtest_quarry.xcf differ diff --git a/textures/xcfs/buildtest_quarry_front.xcf b/textures/xcfs/buildtest_quarry_front.xcf new file mode 100644 index 0000000..d1be96a Binary files /dev/null and b/textures/xcfs/buildtest_quarry_front.xcf differ diff --git a/textures/xcfs/buildtest_quarry_top.xcf b/textures/xcfs/buildtest_quarry_top.xcf new file mode 100644 index 0000000..6122978 Binary files /dev/null and b/textures/xcfs/buildtest_quarry_top.xcf differ