Update the mesecons mod and dependencies
This touches a lot of the existing Mesecons mods. Also add mesecons_wires.
This commit is contained in:
parent
66829c91c3
commit
b299b95fac
27 changed files with 1542 additions and 554 deletions
1
mods/ITEMS/REDSTONE/mesecons_wires/depends.txt
Normal file
1
mods/ITEMS/REDSTONE/mesecons_wires/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
mesecons
|
264
mods/ITEMS/REDSTONE/mesecons_wires/init.lua
Normal file
264
mods/ITEMS/REDSTONE/mesecons_wires/init.lua
Normal file
|
@ -0,0 +1,264 @@
|
|||
-- naming scheme: wire:(xp)(zp)(xm)(zm)(xpyp)(zpyp)(xmyp)(zmyp)_on/off
|
||||
-- where x= x direction, z= z direction, y= y direction, p = +1, m = -1, e.g. xpym = {x=1, y=-1, z=0}
|
||||
-- The (xp)/(zpyp)/.. statements shall be replaced by either 0 or 1
|
||||
-- Where 0 means the wire has no visual connection to that direction and
|
||||
-- 1 means that the wire visually connects to that other node.
|
||||
|
||||
-- #######################
|
||||
-- ## Update wire looks ##
|
||||
-- #######################
|
||||
|
||||
-- self_pos = pos of any mesecon node, from_pos = pos of conductor to getconnect for
|
||||
local wire_getconnect = function (from_pos, self_pos)
|
||||
local node = minetest.get_node(self_pos)
|
||||
if minetest.registered_nodes[node.name]
|
||||
and minetest.registered_nodes[node.name].mesecons then
|
||||
-- rules of node to possibly connect to
|
||||
local rules = {}
|
||||
if (minetest.registered_nodes[node.name].mesecon_wire) then
|
||||
rules = mesecon.rules.default
|
||||
else
|
||||
rules = mesecon.get_any_rules(node)
|
||||
end
|
||||
|
||||
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
||||
if (vector.equals(vector.add(self_pos, r), from_pos)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Update this node
|
||||
local wire_updateconnect = function (pos)
|
||||
local connections = {}
|
||||
|
||||
for _, r in ipairs(mesecon.rules.default) do
|
||||
if wire_getconnect(pos, vector.add(pos, r)) then
|
||||
table.insert(connections, r)
|
||||
end
|
||||
end
|
||||
|
||||
local nid = {}
|
||||
for _, vec in ipairs(connections) do
|
||||
-- flat component
|
||||
if vec.x == 1 then nid[0] = "1" end
|
||||
if vec.z == 1 then nid[1] = "1" end
|
||||
if vec.x == -1 then nid[2] = "1" end
|
||||
if vec.z == -1 then nid[3] = "1" end
|
||||
|
||||
-- slopy component
|
||||
if vec.y == 1 then
|
||||
if vec.x == 1 then nid[4] = "1" end
|
||||
if vec.z == 1 then nid[5] = "1" end
|
||||
if vec.x == -1 then nid[6] = "1" end
|
||||
if vec.z == -1 then nid[7] = "1" end
|
||||
end
|
||||
end
|
||||
|
||||
local nodeid = (nid[0] or "0")..(nid[1] or "0")..(nid[2] or "0")..(nid[3] or "0")
|
||||
..(nid[4] or "0")..(nid[5] or "0")..(nid[6] or "0")..(nid[7] or "0")
|
||||
|
||||
local state_suffix = string.find(minetest.get_node(pos).name, "_off") and "_off" or "_on"
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid..state_suffix})
|
||||
end
|
||||
|
||||
local update_on_place_dig = function (pos, node)
|
||||
-- Update placed node (get_node again as it may have been dug)
|
||||
local nn = minetest.get_node(pos)
|
||||
if (minetest.registered_nodes[nn.name])
|
||||
and (minetest.registered_nodes[nn.name].mesecon_wire) then
|
||||
wire_updateconnect(pos)
|
||||
end
|
||||
|
||||
-- Update nodes around it
|
||||
local rules = {}
|
||||
if minetest.registered_nodes[node.name]
|
||||
and minetest.registered_nodes[node.name].mesecon_wire then
|
||||
rules = mesecon.rules.default
|
||||
else
|
||||
rules = mesecon.get_any_rules(node)
|
||||
end
|
||||
if (not rules) then return end
|
||||
|
||||
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
||||
local np = vector.add(pos, r)
|
||||
if minetest.registered_nodes[minetest.get_node(np).name]
|
||||
and minetest.registered_nodes[minetest.get_node(np).name].mesecon_wire then
|
||||
wire_updateconnect(np)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
mesecon.register_autoconnect_hook("wire", update_on_place_dig)
|
||||
|
||||
-- ############################
|
||||
-- ## Wire node registration ##
|
||||
-- ############################
|
||||
-- Nodeboxes:
|
||||
local box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/64, 1/16}
|
||||
local box_bump1 = { -2/16, -8/16, -2/16, 2/16, -.5+1/64, 2/16 }
|
||||
|
||||
local nbox_nid =
|
||||
{
|
||||
[0] = {1/16, -.5, -1/16, 8/16, -.5+1/64, 1/16}, -- x positive
|
||||
[1] = {-1/16, -.5, 1/16, 1/16, -.5+1/64, 8/16}, -- z positive
|
||||
[2] = {-8/16, -.5, -1/16, -1/16, -.5+1/64, 1/16}, -- x negative
|
||||
[3] = {-1/16, -.5, -8/16, 1/16, -.5+1/64, -1/16}, -- z negative
|
||||
|
||||
[4] = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/64, 1/16}, -- x positive up
|
||||
[5] = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/64, .5}, -- z positive up
|
||||
[6] = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/64, 1/16}, -- x negative up
|
||||
[7] = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/64, -.5+1/16} -- z negative up
|
||||
}
|
||||
|
||||
local selectionbox =
|
||||
{
|
||||
type = "fixed",
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
|
||||
}
|
||||
|
||||
-- go to the next nodeid (ex.: 01000011 --> 01000100)
|
||||
local nid_inc = function() end
|
||||
nid_inc = function (nid)
|
||||
local i = 0
|
||||
while nid[i-1] ~= 1 do
|
||||
nid[i] = (nid[i] ~= 1) and 1 or 0
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
-- BUT: Skip impossible nodeids:
|
||||
if ((nid[0] == 0 and nid[4] == 1) or (nid[1] == 0 and nid[5] == 1)
|
||||
or (nid[2] == 0 and nid[6] == 1) or (nid[3] == 0 and nid[7] == 1)) then
|
||||
return nid_inc(nid)
|
||||
end
|
||||
|
||||
return i <= 8
|
||||
end
|
||||
|
||||
local function register_wires()
|
||||
local nid = {}
|
||||
while true do
|
||||
-- Create group specifiction and nodeid string (see note above for details)
|
||||
local nodeid = (nid[0] or "0")..(nid[1] or "0")..(nid[2] or "0")..(nid[3] or "0")
|
||||
..(nid[4] or "0")..(nid[5] or "0")..(nid[6] or "0")..(nid[7] or "0")
|
||||
|
||||
-- Calculate nodebox
|
||||
local nodebox = {type = "fixed", fixed={box_center}}
|
||||
for i=0,7 do
|
||||
if nid[i] == 1 then
|
||||
table.insert(nodebox.fixed, nbox_nid[i])
|
||||
end
|
||||
end
|
||||
|
||||
-- Add bump to nodebox if curved
|
||||
if (nid[0] == 1 and nid[1] == 1) or (nid[1] == 1 and nid[2] == 1)
|
||||
or (nid[2] == 1 and nid[3] == 1) or (nid[3] == 1 and nid[0] == 1) then
|
||||
table.insert(nodebox.fixed, box_bump1)
|
||||
end
|
||||
|
||||
-- If nothing to connect to, still make a nodebox of a straight wire
|
||||
if nodeid == "00000000" then
|
||||
nodebox.fixed = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
|
||||
end
|
||||
|
||||
local rules = {}
|
||||
if (nid[0] == 1) then table.insert(rules, vector.new( 1, 0, 0)) end
|
||||
if (nid[1] == 1) then table.insert(rules, vector.new( 0, 0, 1)) end
|
||||
if (nid[2] == 1) then table.insert(rules, vector.new(-1, 0, 0)) end
|
||||
if (nid[3] == 1) then table.insert(rules, vector.new( 0, 0, -1)) end
|
||||
|
||||
if (nid[0] == 1) then table.insert(rules, vector.new( 1, -1, 0)) end
|
||||
if (nid[1] == 1) then table.insert(rules, vector.new( 0, -1, 1)) end
|
||||
if (nid[2] == 1) then table.insert(rules, vector.new(-1, -1, 0)) end
|
||||
if (nid[3] == 1) then table.insert(rules, vector.new( 0, -1, -1)) end
|
||||
|
||||
if (nid[4] == 1) then table.insert(rules, vector.new( 1, 1, 0)) end
|
||||
if (nid[5] == 1) then table.insert(rules, vector.new( 0, 1, 1)) end
|
||||
if (nid[6] == 1) then table.insert(rules, vector.new(-1, 1, 0)) end
|
||||
if (nid[7] == 1) then table.insert(rules, vector.new( 0, 1, -1)) end
|
||||
|
||||
local meseconspec_off = { conductor = {
|
||||
rules = rules,
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesecons:wire_"..nodeid.."_on"
|
||||
}}
|
||||
|
||||
local meseconspec_on = { conductor = {
|
||||
rules = rules,
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesecons:wire_"..nodeid.."_off"
|
||||
}}
|
||||
|
||||
local groups_on = {dig_immediate = 3, mesecon_conductor_craftable = 1,
|
||||
not_in_creative_inventory = 1, attached_node = 1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1}
|
||||
local groups_off = {dig_immediate = 3, mesecon_conductor_craftable = 1,
|
||||
attached_node = 1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1}
|
||||
if nodeid ~= "00000000" then
|
||||
groups_off["not_in_creative_inventory"] = 1
|
||||
end
|
||||
|
||||
-- Wire textures
|
||||
local ratio_off = 128
|
||||
local ratio_on = 192
|
||||
local crossing_off = "(redstone_redstone_dust_dot.png^redstone_redstone_dust_line0.png^(redstone_redstone_dust_line1.png^[transformR90))^[colorize:#FF0000:"..ratio_off
|
||||
local crossing_on = "(redstone_redstone_dust_dot.png^redstone_redstone_dust_line0.png^(redstone_redstone_dust_line1.png^[transformR90))^[colorize:#FF0000:"..ratio_on
|
||||
local straight0_off = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_off
|
||||
local straight0_on = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_on
|
||||
local straight1_off = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_off
|
||||
local straight1_on = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_on
|
||||
local dot_off = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_off
|
||||
local dot_on = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_on
|
||||
|
||||
local tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off }
|
||||
local tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on }
|
||||
|
||||
if nodeid == "00000000" then
|
||||
-- Non-connected redstone wire
|
||||
nodebox.fixed = {-8/16, -.5, -8/16, 8/16, -.5+1/64, 8/16}
|
||||
-- “Dot” texture
|
||||
tiles_off = { dot_off, dot_off, "blank.png", "blank.png", "blank.png", "blank.png" }
|
||||
tiles_on = { dot_on, dot_on, "blank.png", "blank.png", "blank.png", "blank.png" }
|
||||
elseif adjx and adjz and (xp + zp + xm + zm > 2) then
|
||||
-- Connected redstone wire (crossing or t-junction)
|
||||
table.insert(nodebox, box_bump1)
|
||||
tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off, }
|
||||
tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on, }
|
||||
else
|
||||
-- Connected redstone wire (straight line or curve)
|
||||
table.insert(nodebox, box_center)
|
||||
tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off, }
|
||||
tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on, }
|
||||
end
|
||||
|
||||
mesecon.register_node(":mesecons:wire_"..nodeid, {
|
||||
description = "Mesecon",
|
||||
drawtype = "nodebox",
|
||||
inventory_image = "redstone_redstone_dust.png",
|
||||
wield_image = "redstone_redstone_dust.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
selection_box = selectionbox,
|
||||
node_box = nodebox,
|
||||
walkable = false,
|
||||
drop = "mesecons:wire_00000000_off",
|
||||
mesecon_wire = true
|
||||
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},
|
||||
{tiles = tiles_on, mesecons = meseconspec_on, groups = groups_on})
|
||||
|
||||
if (nid_inc(nid) == false) then return end
|
||||
end
|
||||
end
|
||||
register_wires()
|
||||
|
||||
minetest.register_alias("mesecons:redstone", "mesecons:wire_00000000_off")
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mesecons:redstone",
|
||||
recipe = "mcl_core:stone_with_redstone",
|
||||
cooktime = 10,
|
||||
})
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 213 B |
Binary file not shown.
After Width: | Height: | Size: 150 B |
Binary file not shown.
After Width: | Height: | Size: 168 B |
Binary file not shown.
After Width: | Height: | Size: 166 B |
269
mods/ITEMS/REDSTONE/mesecons_wires/wires.lua
Normal file
269
mods/ITEMS/REDSTONE/mesecons_wires/wires.lua
Normal file
|
@ -0,0 +1,269 @@
|
|||
-- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off
|
||||
-- The conditions in brackets define whether there is a mesecon at that place or not
|
||||
-- 1 = there is one; 0 = there is none
|
||||
-- y always means y+
|
||||
|
||||
box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/64, 1/16} -- filler for curves and straight lines
|
||||
box_bump1 = { -3/16, -.5, -3/16, 3/16, -.5+1/64, 3/16 } -- filler for redstone dust “dot”
|
||||
|
||||
box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/64, 1/16}
|
||||
box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/64, 8/16}
|
||||
box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/64, 1/16}
|
||||
box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/64, -1/16}
|
||||
|
||||
box_xpy = {.5-1/16, -.5+1/64, -1/16, .5, .4999+1/64, 1/16}
|
||||
box_zpy = {-1/16, -.5+1/64, .5-1/16, 1/16, .4999+1/64, .5}
|
||||
box_xmy = {-.5, -.5+1/64, -1/16, -.5+1/16, .4999+1/64, 1/16}
|
||||
box_zmy = {-1/16, -.5+1/64, -.5, 1/16, .4999+1/64, -.5+1/16}
|
||||
|
||||
-- Registering the wires
|
||||
|
||||
for xp=0, 1 do
|
||||
for zp=0, 1 do
|
||||
for xm=0, 1 do
|
||||
for zm=0, 1 do
|
||||
for xpy=0, 1 do
|
||||
for zpy=0, 1 do
|
||||
for xmy=0, 1 do
|
||||
for zmy=0, 1 do
|
||||
if (xpy == 1 and xp == 0) or (zpy == 1 and zp == 0)
|
||||
or (xmy == 1 and xm == 0) or (zmy == 1 and zm == 0) then break end
|
||||
|
||||
local groups
|
||||
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
|
||||
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
|
||||
|
||||
local wirehelp
|
||||
local longdesc
|
||||
local usagehelp
|
||||
if nodeid == "00000000" then
|
||||
groups = {dig_immediate = 3, mesecon_conductor_craftable = 1, attached_node = 1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1}
|
||||
wiredesc = "Redstone"
|
||||
wirehelp = nodeid == "00000000"
|
||||
if wirehelp then
|
||||
longdesc = [[Redstone is a versatile conductive mineral which transmits redstone power. It can be placed on trail the ground as a trail.
|
||||
A redstone trail can be in two states: Powered or not powered. A powered redstone trail will power (and thus activate) adjacent redstone components.
|
||||
Redstone power can be received from various redstone components, such as a block of redstone or a button. Redstone power is used to activate numerous mechanisms, such as redstone lamps or pistons.]]
|
||||
usagehelp = [[Place redstone on the ground to build a redstone trail. The trails will connect to each other automatically and it can also go over hills. An easy way to power a redstone trail is by placing a redstone torch.
|
||||
|
||||
Read the help entries on the other redstone components to learn how redstone components interact.]]
|
||||
end
|
||||
else
|
||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1, attached_node = 1, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1}
|
||||
wiredesc = "Redstone Trail (ID: "..nodeid..")"
|
||||
wirehelp = false
|
||||
end
|
||||
|
||||
local nodebox = {}
|
||||
local adjx = false
|
||||
local adjz = false
|
||||
if xp == 1 then table.insert(nodebox, box_xp) adjx = true end
|
||||
if zp == 1 then table.insert(nodebox, box_zp) adjz = true end
|
||||
if xm == 1 then table.insert(nodebox, box_xm) adjx = true end
|
||||
if zm == 1 then table.insert(nodebox, box_zm) adjz = true end
|
||||
if xpy == 1 then table.insert(nodebox, box_xpy) end
|
||||
if zpy == 1 then table.insert(nodebox, box_zpy) end
|
||||
if xmy == 1 then table.insert(nodebox, box_xmy) end
|
||||
if zmy == 1 then table.insert(nodebox, box_zmy) end
|
||||
|
||||
local ratio_off = 128
|
||||
local ratio_on = 192
|
||||
local crossing_off = "(redstone_redstone_dust_dot.png^redstone_redstone_dust_line0.png^(redstone_redstone_dust_line1.png^[transformR90))^[colorize:#FF0000:"..ratio_off
|
||||
local crossing_on = "(redstone_redstone_dust_dot.png^redstone_redstone_dust_line0.png^(redstone_redstone_dust_line1.png^[transformR90))^[colorize:#FF0000:"..ratio_on
|
||||
local straight0_off = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_off
|
||||
local straight0_on = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_on
|
||||
local straight1_off = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_off
|
||||
local straight1_on = "redstone_redstone_dust_line0.png^[colorize:#FF0000:"..ratio_on
|
||||
local dot_off = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_off
|
||||
local dot_on = "redstone_redstone_dust_dot.png^[colorize:#FF0000:"..ratio_on
|
||||
|
||||
if nodeid == "00000000" then
|
||||
-- Non-connected redstone wire
|
||||
nodebox = {-8/16, -.5, -8/16, 8/16, -.5+1/16, 8/16}
|
||||
-- “Dot” texture
|
||||
tiles_off = { dot_off, dot_off, "blank.png", "blank.png", "blank.png", "blank.png" }
|
||||
tiles_on = { dot_on, dot_on, "blank.png", "blank.png", "blank.png", "blank.png" }
|
||||
elseif adjx and adjz and (xp + zp + xm + zm > 2) then
|
||||
-- Connected redstone wire (crossing or t-junction)
|
||||
table.insert(nodebox, box_bump1)
|
||||
tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off, }
|
||||
tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on, }
|
||||
else
|
||||
-- Connected redstone wire (straight line or curve)
|
||||
table.insert(nodebox, box_center)
|
||||
tiles_off = { crossing_off, crossing_off, straight0_off, straight1_off, straight0_off, straight1_off, }
|
||||
tiles_on = { crossing_on, crossing_on, straight0_on, straight1_on, straight0_on, straight1_on, }
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons:wire_"..nodeid.."_off", {
|
||||
description = "Redstone",
|
||||
_doc_items_create_entry = wirehelp,
|
||||
_doc_items_longdesc = longdesc,
|
||||
_doc_items_usagehelp = usagehelp,
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_off,
|
||||
is_ground_content = false,
|
||||
-- inventory_image = "wires_inv.png",
|
||||
-- wield_image = "wires_inv.png",
|
||||
inventory_image = "redstone_redstone_dust.png",
|
||||
wield_image = "redstone_redstone_dust.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
groups = groups,
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
drop = "mesecons:wire_00000000_off",
|
||||
mesecons = {conductor={
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesecons:wire_"..nodeid.."_on"
|
||||
}},
|
||||
sounds = mcl_sounds.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons:wire_"..nodeid.."_on", {
|
||||
description = "Redstone (Powered)",
|
||||
_doc_items_create_entry = false,
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_on,
|
||||
is_ground_content = false,
|
||||
-- inventory_image = "wires_inv.png",
|
||||
-- wield_image = "wires_inv.png",
|
||||
inventory_image = "redstone_redstone_dust.png",
|
||||
wield_image = "redstone_redstone_dust.png",
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-.5, -.5, -.5, .5, -.5+1/16, .5}
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = nodebox
|
||||
},
|
||||
groups = {dig_immediate = 3, mesecon = 2, dig_by_water = 1,destroy_by_lava_flow=1, dig_by_piston = 1, attached_node = 1, not_in_creative_inventory = 1},
|
||||
walkable = false,
|
||||
stack_max = 64,
|
||||
drop = "mesecons:wire_00000000_off",
|
||||
mesecons = {conductor={
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesecons:wire_"..nodeid.."_off"
|
||||
}},
|
||||
sounds = mcl_sounds.node_sound_defaults(),
|
||||
})
|
||||
|
||||
-- Add Help entry aliases for e.g. making it identifiable by the lookup tool [doc_identifier]
|
||||
if minetest.get_modpath("doc") then
|
||||
if nodeid ~= "00000000" then
|
||||
doc.add_entry_alias("nodes", "mesecons:wire_00000000_off", "nodes", "mesecons:wire_"..nodeid.."_off")
|
||||
end
|
||||
doc.add_entry_alias("nodes", "mesecons:wire_00000000_off", "nodes", "mesecons:wire_"..nodeid.."_on")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Updating the wires:
|
||||
-- Place the right connection wire
|
||||
|
||||
local update_on_place_dig = function (pos, node)
|
||||
if minetest.registered_nodes[node.name]
|
||||
and minetest.registered_nodes[node.name].mesecons then
|
||||
mesecon:update_autoconnect(pos)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(update_on_place_dig)
|
||||
minetest.register_on_dignode(update_on_place_dig)
|
||||
|
||||
function mesecon:update_autoconnect(pos, secondcall, replace_old)
|
||||
local xppos = {x=pos.x+1, y=pos.y, z=pos.z}
|
||||
local zppos = {x=pos.x, y=pos.y, z=pos.z+1}
|
||||
local xmpos = {x=pos.x-1, y=pos.y, z=pos.z}
|
||||
local zmpos = {x=pos.x, y=pos.y, z=pos.z-1}
|
||||
|
||||
local xpympos = {x=pos.x+1, y=pos.y-1, z=pos.z}
|
||||
local zpympos = {x=pos.x, y=pos.y-1, z=pos.z+1}
|
||||
local xmympos = {x=pos.x-1, y=pos.y-1, z=pos.z}
|
||||
local zmympos = {x=pos.x, y=pos.y-1, z=pos.z-1}
|
||||
|
||||
local xpypos = {x=pos.x+1, y=pos.y+1, z=pos.z}
|
||||
local zpypos = {x=pos.x, y=pos.y+1, z=pos.z+1}
|
||||
local xmypos = {x=pos.x-1, y=pos.y+1, z=pos.z}
|
||||
local zmypos = {x=pos.x, y=pos.y+1, z=pos.z-1}
|
||||
|
||||
if secondcall == nil then
|
||||
mesecon:update_autoconnect(xppos, true)
|
||||
mesecon:update_autoconnect(zppos, true)
|
||||
mesecon:update_autoconnect(xmpos, true)
|
||||
mesecon:update_autoconnect(zmpos, true)
|
||||
|
||||
mesecon:update_autoconnect(xpypos, true)
|
||||
mesecon:update_autoconnect(zpypos, true)
|
||||
mesecon:update_autoconnect(xmypos, true)
|
||||
mesecon:update_autoconnect(zmypos, true)
|
||||
|
||||
mesecon:update_autoconnect(xpympos, true)
|
||||
mesecon:update_autoconnect(zpympos, true)
|
||||
mesecon:update_autoconnect(xmympos, true)
|
||||
mesecon:update_autoconnect(zmympos, true)
|
||||
end
|
||||
|
||||
local nodename = minetest.get_node(pos).name
|
||||
if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end
|
||||
|
||||
if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end
|
||||
if mesecon:rules_link_anydir(pos, xmpos) then xm = 1 else xm = 0 end
|
||||
if mesecon:rules_link_anydir(pos, zppos) then zp = 1 else zp = 0 end
|
||||
if mesecon:rules_link_anydir(pos, zmpos) then zm = 1 else zm = 0 end
|
||||
|
||||
if mesecon:rules_link_anydir(pos, xpympos) then xp = 1 end
|
||||
if mesecon:rules_link_anydir(pos, xmympos) then xm = 1 end
|
||||
if mesecon:rules_link_anydir(pos, zpympos) then zp = 1 end
|
||||
if mesecon:rules_link_anydir(pos, zmympos) then zm = 1 end
|
||||
|
||||
if mesecon:rules_link_anydir(pos, xpypos) then xpy = 1 else xpy = 0 end
|
||||
if mesecon:rules_link_anydir(pos, zpypos) then zpy = 1 else zpy = 0 end
|
||||
if mesecon:rules_link_anydir(pos, xmypos) then xmy = 1 else xmy = 0 end
|
||||
if mesecon:rules_link_anydir(pos, zmypos) then zmy = 1 else zmy = 0 end
|
||||
|
||||
if xpy == 1 then xp = 1 end
|
||||
if zpy == 1 then zp = 1 end
|
||||
if xmy == 1 then xm = 1 end
|
||||
if zmy == 1 then zm = 1 end
|
||||
|
||||
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
|
||||
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
|
||||
|
||||
|
||||
if string.find(nodename, "_off") ~= nil then
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
|
||||
else
|
||||
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_alias("mesecons:redstone", "mesecons:wire_00000000_off")
|
||||
|
||||
minetest.register_craft({
|
||||
type = "cooking",
|
||||
output = "mesecons:redstone",
|
||||
recipe = "mcl_core:stone_with_redstone",
|
||||
cooktime = 10,
|
||||
})
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue