summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDS-Minetest <vorunbekannt75@web.de>2017-04-03 19:49:22 +0200
committerDiego Martínez <kaeza@users.noreply.github.com>2017-04-04 21:59:13 -0300
commit4dda59da0ce714712749c56f71e36c2de75ee2d2 (patch)
tree679fb0b4eeb0c5121846007793c753f4b73ce0c4
parent338f3b6a997bb3ebea9d62d986b7c3327f06072e (diff)
Add conductive plates.
These work exactly like cables, but are meant to be used as floor for when the machine does not fill the while cube.
-rw-r--r--technic/machines/register/cables.lua80
1 files changed, 78 insertions, 2 deletions
diff --git a/technic/machines/register/cables.lua b/technic/machines/register/cables.lua
index 165db98..b0e2e06 100644
--- a/technic/machines/register/cables.lua
+++ b/technic/machines/register/cables.lua
@@ -121,7 +121,8 @@ function technic.register_cable(tier, size)
local ltier = string.lower(tier)
cable_tier["technic:"..ltier.."_cable"] = tier
- local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}
+ local groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2,
+ ["technic_"..ltier.."_cable"] = 1}
local node_box = {
type = "connected",
@@ -146,11 +147,86 @@ function technic.register_cable(tier, size)
sunlight_propagates = true,
drawtype = "nodebox",
node_box = node_box,
- connects_to = {"technic:"..ltier.."_cable",
+ connects_to = {"group:technic_"..ltier.."_cable",
"group:technic_"..ltier, "group:technic_all_tiers"},
on_construct = clear_networks,
on_destruct = clear_networks,
})
+
+ local xyz = {
+ ["-x"] = 1,
+ ["-y"] = 2,
+ ["-z"] = 3,
+ ["x"] = 4,
+ ["y"] = 5,
+ ["z"] = 6,
+ }
+ local notconnects = {
+ [1] = "left",
+ [2] = "bottom",
+ [3] = "front",
+ [4] = "right",
+ [5] = "top",
+ [6] = "back",
+ }
+ local function s(p)
+ if p:find("-") then
+ return p:sub(2)
+ else
+ return "-"..p
+ end
+ end
+ for p, i in pairs(xyz) do
+ local def = {
+ description = S("%s Cable Plate"):format(tier),
+ tiles = {"technic_"..ltier.."_cable.png"},
+ groups = table.copy(groups),
+ sounds = default.node_sound_wood_defaults(),
+ drop = "technic:"..ltier.."_cable",
+ paramtype = "light",
+ sunlight_propagates = true,
+ drawtype = "nodebox",
+ node_box = table.copy(node_box),
+ connects_to = {"group:technic_"..ltier.."_cable",
+ "group:technic_"..ltier, "group:technic_all_tiers"},
+ on_construct = clear_networks,
+ on_destruct = clear_networks,
+ }
+ def.node_box.fixed = {
+ {-size, -size, -size, size, size, size},
+ {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}
+ }
+ def.node_box.fixed[1][xyz[p]] = 7/16 * (i-3.5)/math.abs(i-3.5)
+ def.node_box.fixed[2][xyz[s(p)]] = 3/8 * (i-3.5)/math.abs(i-3.5)
+ def.node_box["connect_"..notconnects[i]] = nil
+ if i == 1 then
+ def.on_place = function(itemstack, placer, pointed_thing)
+ local pointed_thing_diff = vector.subtract(pointed_thing.above, pointed_thing.under)
+ local num
+ for k, v in pairs(pointed_thing_diff) do
+ if v ~= 0 then
+ num = xyz[s(tostring(v):sub(-2, -2)..k)]
+ break
+ end
+ end
+ minetest.set_node(pointed_thing.above, {name = "technic:"..ltier.."_cable_plate_"..num})
+ end
+ else
+ def.groups.not_in_creative_inventory = 1
+ end
+ minetest.register_node("technic:"..ltier.."_cable_plate_"..i, def)
+ cable_tier["technic:"..ltier.."_cable_plate_"..i] = tier
+ end
+
+ local c = "technic:"..ltier.."_cable"
+ minetest.register_craft({
+ output = "technic:"..ltier.."_cable_plate_1 5",
+ recipe = {
+ {"", "", c},
+ {c , c , c},
+ {"", "", c},
+ }
+ })
end