|
@ -7,6 +7,8 @@ git clone https://github.com/minetest-technic/unified_inventory.git
|
|||
git clone https://github.com/bdjnk/mini_sun.git
|
||||
git clone https://github.com/Ezhh/under_sky.git
|
||||
git clone https://github.com/tenplus1/ethereal.git
|
||||
git clone https://github.com/orwell96/advtrains.git
|
||||
git clone https://github.com/Jeija/minetest-mod-mesecons.git
|
||||
|
||||
mkdir octacian
|
||||
cd octacian
|
||||
|
@ -21,7 +23,7 @@ git clone https://gitlab.com/yawin/Mod_Magic.git
|
|||
git clone https://github.com/yawin123/utilities.git
|
||||
|
||||
cd ../../mods/
|
||||
rm -f beds boats bucket carts creative datalib default digicompute doors dye ethereal farming fire flowers give_initial_stuff killme microexpansion mini_sun Mod_Magic Minetest-WorldEdit screwdriver sethome sfinv stairs tnt under_sky unified_inventory utilities vessels walls wool xpanes
|
||||
rm -f advtrains beds boats bucket carts creative datalib default digicompute doors dye ethereal farming fire flowers give_initial_stuff killme microexpansion mini_sun Mod_Magic minetest-mod-mesecons Minetest-WorldEdit screwdriver sethome sfinv stairs tnt under_sky unified_inventory utilities vessels walls wool xpanes
|
||||
|
||||
ln -s ../referenced-mods/minetest_game/mods/beds/
|
||||
ln -s ../referenced-mods/minetest_game/mods/boats/
|
||||
|
@ -48,7 +50,9 @@ ln -s ../referenced-mods/minetest_game/mods/xpanes/
|
|||
|
||||
ln -s ../referenced-mods/mini_sun/
|
||||
|
||||
ln -s ../referenced-mods/advtrains/
|
||||
ln -s ../referenced-mods/ethereal/
|
||||
ln -s ../referenced-mods/minetest-mod-mesecons/
|
||||
ln -s ../referenced-mods/under_sky/
|
||||
ln -s ../referenced-mods/unified_inventory/
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
../../../mods/Minetest-WorldEdit/
|
||||
/home/yawin/.minetest/mods/Minetest-WorldEdit
|
|
@ -0,0 +1 @@
|
|||
../referenced-mods/advtrains/
|
|
@ -0,0 +1 @@
|
|||
../referenced-mods/ethereal/
|
|
@ -210,7 +210,6 @@ minetest.register_abm({
|
|||
inv:add_item("main", item)
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -226,7 +225,6 @@ minetest.register_abm({
|
|||
local inv2 = meta2:get_inventory()
|
||||
local invsize2 = inv2:get_size("dst")
|
||||
if inv2:is_empty("dst") == false then
|
||||
|
||||
for i = 1,invsize2 do
|
||||
local stack = inv2:get_stack("dst", i)
|
||||
local item = stack:get_name()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
../referenced-mods/minetest-mod-mesecons/
|
|
@ -1,24 +0,0 @@
|
|||
-- |\ /| ____ ____ ____ _____ ____ _____
|
||||
-- | \ / | | | | | | | |\ | |
|
||||
-- | \/ | |___ ____ |___ | | | | \ | |____
|
||||
-- | | | | | | | | | \ | |
|
||||
-- | | |___ ____| |___ |____ |____| | \| ____|
|
||||
-- by Jeija and contributors
|
||||
|
||||
Credits:
|
||||
Jeija: main developer
|
||||
VanessaE: Awesome textures & design, coding
|
||||
sfan5: coding, textures
|
||||
temperest: coding, textures
|
||||
Jordach: Sounds for the noteblock
|
||||
minerd247: Some textures
|
||||
...other contributors
|
||||
|
||||
This is a mod for minetest-c55.
|
||||
Copy the minetest-mod-mesecons directory into you game's mod folder
|
||||
(e.g. games/minetest_game/mods/minetest-mod-mesecons)
|
||||
|
||||
You can remove modules of this mod by deleting the mesecons_*
|
||||
folders in the minetest-mod-mesecons directory.
|
||||
|
||||
Mod dependencies: none
|
|
@ -1 +0,0 @@
|
|||
0.41 DEV
|
|
@ -1 +0,0 @@
|
|||
default
|
|
@ -1,114 +0,0 @@
|
|||
-- |\ /| ____ ____ ____ _____ ____ _____
|
||||
-- | \ / | | | | | | | |\ | |
|
||||
-- | \/ | |___ ____ |___ | | | | \ | |____
|
||||
-- | | | | | | | | | \ | |
|
||||
-- | | |___ ____| |___ |____ |____| | \| ____|
|
||||
-- by Jeija, Uberi (Temperest), sfan5, VanessaE
|
||||
--
|
||||
--
|
||||
--
|
||||
-- This mod adds mesecons[=minecraft redstone] and different receptors/effectors to minetest.
|
||||
-- See the documentation on the forum for additional information, especially about crafting
|
||||
--
|
||||
--
|
||||
-- For developer documentation see the Developers' section on mesecons.TK
|
||||
--
|
||||
--
|
||||
--
|
||||
--Quick draft for the mesecons array in the node's definition
|
||||
--mesecons =
|
||||
--{
|
||||
-- receptor =
|
||||
-- {
|
||||
-- state = mesecon.state.on/off
|
||||
-- rules = rules/get_rules
|
||||
-- },
|
||||
-- effector =
|
||||
-- {
|
||||
-- action_on = function
|
||||
-- action_off = function
|
||||
-- action_change = function
|
||||
-- rules = rules/get_rules
|
||||
-- },
|
||||
-- conductor =
|
||||
-- {
|
||||
-- state = mesecon.state.on/off
|
||||
-- offstate = opposite state (for state = on only)
|
||||
-- onstate = opposite state (for state = off only)
|
||||
-- rules = rules/get_rules
|
||||
-- }
|
||||
--}
|
||||
|
||||
|
||||
-- PUBLIC VARIABLES
|
||||
mesecon={} -- contains all functions and all global variables
|
||||
mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED
|
||||
mesecon.actions_off={} -- Saves registered function callbacks for mesecon off | DEPRECATED
|
||||
mesecon.actions_change={} -- Saves registered function callbacks for mesecon change | DEPRECATED
|
||||
mesecon.receptors={} -- saves all information about receptors | DEPRECATED
|
||||
mesecon.effectors={} -- saves all information about effectors | DEPRECATED
|
||||
mesecon.conductors={} -- saves all information about conductors | DEPRECATED
|
||||
|
||||
-- Settings
|
||||
dofile(minetest.get_modpath("mesecons").."/settings.lua")
|
||||
|
||||
-- Presets (eg default rules)
|
||||
dofile(minetest.get_modpath("mesecons").."/presets.lua");
|
||||
|
||||
|
||||
-- Utilities like comparing positions,
|
||||
-- adding positions and rules,
|
||||
-- mostly things that make the source look cleaner
|
||||
dofile(minetest.get_modpath("mesecons").."/util.lua");
|
||||
|
||||
-- Internal stuff
|
||||
-- This is the most important file
|
||||
-- it handles signal transmission and basically everything else
|
||||
-- It is also responsible for managing the nodedef things,
|
||||
-- like calling action_on/off/change
|
||||
dofile(minetest.get_modpath("mesecons").."/internal.lua");
|
||||
|
||||
-- Deprecated stuff
|
||||
-- To be removed in future releases
|
||||
-- Currently there is nothing here
|
||||
dofile(minetest.get_modpath("mesecons").."/legacy.lua");
|
||||
|
||||
-- API
|
||||
-- these are the only functions you need to remember
|
||||
|
||||
function mesecon:receptor_on(pos, rules)
|
||||
rules = rules or mesecon.rules.default
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np, rules)
|
||||
if link then
|
||||
mesecon:turnon(np, rulename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:receptor_off(pos, rules)
|
||||
rules = rules or mesecon.rules.default
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np, rules)
|
||||
if link then
|
||||
if not mesecon:connected_to_receptor(np) then
|
||||
mesecon:turnoff(np, rulename)
|
||||
else
|
||||
mesecon:changesignal(np, minetest.env:get_node(np), rulename, mesecon.state.off)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
print("[OK] Mesecons")
|
||||
|
||||
--The actual wires
|
||||
dofile(minetest.get_modpath("mesecons").."/wires.lua");
|
||||
|
||||
--Services like turnoff receptor on dignode and so on
|
||||
dofile(minetest.get_modpath("mesecons").."/services.lua");
|
|
@ -1,472 +0,0 @@
|
|||
-- Internal.lua - The core of mesecons
|
||||
--
|
||||
-- For more practical developer resources see mesecons.tk
|
||||
--
|
||||
-- Function overview
|
||||
-- mesecon:get_effector(nodename) --> Returns the mesecons.effector -specifictation in the nodedef by the nodename
|
||||
-- mesecon:get_receptor(nodename) --> Returns the mesecons.receptor -specifictation in the nodedef by the nodename
|
||||
-- mesecon:get_conductor(nodename) --> Returns the mesecons.conductor-specifictation in the nodedef by the nodename
|
||||
-- mesecon:get_any_inputrules (node) --> Returns the rules of a node if it is a conductor or an effector
|
||||
-- mesecon:get_any_outputrules (node) --> Returns the rules of a node if it is a conductor or a receptor
|
||||
|
||||
-- RECEPTORS
|
||||
-- mesecon:is_receptor(nodename) --> Returns true if nodename is a receptor
|
||||
-- mesecon:is_receptor_on(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.on
|
||||
-- mesecon:is_receptor_off(nodename) --> Returns true if nodename is an receptor with state = mesecon.state.off
|
||||
-- mesecon:receptor_get_rules(node) --> Returns the rules of the receptor (mesecon.rules.default if none specified)
|
||||
|
||||
-- EFFECTORS
|
||||
-- mesecon:is_effector(nodename) --> Returns true if nodename is an effector
|
||||
-- mesecon:is_effector_on(nodename) --> Returns true if nodename is an effector with nodedef.mesecons.effector.action_off
|
||||
-- mesecon:is_effector_off(nodename) --> Returns true if nodename is an effector with nodedef.mesecons.effector.action_on
|
||||
-- mesecon:effector_get_rules(node) --> Returns the input rules of the effector (mesecon.rules.default if none specified)
|
||||
|
||||
-- SIGNALS
|
||||
-- mesecon:activate(pos, node) --> Activates the effector node at the specific pos (calls nodedef.mesecons.effector.action_on)
|
||||
-- mesecon:deactivate(pos, node) --> Deactivates the effector node at the specific pos (calls nodedef.mesecons.effector.action_off)
|
||||
-- mesecon:changesignal(pos, node, rulename, newstate) --> Changes the effector node at the specific pos (calls nodedef.mesecons.effector.action_change)
|
||||
|
||||
-- RULES
|
||||
-- mesecon:add_rules(name, rules) | deprecated? --> Saves rules table by name
|
||||
-- mesecon:get_rules(name, rules) | deprecated? --> Loads rules table with name
|
||||
|
||||
-- CONDUCTORS
|
||||
-- mesecon:is_conductor(nodename) --> Returns true if nodename is a conductor
|
||||
-- mesecon:is_conductor_on(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.on
|
||||
-- mesecon:is_conductor_off(nodename) --> Returns true if nodename is a conductor with state = mesecon.state.off
|
||||
-- mesecon:get_conductor_on(offstate) --> Returns the onstate nodename of the conductor with the name offstate
|
||||
-- mesecon:get_conductor_off(onstate) --> Returns the offstate nodename of the conductor with the name onstate
|
||||
-- mesecon:conductor_get_rules(node) --> Returns the input+output rules of a conductor (mesecon.rules.default if none specified)
|
||||
|
||||
-- HIGH-LEVEL Internals
|
||||
-- mesecon:is_power_on(pos) --> Returns true if pos emits power in any way
|
||||
-- mesecon:is_power_off(pos) --> Returns true if pos does not emit power in any way
|
||||
-- mesecon:turnon(pos, rulename) --> Returns true whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive, the rulename is the name of the input rule that caused calling turnon
|
||||
-- mesecon:turnoff(pos, rulename) --> Turns off whatever there is at pos. Calls itself for connected nodes (if pos is a conductor) --> recursive, the rulename is the name of the input rule that caused calling turnoff
|
||||
-- mesecon:connected_to_receptor(pos) --> Returns true if pos is connected to a receptor directly or via conductors; calls itself if pos is a conductor --> recursive
|
||||
-- mesecon:rules_link(output, input, dug_outputrules) --> Returns true if outputposition + outputrules = inputposition and inputposition + inputrules = outputposition (if the two positions connect)
|
||||
-- mesecon:rules_link_anydir(outp., inp., d_outpr.) --> Same as rules mesecon:rules_link but also returns true if output and input are swapped
|
||||
-- mesecon:is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor
|
||||
|
||||
-- RULES ROTATION helpsers
|
||||
-- mesecon:rotate_rules_right(rules)
|
||||
-- mesecon:rotate_rules_left(rules)
|
||||
-- mesecon:rotate_rules_up(rules)
|
||||
-- mesecon:rotate_rules_down(rules)
|
||||
-- These functions return rules that have been rotated in the specific direction
|
||||
|
||||
-- General
|
||||
function mesecon:get_effector(nodename)
|
||||
if minetest.registered_nodes[nodename]
|
||||
and minetest.registered_nodes[nodename].mesecons
|
||||
and minetest.registered_nodes[nodename].mesecons.effector then
|
||||
return minetest.registered_nodes[nodename].mesecons.effector
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:get_receptor(nodename)
|
||||
if minetest.registered_nodes[nodename]
|
||||
and minetest.registered_nodes[nodename].mesecons
|
||||
and minetest.registered_nodes[nodename].mesecons.receptor then
|
||||
return minetest.registered_nodes[nodename].mesecons.receptor
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:get_conductor(nodename)
|
||||
if minetest.registered_nodes[nodename]
|
||||
and minetest.registered_nodes[nodename].mesecons
|
||||
and minetest.registered_nodes[nodename].mesecons.conductor then
|
||||
return minetest.registered_nodes[nodename].mesecons.conductor
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:get_any_outputrules (node)
|
||||
if mesecon:is_conductor(node.name) then
|
||||
return mesecon:conductor_get_rules(node)
|
||||
elseif mesecon:is_receptor(node.name) then
|
||||
return mesecon:receptor_get_rules(node)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:get_any_inputrules (node)
|
||||
if mesecon:is_conductor(node.name) then
|
||||
return mesecon:conductor_get_rules(node)
|
||||
elseif mesecon:is_effector(node.name) then
|
||||
return mesecon:effector_get_rules(node)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Receptors
|
||||
-- Nodes that can power mesecons
|
||||
function mesecon:is_receptor_on(nodename)
|
||||
local receptor = mesecon:get_receptor(nodename)
|
||||
if receptor and receptor.state == mesecon.state.on then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_receptor_off(nodename)
|
||||
local receptor = mesecon:get_receptor(nodename)
|
||||
if receptor and receptor.state == mesecon.state.off then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_receptor(nodename)
|
||||
local receptor = mesecon:get_receptor(nodename)
|
||||
if receptor then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:receptor_get_rules(node)
|
||||
local receptor = mesecon:get_receptor(node.name)
|
||||
if receptor then
|
||||
local rules = receptor.rules
|
||||
if type(rules) == 'function' then
|
||||
return rules(node)
|
||||
elseif rules then
|
||||
return rules
|
||||
end
|
||||
end
|
||||
|
||||
return mesecon.rules.default
|
||||
end
|
||||
|
||||
-- Effectors
|
||||
-- Nodes that can be powered by mesecons
|
||||
function mesecon:is_effector_on(nodename)
|
||||
local effector = mesecon:get_effector(nodename)
|
||||
if effector and effector.action_off then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_effector_off(nodename)
|
||||
local effector = mesecon:get_effector(nodename)
|
||||
if effector and effector.action_on then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_effector(nodename)
|
||||
local effector = mesecon:get_effector(nodename)
|
||||
if effector then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:effector_get_rules(node)
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector then
|
||||
local rules = effector.rules
|
||||
if type(rules) == 'function' then
|
||||
return rules(node)
|
||||
elseif rules then
|
||||
return rules
|
||||
end
|
||||
end
|
||||
return mesecon.rules.default
|
||||
end
|
||||
|
||||
--Signals
|
||||
|
||||
function mesecon:activate(pos, node, rulename)
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector and effector.action_on then
|
||||
effector.action_on (pos, node, rulename)
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:deactivate(pos, node, rulename)
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector and effector.action_off then
|
||||
effector.action_off (pos, node, rulename)
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:changesignal(pos, node, rulename, newstate)
|
||||
local effector = mesecon:get_effector(node.name)
|
||||
if effector and effector.action_change then
|
||||
effector.action_change (pos, node, rulename, newstate)
|
||||
end
|
||||
end
|
||||
|
||||
--Rules
|
||||
|
||||
function mesecon:add_rules(name, rules)
|
||||
mesecon.rules[name] = rules
|
||||
end
|
||||
|
||||
function mesecon:get_rules(name)
|
||||
return mesecon.rules[name]
|
||||
end
|
||||
|
||||
-- Conductors
|
||||
|
||||
function mesecon:is_conductor_on(nodename)
|
||||
local conductor = mesecon:get_conductor(nodename)
|
||||
if conductor and conductor.state == mesecon.state.on then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_conductor_off(nodename)
|
||||
local conductor = mesecon:get_conductor(nodename)
|
||||
if conductor and conductor.state == mesecon.state.off then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_conductor(nodename)
|
||||
local conductor = mesecon:get_conductor(nodename)
|
||||
if conductor then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:get_conductor_on(offstate)
|
||||
local conductor = mesecon:get_conductor(offstate)
|
||||
if conductor then
|
||||
return conductor.onstate
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:get_conductor_off(onstate)
|
||||
local conductor = mesecon:get_conductor(onstate)
|
||||
if conductor then
|
||||
return conductor.offstate
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:conductor_get_rules(node)
|
||||
local conductor = mesecon:get_conductor(node.name)
|
||||
if conductor then
|
||||
local rules = conductor.rules
|
||||
if type(rules) == 'function' then
|
||||
return rules(node)
|
||||
elseif rules then
|
||||
return rules
|
||||
end
|
||||
end
|
||||
return mesecon.rules.default
|
||||
end
|
||||
|
||||
-- some more general high-level stuff
|
||||
|
||||
function mesecon:is_power_on(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if mesecon:is_conductor_on(node.name) or mesecon:is_receptor_on(node.name) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:is_power_off(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if mesecon:is_conductor_off(node.name) or mesecon:is_receptor_off(node.name) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:turnon(pos, rulename)
|
||||
local node = minetest.env:get_node(pos)
|
||||
|
||||
if mesecon:is_conductor_off(node.name) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
minetest.env:add_node(pos, {name = mesecon:get_conductor_on(node.name), param2 = node.param2})
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np)
|
||||
|
||||
if link then
|
||||
mesecon:turnon(np, rulename)
|
||||
end
|
||||
end
|
||||
elseif mesecon:is_effector(node.name) then
|
||||
mesecon:changesignal(pos, node, rulename, mesecon.state.on)
|
||||
if mesecon:is_effector_off(node.name) then
|
||||
mesecon:activate(pos, node, rulename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:turnoff(pos, rulename)
|
||||
local node = minetest.env:get_node(pos)
|
||||
|
||||
if mesecon:is_conductor_on(node.name) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
minetest.env:add_node(pos, {name = mesecon:get_conductor_off(node.name), param2 = node.param2})
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local link, rulename = mesecon:rules_link(pos, np)
|
||||
|
||||
if link then
|
||||
mesecon:turnoff(np, rulename)
|
||||
end
|
||||
end
|
||||
elseif mesecon:is_effector(node.name) then
|
||||
mesecon:changesignal(pos, node, rulename, mesecon.state.off)
|
||||
if mesecon:is_effector_on(node.name)
|
||||
and not mesecon:is_powered(pos) then
|
||||
mesecon:deactivate(pos, node, rulename)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function mesecon:connected_to_receptor(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
|
||||
-- Check if conductors around are connected
|
||||
local rules = mesecon:get_any_inputrules(node)
|
||||
if not rules then return false end
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if mesecon:rules_link(np, pos) then
|
||||
if mesecon:find_receptor_on(np, {}) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:find_receptor_on(pos, checked)
|
||||
-- find out if node has already been checked (to prevent from endless loop)
|
||||
for _, cp in ipairs(checked) do
|
||||
if mesecon:cmpPos(cp, pos) then
|
||||
return false, checked
|
||||
end
|
||||
end
|
||||
|
||||
-- add current position to checked
|
||||
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z})
|
||||
local node = minetest.env:get_node(pos)
|
||||
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
return true
|
||||
end
|
||||
|
||||
if mesecon:is_conductor(node.name) then
|
||||
local rules = mesecon:conductor_get_rules(node)
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if mesecon:rules_link(np, pos) then
|
||||
if mesecon:find_receptor_on(np, checked) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
|
||||
local outputnode = minetest.env:get_node(output)
|
||||
local inputnode = minetest.env:get_node(input)
|
||||
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
|
||||
local inputrules = mesecon:get_any_inputrules (inputnode)
|
||||
if not outputrules or not inputrules then
|
||||
return
|
||||
end
|
||||
|
||||
for _, outputrule in ipairs(outputrules) do
|
||||
-- Check if output sends to input
|
||||
if mesecon:cmpPos(mesecon:addPosRule(output, outputrule), input) then
|
||||
for _, inputrule in ipairs(inputrules) do
|
||||
-- Check if input accepts from output
|
||||
if mesecon:cmpPos(mesecon:addPosRule(input, inputrule), output) then
|
||||
return true, inputrule.name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function mesecon:rules_link_anydir(pos1, pos2)
|
||||
return mesecon:rules_link(pos1, pos2) or mesecon:rules_link(pos2, pos1)
|
||||
end
|
||||
|
||||
function mesecon:is_powered(pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local rules = mesecon:get_any_inputrules(node)
|
||||
if not rules then return false end
|
||||
|
||||
for _, rule in ipairs(rules) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
local nn = minetest.env:get_node(np)
|
||||
|
||||
if (mesecon:is_conductor_on (nn.name) or mesecon:is_receptor_on (nn.name))
|
||||
and mesecon:rules_link(np, pos) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
--Rules rotation Functions:
|
||||
function mesecon:rotate_rules_right(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
table.insert(nr, {
|
||||
x = -rule.z,
|
||||
y = rule.y,
|
||||
z = rule.x})
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function mesecon:rotate_rules_left(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
table.insert(nr, {
|
||||
x = rule.z,
|
||||
y = rule.y,
|
||||
z = -rule.x})
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function mesecon:rotate_rules_down(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
table.insert(nr, {
|
||||
x = -rule.y,
|
||||
y = rule.x,
|
||||
z = rule.z})
|
||||
end
|
||||
return nr
|
||||
end
|
||||
|
||||
function mesecon:rotate_rules_up(rules)
|
||||
local nr = {}
|
||||
for i, rule in ipairs(rules) do
|
||||
table.insert(nr, {
|
||||
x = rule.y,
|
||||
y = -rule.x,
|
||||
z = rule.z})
|
||||
end
|
||||
return nr
|
||||
end
|
|
@ -1,38 +0,0 @@
|
|||
minetest.register_node("mesecons:mesecon_off", {
|
||||
drawtype = "raillike",
|
||||
tiles = {"jeija_mesecon_off.png", "jeija_mesecon_curved_off.png", "jeija_mesecon_t_junction_off.png", "jeija_mesecon_crossing_off.png"},
|
||||
inventory_image = "jeija_mesecon_off.png",
|
||||
wield_image = "jeija_mesecon_off.png",
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
||||
},
|
||||
groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1},
|
||||
description="Mesecons",
|
||||
mesecons = {conductor={
|
||||
state = mesecon.state.off,
|
||||
onstate = "mesecons:mesecon_on"
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons:mesecon_on", {
|
||||
drawtype = "raillike",
|
||||
tiles = {"jeija_mesecon_on.png", "jeija_mesecon_curved_on.png", "jeija_mesecon_t_junction_on.png", "jeija_mesecon_crossing_on.png"},
|
||||
paramtype = "light",
|
||||
is_ground_content = true,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
||||
},
|
||||
groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1},
|
||||
drop = '"mesecons:mesecon_off" 1',
|
||||
light_source = LIGHT_MAX-11,
|
||||
mesecons = {conductor={
|
||||
state = mesecon.state.on,
|
||||
offstate = "mesecons:mesecon_off"
|
||||
}}
|
||||
})
|
|
@ -1,45 +0,0 @@
|
|||
mesecon.rules = {}
|
||||
mesecon.state = {}
|
||||
|
||||
mesecon.rules.default =
|
||||
{{x=0, y=0, z=-1},
|
||||
{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0},
|
||||
{x=0, y=0, z=1},
|
||||
{x=1, y=1, z=0},
|
||||
{x=1, y=-1, z=0},
|
||||
{x=-1, y=1, z=0},
|
||||
{x=-1, y=-1, z=0},
|
||||
{x=0, y=1, z=1},
|
||||
{x=0, y=-1, z=1},
|
||||
{x=0, y=1, z=-1},
|
||||
{x=0, y=-1, z=-1}}
|
||||
|
||||
mesecon.rules.buttonlike =
|
||||
{{x = 1, y = 0, z = 0},
|
||||
{x = 1, y = 1, z = 0},
|
||||
{x = 1, y =-1, z = 0},
|
||||
{x = 1, y =-1, z = 1},
|
||||
{x = 1, y =-1, z =-1},
|
||||
{x = 2, y = 0, z = 0}}
|
||||
|
||||
mesecon.rules.flat =
|
||||
{{x = 1, y = 0, z = 0},
|
||||
{x =-1, y = 0, z = 0},
|
||||
{x = 0, y = 0, z = 1},
|
||||
{x = 0, y = 0, z =-1}}
|
||||
|
||||
mesecon.rules.buttonlike_get = function(node)
|
||||
local rules = mesecon.rules.buttonlike
|
||||
if node.param2 == 2 then
|
||||
rules=mesecon:rotate_rules_left(rules)
|
||||
elseif node.param2 == 3 then
|
||||
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
|
||||
elseif node.param2 == 0 then
|
||||
rules=mesecon:rotate_rules_right(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
mesecon.state.on = "on"
|
||||
mesecon.state.off = "off"
|
|
@ -1,28 +0,0 @@
|
|||
mesecon.on_placenode = function (pos, node)
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
|
||||
elseif mesecon:is_powered(pos) then
|
||||
if mesecon:is_conductor(node.name) then
|
||||
mesecon:turnon (pos)
|
||||
mesecon:receptor_on (pos, mesecon:conductor_get_rules(node))
|
||||
else
|
||||
mesecon:changesignal(pos, node)
|
||||
mesecon:activate(pos, node)
|
||||
end
|
||||
elseif mesecon:is_conductor_on(node.name) then
|
||||
mesecon:swap_node(pos, mesecon:get_conductor_off(node.name))
|
||||
elseif mesecon:is_effector_on (node.name) then
|
||||
mesecon:deactivate(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
mesecon.on_dignode = function (pos, node)
|
||||
if mesecon:is_conductor_on(node.name) then
|
||||
mesecon:receptor_off(pos, mesecon:conductor_get_rules(node))
|
||||
elseif mesecon:is_receptor_on(node.name) then
|
||||
mesecon:receptor_off(pos, mesecon:receptor_get_rules(node))
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_placenode(mesecon.on_placenode)
|
||||
minetest.register_on_dignode(mesecon.on_dignode)
|
|
@ -1,7 +0,0 @@
|
|||
-- SETTINGS
|
||||
BLINKY_PLANT_INTERVAL = 3
|
||||
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
|
||||
PRESSURE_PLATE_INTERVAL = 0.1
|
||||
OBJECT_DETECTOR_RADIUS = 6
|
||||
PISTON_MAXIMUM_PUSH = 15
|
||||
MOVESTONE_MAXIMUM_PUSH = 100
|
|
@ -1,24 +0,0 @@
|
|||
function mesecon:swap_node(pos, name)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local data = minetest.env:get_meta(pos):to_table()
|
||||
node.name = name
|
||||
minetest.env:add_node(pos, node)
|
||||
minetest.env:get_meta(pos):from_table(data)
|
||||
end
|
||||
|
||||
function mesecon:move_node(pos, newpos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos):to_table()
|
||||
minetest.env:remove_node(pos)
|
||||
minetest.env:add_node(newpos, node)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
|
||||
function mesecon:addPosRule(p, r)
|
||||
return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z}
|
||||
end
|
||||
|
||||
function mesecon:cmpPos(p1, p2)
|
||||
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
|
||||
end
|
|
@ -1,242 +0,0 @@
|
|||
-- 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}
|
||||
box_bump1 = { -2/16, -.5, -2/16, 2/16, -.5+1/64, 2/16 }
|
||||
|
||||
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)
|
||||
|
||||
if nodeid == "00000000" then
|
||||
groups = {dig_immediate = 3, mesecon_conductor_craftable = 1, attach_node = 1}
|
||||
wiredesc = "Mesecon"
|
||||
else
|
||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1, attach_node = 1}
|
||||
wiredesc = "Mesecons Wire (ID: "..nodeid..")"
|
||||
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
|
||||
|
||||
if adjx and adjz and (xp + zp + xm + zm > 2) then
|
||||
table.insert(nodebox, box_bump1)
|
||||
tiles_off = {
|
||||
"jeija_mesecon_crossing_off.png",
|
||||
"jeija_mesecon_crossing_off.png",
|
||||
"jeija_mesecon_off.png",
|
||||
"jeija_mesecon_off.png",
|
||||
"jeija_mesecon_off.png",
|
||||
"jeija_mesecon_off.png"
|
||||
}
|
||||
tiles_on = {
|
||||
"jeija_mesecon_crossing_on.png",
|
||||
"jeija_mesecon_crossing_on.png",
|
||||
"jeija_mesecon_on.png",
|
||||
"jeija_mesecon_on.png",
|
||||
"jeija_mesecon_on.png",
|
||||
"jeija_mesecon_on.png"
|
||||
}
|
||||
else
|
||||
table.insert(nodebox, box_center)
|
||||
tiles_off = {
|
||||
"jeija_mesecon_crossing_off.png",
|
||||
"jeija_mesecon_crossing_off.png",
|
||||
"jeija_mesecon_off.png",
|
||||
"jeija_mesecon_off.png",
|
||||
"jeija_mesecon_off.png",
|
||||
"jeija_mesecon_off.png"
|
||||
}
|
||||
tiles_on = {
|
||||
"jeija_mesecon_crossing_on.png",
|
||||
"jeija_mesecon_crossing_on.png",
|
||||
"jeija_mesecon_on.png",
|
||||
"jeija_mesecon_on.png",
|
||||
"jeija_mesecon_on.png",
|
||||
"jeija_mesecon_on.png"
|
||||
}
|
||||
end
|
||||
|
||||
if nodeid == "00000000" then
|
||||
nodebox = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons:wire_"..nodeid.."_off", {
|
||||
description = "Redstone Dust",
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_off,
|
||||
-- inventory_image = "wires_inv.png",
|
||||
-- wield_image = "wires_inv.png",
|
||||
inventory_image = "default_redstone_dust.png",
|
||||
wield_image = "default_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"
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons:wire_"..nodeid.."_on", {
|
||||
description = "Redstone Dust",
|
||||
drawtype = "nodebox",
|
||||
tiles = tiles_on,
|
||||
-- inventory_image = "wires_inv.png",
|
||||
-- wield_image = "wires_inv.png",
|
||||
inventory_image = "default_redstone_dust.png",
|
||||
wield_image = "default_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, 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"
|
||||
}},
|
||||
})
|
||||
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
|
||||
|
||||
nodename = minetest.env: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.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
|
||||
else
|
||||
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
|
||||
end
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,38 +0,0 @@
|
|||
-- This file registers aliases for the /give /giveme commands.
|
||||
|
||||
minetest.register_alias("mesecons:removestone", "mesecons_random:removestone")
|
||||
minetest.register_alias("mesecons:power_plant", "mesecons_powerplant:power_plant")
|
||||
minetest.register_alias("mesecons:powerplant", "mesecons_powerplant:power_plant")
|
||||
minetest.register_alias("mesecons:meselamp", "mesecons_lamp:lamp_off")
|
||||
minetest.register_alias("mesecons:mesecon", "mesecons:wire_00000000_off")
|
||||
minetest.register_alias("mesecons:object_detector", "mesecons_detector:object_detector_off")
|
||||
minetest.register_alias("mesecons:wireless_inverter", "mesecons_wireless:wireless_inverter_on")
|
||||
minetest.register_alias("mesecons:wireless_receiver", "mesecons_wireless:wireless_receiver_off")
|
||||
minetest.register_alias("mesecons:wireless_transmitter", "mesecons_wireless:wireless_transmitter_off")
|
||||
minetest.register_alias("mesecons:switch", "mesecons_switch:mesecon_switch_off")
|
||||
minetest.register_alias("mesecons:button", "mesecons_button:button_off")
|
||||
minetest.register_alias("mesecons:piston", "mesecons_pistons:piston_normal_off")
|
||||
minetest.register_alias("mesecons:blinky_plant", "mesecons_blinkyplant:blinky_plant_off")
|
||||
minetest.register_alias("mesecons:mesecon_torch", "mesecons_torch:mesecon_torch_on")
|
||||
minetest.register_alias("mesecons:torch", "mesecons_torch:mesecon_torch_on")
|
||||
minetest.register_alias("mesecons:hydro_turbine", "mesecons_hydroturbine:hydro_turbine_off")
|
||||
minetest.register_alias("mesecons:pressure_plate_stone", "mesecons_pressureplates:pressure_plate_stone_off")
|
||||
minetest.register_alias("mesecons:pressure_plate_wood", "mesecons_pressureplates:pressure_plate_wood_off")
|
||||
minetest.register_alias("mesecons:mesecon_socket", "mesecons_temperest:mesecon_socket_off")
|
||||
minetest.register_alias("mesecons:mesecon_inverter", "mesecons_temperest:mesecon_inverter_on")
|
||||
minetest.register_alias("mesecons:movestone", "mesecons_movestones:movestone")
|
||||
minetest.register_alias("mesecons:sticky_movestone", "mesecons_movestones:sticky_movestone")
|
||||
minetest.register_alias("mesecons:noteblock", "mesecons_noteblock:noteblock")
|
||||
minetest.register_alias("mesecons:microcontroller", "mesecons_microcontroller:microcontroller0000")
|
||||
minetest.register_alias("mesecons:delayer", "mesecons_delayer:delayer_off_1")
|
||||
minetest.register_alias("mesecons:solarpanel", "mesecons_solarpanel:solar_panel_off")
|
||||
|
||||
|
||||
--Backwards compatibility
|
||||
minetest.register_alias("mesecons:mesecon_off", "mesecons:wire_00000000_off")
|
||||
minetest.register_alias("mesecons_pistons:piston_sticky", "mesecons_pistons:piston_sticky_on")
|
||||
minetest.register_alias("mesecons_pistons:piston_normal", "mesecons_pistons:piston_normal_on")
|
||||
minetest.register_alias("mesecons_pistons:piston_up_normal", "mesecons_pistons:piston_up_normal_on")
|
||||
minetest.register_alias("mesecons_pistons:piston_down_normal", "mesecons_pistons:piston_down_normal_on")
|
||||
minetest.register_alias("mesecons_pistons:piston_up_sticky", "mesecons_pistons:piston_up_sticky_on")
|
||||
minetest.register_alias("mesecons_pistons:piston_down_sticky", "mesecons_pistons:piston_down_sticky_on")
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,149 +0,0 @@
|
|||
-- WALL BUTTON
|
||||
-- A button that when pressed emits power for 1 second
|
||||
-- and then turns off again
|
||||
|
||||
mesecon.button_turnoff = function (pos)
|
||||
local node = minetest.env:get_node(pos)
|
||||
if node.name=="mesecons_button:button_stone_on" then --has not been dug
|
||||
mesecon:swap_node(pos, "mesecons_button:button_stone_off")
|
||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||
local rules = mesecon.rules.buttonlike_get(node)
|
||||
mesecon:receptor_off(pos, rules)
|
||||
elseif node.name=="mesecons_button:button_wood_on" then --has not been dug
|
||||
mesecon:swap_node(pos, "mesecons_button:button_wood_off")
|
||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||
local rules = mesecon.rules.buttonlike_get(node)
|
||||
mesecon:receptor_off(pos, rules)
|
||||
end
|
||||
end
|
||||
|
||||
local boxes_off = { -4/16, -2/16, 8/16, 4/16, 2/16, 6/16 } -- The button
|
||||
local boxes_on = { -4/16, -2/16, 8/16, 4/16, 2/16, 7/16 } -- The button
|
||||
|
||||
minetest.register_node("mesecons_button:button_stone_off", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"default_stone.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
legacy_wallmounted = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_off
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_off -- the button itself
|
||||
},
|
||||
groups = {dig_immediate=2, attached_node=1},
|
||||
description = "Stone Button",
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_button:button_stone_on")
|
||||
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||
minetest.after(1, mesecon.button_turnoff, pos)
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.buttonlike_get
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_button:button_stone_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"default_stone.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
legacy_wallmounted = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_on
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_on -- the button itself
|
||||
},
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, attached_node=1},
|
||||
drop = 'mesecons_button:button_stone_off',
|
||||
description = "Stone Button",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.buttonlike_get
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_button:button_wood_off", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"default_wood.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
legacy_wallmounted = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_off
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_off -- the button itself
|
||||
},
|
||||
groups = {dig_immediate=2, attached_node=1},
|
||||
description = "Wood Button",
|
||||
on_punch = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_button:button_wood_on")
|
||||
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||
minetest.after(1, mesecon.button_turnoff, pos)
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off,
|
||||
rules = mesecon.rules.buttonlike_get
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_button:button_wood_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {"default_wood.png"},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
legacy_wallmounted = true,
|
||||
walkable = false,
|
||||
sunlight_propagates = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_on
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes_on -- the button itself
|
||||
},
|
||||
groups = {dig_immediate=2, not_in_creative_inventory=1, attached_node=1},
|
||||
drop = 'mesecons_button:button_wood_off',
|
||||
description = "Wood Button",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on,
|
||||
rules = mesecon.rules.buttonlike_get
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'mesecons_button:button_stone_off',
|
||||
recipe = {
|
||||
{'default:stone'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'mesecons_button:button_wood_off',
|
||||
recipe = {
|
||||
{'group:wood'},
|
||||
}
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,191 +0,0 @@
|
|||
minetest.register_chatcommand("say", {
|
||||
params = "<text>",
|
||||
description = "Say <text> as the server",
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
minetest.chat_send_all(name .. ": " .. param)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("tell", {
|
||||
params = "<name> <text>",
|
||||
description = "Say <text> to <name> privately",
|
||||
func = function(name, param)
|
||||
local found, _, target, message = param:find("^([^%s]+)%s+(.*)$")
|
||||
if found == nil then
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
minetest.chat_send_player(target, name .. " whispers: " .. message)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("hp", {
|
||||
params = "<name> <value>",
|
||||
description = "Set health of <name> to <value> hitpoints",
|
||||
privs = {ban=true},
|
||||
func = function(name, param)
|
||||
local found, _, target, value = param:find("^([^%s]+)%s+(%d+)$")
|
||||
if found == nil then
|
||||
minetest.chat_send_player(name, "Invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
minetest.get_player_by_name(target):set_hp(value)
|
||||
end
|
||||
})
|
||||
|
||||
local initialize_data = function(meta, player, command, param)
|
||||
meta:set_string("formspec",
|
||||
"invsize[9,6;]" ..
|
||||
"field[1,1;7.5,1;player;Player;" .. player .. "]" ..
|
||||
"button[1.3,2;2,1;nearest;Nearest]" ..
|
||||
"button[3.3,2;2,1;farthest;Farthest]" ..
|
||||
"button[5.3,2;2,1;random;Random]" ..
|
||||
"field[1,4;2,1;command;Command;" .. command .. "]" ..
|
||||
"field[3,4;5.5,1;param;Parameter;" .. param .. "]" ..
|
||||
"button_exit[3.3,5;2,1;submit;Submit]")
|
||||
local owner = meta:get_string("owner")
|
||||
if owner == "" then
|
||||
owner = "not owned"
|
||||
else
|
||||
owner = "owned by " .. owner
|
||||
end
|
||||
meta:set_string("infotext", "Command Block\n" ..
|
||||
"(" .. owner .. ")\n" ..
|
||||
"Command: /" .. command .. " " .. param)
|
||||
end
|
||||
|
||||
local construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
|
||||
meta:set_string("player", "@nearest")
|
||||
meta:set_string("command", "time")
|
||||
meta:set_string("param", "7000")
|
||||
|
||||
meta:set_string("owner", "")
|
||||
|
||||
initialize_data(meta, "@nearest", "time", "7000")
|
||||
end
|
||||
|
||||
local after_place = function(pos, placer)
|
||||
if placer then
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
initialize_data(meta, "@nearest", "time", "7000")
|
||||
end
|
||||
end
|
||||
|
||||
local receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if fields.nearest then
|
||||
initialize_data(meta, "@nearest", fields.command, fields.param)
|
||||
elseif fields.farthest then
|
||||
initialize_data(meta, "@farthest", fields.command, fields.param)
|
||||
elseif fields.random then
|
||||
initialize_data(meta, "@random", fields.command, fields.param)
|
||||
else --fields.submit or pressed enter
|
||||
meta:set_string("player", fields.player)
|
||||
meta:set_string("command", fields.command)
|
||||
meta:set_string("param", fields.param)
|
||||
|
||||
initialize_data(meta, fields.player, fields.command, fields.param)
|
||||
end
|
||||
end
|
||||
|
||||
local resolve_player = function(name, pos)
|
||||
local get_distance = function(pos1, pos2)
|
||||
return math.sqrt((pos1.x - pos2.x) ^ 2 + (pos1.y - pos2.y) ^ 2 + (pos1.z - pos2.z) ^ 2)
|
||||
end
|
||||
|
||||
if name == "@nearest" then
|
||||
local min_distance = math.huge
|
||||
for index, player in ipairs(minetest.get_connected_players()) do
|
||||
local distance = get_distance(pos, player:getpos())
|
||||
if distance < min_distance then
|
||||
min_distance = distance
|
||||
name = player:get_player_name()
|
||||
end
|
||||
end
|
||||
elseif name == "@farthest" then
|
||||
local max_distance = -1
|
||||
for index, player in ipairs(minetest.get_connected_players()) do
|
||||
local distance = get_distance(pos, player:getpos())
|
||||
if distance > max_distance then
|
||||
max_distance = distance
|
||||
name = player:get_player_name()
|
||||
end
|
||||
end
|
||||
elseif name == "@random" then
|
||||
local players = minetest.get_connected_players()
|
||||
local player = players[math.random(#players)]
|
||||
name = player:get_player_name()
|
||||
end
|
||||
return name
|
||||
end
|
||||
|
||||
local commandblock_action_on = function(pos, node)
|
||||
if node.name ~= "mesecons_commandblock:commandblock_off" then
|
||||
return
|
||||
end
|
||||
|
||||
mesecon:swap_node(pos, "mesecons_commandblock:commandblock_on")
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local command = minetest.chatcommands[meta:get_string("command")]
|
||||
if command == nil then
|
||||
return
|
||||
end
|
||||
local owner = meta:get_string("owner")
|
||||
if owner == "" then
|
||||
return
|
||||
end
|
||||
local has_privs, missing_privs = minetest.check_player_privs(owner, command.privs)
|
||||
if not has_privs then
|
||||
minetest.chat_send_player(owner, "You don't have permission to run this command (missing privileges: "..table.concat(missing_privs, ", ")..")")
|
||||
return
|
||||
end
|
||||
local player = resolve_player(meta:get_string("player"), pos)
|
||||
command.func(player, meta:get_string("param"))
|
||||
end
|
||||
|
||||
local commandblock_action_off = function(pos, node)
|
||||
if node.name == "mesecons_commandblock:commandblock_on" then
|
||||
mesecon:swap_node(pos, "mesecons_commandblock:commandblock_off")
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_commandblock:commandblock_off", {
|
||||
description = "Command Block",
|
||||
tiles = {"jeija_commandblock_off.png"},
|
||||
inventory_image = minetest.inventorycube("jeija_commandblock_off.png"),
|
||||
groups = {cracky=2, mesecon_effector_off=1},
|
||||
on_construct = construct,
|
||||
after_place_node = after_place,
|
||||
on_receive_fields = receive_fields,
|
||||
can_dig = function(pos,player)
|
||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = commandblock_action_on
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_commandblock:commandblock_on", {
|
||||
tiles = {"jeija_commandblock_on.png"},
|
||||
groups = {cracky=2, mesecon_effector_on=1, not_in_creative_inventory=1},
|
||||
light_source = 10,
|
||||
drop = "mesecons_commandblock:commandblock_off",
|
||||
on_construct = construct,
|
||||
after_place_node = after_place,
|
||||
on_receive_fields = receive_fields,
|
||||
can_dig = function(pos,player)
|
||||
local owner = minetest.env:get_meta(pos):get_string("owner")
|
||||
return owner == "" or owner == player:get_player_name()
|
||||
end,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = commandblock_action_off
|
||||
}}
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,204 +0,0 @@
|
|||
-- Function that get the input/output rules of the delayer
|
||||
local delayer_get_output_rules = function(node)
|
||||
local rules = {{x = 0, y = 0, z = 1}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon:rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
local delayer_get_input_rules = function(node)
|
||||
local rules = {{x = 0, y = 0, z = -1}}
|
||||
for i = 0, node.param2 do
|
||||
rules = mesecon:rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
-- Functions that are called after the delay time
|
||||
|
||||
local delayer_turnon = function(params)
|
||||
local rules = delayer_get_output_rules(params.node)
|
||||
mesecon:receptor_on(params.pos, rules)
|
||||
end
|
||||
|
||||
local delayer_turnoff = function(params)
|
||||
local rules = delayer_get_output_rules(params.node)
|
||||
mesecon:receptor_off(params.pos, rules)
|
||||
end
|
||||
|
||||
local delayer_activate = function(pos, node)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local time = def.delayer_time
|
||||
mesecon:swap_node(pos, def.delayer_onstate)
|
||||
minetest.after(time, delayer_turnon , {pos = pos, node = node})
|
||||
end
|
||||
|
||||
local delayer_deactivate = function(pos, node)
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
local time = def.delayer_time
|
||||
mesecon:swap_node(pos, def.delayer_offstate)
|
||||
minetest.after(time, delayer_turnoff, {pos = pos, node = node})
|
||||
end
|
||||
|
||||
-- Register the 2 (states) x 4 (delay times) delayers
|
||||
|
||||
for i = 1, 4 do
|
||||
local groups = {}
|
||||
if i == 1 then
|
||||
groups = {bendy=2,snappy=1,dig_immediate=2}
|
||||
else
|
||||
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1}
|
||||
end
|
||||
|
||||
local delaytime
|
||||
if i == 1 then delaytime = 0.1
|
||||
elseif i == 2 then delaytime = 0.3
|
||||
elseif i == 3 then delaytime = 0.5
|
||||
elseif i == 4 then delaytime = 1.0
|
||||
end
|
||||
|
||||
local boxes
|
||||
if i == 1 then
|
||||
boxes = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
|
||||
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
|
||||
{ 0/16, -6/16, -1/16, 2/16, -1/16, 1/16}, -- moved torch
|
||||
}
|
||||
elseif i == 2 then
|
||||
boxes = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
|
||||
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
|
||||
{ -2/16, -6/16, -1/16, 0/16, -1/16, 1/16}, -- moved torch
|
||||
}
|
||||
elseif i == 3 then
|
||||
boxes = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
|
||||
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
|
||||
{ -4/16, -6/16, -1/16, -2/16, -1/16, 1/16}, -- moved torch
|
||||
}
|
||||
elseif i == 4 then
|
||||
boxes = {
|
||||
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab
|
||||
{ 6/16, -6/16, -1/16, 4/16, -1/16, 1/16}, -- still torch
|
||||
{ -6/16, -6/16, -1/16, -4/16, -1/16, 1/16}, -- moved torch
|
||||
}
|
||||
end
|
||||
|
||||
minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
|
||||
description = "Delayer",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_delayer_off.png",
|
||||
"mesecons_delayer_bottom.png",
|
||||
"mesecons_delayer_ends_off.png",
|
||||
"mesecons_delayer_ends_off.png",
|
||||
"mesecons_delayer_sides_off.png",
|
||||
"mesecons_delayer_sides_off.png"
|
||||
},
|
||||
wield_image = "mesecons_delayer_off.png",
|
||||
walkable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
groups = groups,
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = true,
|
||||
drop = 'mesecons_delayer:delayer_off_1',
|
||||
on_punch = function (pos, node)
|
||||
if node.name=="mesecons_delayer:delayer_off_1" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_2")
|
||||
elseif node.name=="mesecons_delayer:delayer_off_2" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_3")
|
||||
elseif node.name=="mesecons_delayer:delayer_off_3" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_4")
|
||||
elseif node.name=="mesecons_delayer:delayer_off_4" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_off_1")
|
||||
end
|
||||
end,
|
||||
delayer_time = delaytime,
|
||||
delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i),
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {
|
||||
receptor =
|
||||
{
|
||||
state = mesecon.state.off,
|
||||
rules = delayer_get_output_rules
|
||||
},
|
||||
effector =
|
||||
{
|
||||
rules = delayer_get_input_rules,
|
||||
action_on = delayer_activate
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
|
||||
description = "You hacker you",
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_delayer_on.png",
|
||||
"mesecons_delayer_bottom.png",
|
||||
"mesecons_delayer_ends_on.png",
|
||||
"mesecons_delayer_ends_on.png",
|
||||
"mesecons_delayer_sides_on.png",
|
||||
"mesecons_delayer_sides_on.png"
|
||||
},
|
||||
walkable = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
groups = {bendy = 2, snappy = 1, dig_immediate = 2, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = true,
|
||||
drop = 'mesecons_delayer:delayer_off_1',
|
||||
on_punch = function (pos, node)
|
||||
if node.name=="mesecons_delayer:delayer_on_1" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_2")
|
||||
elseif node.name=="mesecons_delayer:delayer_on_2" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_3")
|
||||
elseif node.name=="mesecons_delayer:delayer_on_3" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_4")
|
||||
elseif node.name=="mesecons_delayer:delayer_on_4" then
|
||||
mesecon:swap_node(pos,"mesecons_delayer:delayer_on_1")
|
||||
end
|
||||
end,
|
||||
delayer_time = delaytime,
|
||||
delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i),
|
||||
mesecons = {
|
||||
receptor =
|
||||
{
|
||||
state = mesecon.state.on,
|
||||
rules = delayer_get_output_rules
|
||||
},
|
||||
effector =
|
||||
{
|
||||
rules = delayer_get_input_rules,
|
||||
action_off = delayer_deactivate
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesecons_delayer:delayer_off_1",
|
||||
recipe = {
|
||||
{"mesecons_torch:mesecon_torch_on", "", "mesecons_torch:mesecon_torch_on"},
|
||||
{"default:stone","default:stone", "default:stone"},
|
||||
}
|
||||
})
|
Before Width: | Height: | Size: 364 B |
Before Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 651 B |
Before Width: | Height: | Size: 659 B |
Before Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 265 B |
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,35 +0,0 @@
|
|||
minetest.register_node("mesecons_lightstone:lightstone_off", {
|
||||
tiles = {"jeija_lightstone_gray_off.png"},
|
||||
inventory_image = minetest.inventorycube("jeija_lightstone_gray_off.png"),
|
||||
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
|
||||
description= "Redstone Lamp",
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_on")
|
||||
end
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_node("mesecons_lightstone:lightstone_on", {
|
||||
tiles = {"jeija_lightstone_gray_off.png"},
|
||||
inventory_image = minetest.inventorycube("jeija_lightstone_gray_off.png"),
|
||||
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
|
||||
drop = "node mesecons_lightstone:lightstone_off",
|
||||
light_source = LIGHT_MAX-2,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
mesecons = {effector = {
|
||||
action_off = function (pos, node)
|
||||
mesecon:swap_node(pos, "mesecons_lightstone:lightstone_off")
|
||||
end
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "node mesecons_lightstone:lightstone_off",
|
||||
recipe = {
|
||||
{'',"default:redstone_dust",''},
|
||||
{"default:redstone_dust",'default:glowstone',"default:redstone_dust"},
|
||||
{'','default:redstone_dust',''},
|
||||
}
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,14 +0,0 @@
|
|||
--GLUE
|
||||
minetest.register_craftitem("mesecons_materials:glue", {
|
||||
image = "jeija_glue.png",
|
||||
on_place_on_ground = minetest.craftitem_place_item,
|
||||
description="Glue",
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_materials:glue" 2',
|
||||
type = "cooking",
|
||||
recipe = "default:sapling",
|
||||
cooktime = 2
|
||||
})
|
||||
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,127 +0,0 @@
|
|||
--register stoppers for movestones/pistons
|
||||
|
||||
mesecon.mvps_stoppers={}
|
||||
|
||||
function mesecon:is_mvps_stopper(node, pushdir, stack, stackid)
|
||||
local get_stopper = mesecon.mvps_stoppers[node.name]
|
||||
if type (get_stopper) == "function" then
|
||||
get_stopper = get_stopper(node, pushdir, stack, stackid)
|
||||
end
|
||||
return get_stopper
|
||||
end
|
||||
|
||||
function mesecon:register_mvps_stopper(nodename, get_stopper)
|
||||
if get_stopper == nil then
|
||||
get_stopper = true
|
||||
end
|
||||
mesecon.mvps_stoppers[nodename] = get_stopper
|
||||
end
|
||||
|
||||
function mesecon:mvps_process_stack(stack)
|
||||
-- update mesecons for placed nodes ( has to be done after all nodes have been added )
|
||||
for _, n in ipairs(stack) do
|
||||
nodeupdate(n.pos)
|
||||
mesecon.on_placenode(n.pos, minetest.env:get_node(n.pos))
|
||||
mesecon:update_autoconnect(n.pos)
|
||||
end
|
||||
end
|
||||
|
||||
function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed
|
||||
np = {x = pos.x, y = pos.y, z = pos.z}
|
||||
|
||||
-- determine the number of nodes to be pushed
|
||||
local nodes = {}
|
||||
while true do
|
||||
nn = minetest.env:get_node_or_nil(np)
|
||||
if not nn or #nodes > maximum then
|
||||
-- don't push at all, something is in the way (unloaded map or too many nodes)
|
||||
return
|
||||
end
|
||||
|
||||
if nn.name == "air"
|
||||
or minetest.registered_nodes[nn.name].liquidtype ~= "none" then --is liquid
|
||||
break
|
||||
end
|
||||
|
||||
table.insert (nodes, {node = nn, pos = np})
|
||||
|
||||
np = mesecon:addPosRule(np, dir)
|
||||
end
|
||||
|
||||
-- determine if one of the nodes blocks the push
|
||||
for id, n in ipairs(nodes) do
|
||||
if mesecon:is_mvps_stopper(n.node, dir, nodes, id) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- remove all nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
n.meta = minetest.env:get_meta(n.pos):to_table()
|
||||
minetest.env:remove_node(n.pos)
|
||||
end
|
||||
|
||||
-- update mesecons for removed nodes ( has to be done after all nodes have been removed )
|
||||
for _, n in ipairs(nodes) do
|
||||
mesecon.on_dignode(n.pos, n.node)
|
||||
mesecon:update_autoconnect(n.pos)
|
||||
end
|
||||
|
||||
-- add nodes
|
||||
for _, n in ipairs(nodes) do
|
||||
np = mesecon:addPosRule(n.pos, dir)
|
||||
minetest.env:add_node(np, n.node)
|
||||
minetest.env:get_meta(np):from_table(n.meta)
|
||||
end
|
||||
|
||||
for i in ipairs(nodes) do
|
||||
nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir)
|
||||
end
|
||||
|
||||
return true, nodes
|
||||
end
|
||||
|
||||
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
|
||||
np = mesecon:addPosRule(pos, dir)
|
||||
nn = minetest.env:get_node(np)
|
||||
|
||||
if minetest.registered_nodes[nn.name].liquidtype == "none"
|
||||
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then
|
||||
local meta = minetest.env:get_meta(np):to_table()
|
||||
minetest.env:remove_node(np)
|
||||
minetest.env:add_node(pos, nn)
|
||||
minetest.env:get_meta(pos):from_table(meta)
|
||||
|
||||
nodeupdate(np)
|
||||
nodeupdate(pos)
|
||||
mesecon.on_dignode(np, nn)
|
||||
mesecon:update_autoconnect(np)
|
||||
end
|
||||
return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}}
|
||||
end
|
||||
|
||||
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
|
||||
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
|
||||
local lnode = minetest.env:get_node(lpos)
|
||||
local lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
|
||||
local lnode2 = minetest.env:get_node(lpos2)
|
||||
|
||||
if lnode.name ~= "ignore" and lnode.name ~= "air" and minetest.registered_nodes[lnode.name].liquidtype == "none" then return end
|
||||
if lnode2.name == "ignore" or lnode2.name == "air" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none") then return end
|
||||
|
||||
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
|
||||
repeat
|
||||
lnode2 = minetest.env:get_node(lpos2)
|
||||
minetest.env:add_node(oldpos, {name=lnode2.name})
|
||||
nodeupdate(oldpos)
|
||||
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
|
||||
lpos2.x = lpos2.x-direction.x
|
||||
lpos2.y = lpos2.y-direction.y
|
||||
lpos2.z = lpos2.z-direction.z
|
||||
lnode = minetest.env:get_node(lpos2)
|
||||
until lnode.name=="air" or lnode.name=="ignore" or not(minetest.registered_nodes[lnode2.name].liquidtype == "none")
|
||||
minetest.env:remove_node(oldpos)
|
||||
end
|
||||
|
||||
mesecon:register_mvps_stopper("default:chest_locked")
|
||||
mesecon:register_mvps_stopper("default:furnace")
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,79 +0,0 @@
|
|||
minetest.register_node("mesecons_noteblock:noteblock", {
|
||||
description = "Noteblock",
|
||||
tiles = {"mesecons_noteblock.png"},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
drawtype = "allfaces_optional",
|
||||
visual_scale = 1.3,
|
||||
paramtype="light",
|
||||
after_place_node = function(pos)
|
||||
minetest.env:add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
|
||||
end,
|
||||
on_punch = function (pos, node) -- change sound when punched
|
||||
local param2 = node.param2+1
|
||||
if param2==12 then param2=0 end
|
||||
minetest.env:add_node(pos, {name = node.name, param2 = param2})
|
||||
mesecon.noteblock_play(pos, param2)
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector = { -- play sound when activated
|
||||
action_on = function (pos, node)
|
||||
mesecon.noteblock_play(pos, node.param2)
|
||||
end
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_noteblock:noteblock" 1',
|
||||
recipe = {
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
{"default:steel_ingot", "default:redstone_dust", "default:steel_ingot"},
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
}
|
||||
})
|
||||
|
||||
mesecon.noteblock_play = function (pos, param2)
|
||||
local soundname
|
||||
if param2==8 then
|
||||
soundname="mesecons_noteblock_a"
|
||||
elseif param2==9 then
|
||||
soundname="mesecons_noteblock_asharp"
|
||||
elseif param2==10 then
|
||||
soundname="mesecons_noteblock_b"
|
||||
elseif param2==11 then
|
||||
soundname="mesecons_noteblock_c"
|
||||
elseif param2==0 then
|
||||
soundname="mesecons_noteblock_csharp"
|
||||
elseif param2==1 then
|
||||
soundname="mesecons_noteblock_d"
|
||||
elseif param2==2 then
|
||||
soundname="mesecons_noteblock_dsharp"
|
||||
elseif param2==3 then
|
||||
soundname="mesecons_noteblock_e"
|
||||
elseif param2==4 then
|
||||
soundname="mesecons_noteblock_f"
|
||||
elseif param2==5 then
|
||||
soundname="mesecons_noteblock_fsharp"
|
||||
elseif param2==6 then
|
||||
soundname="mesecons_noteblock_g"
|
||||
elseif param2==7 then
|
||||
soundname="mesecons_noteblock_gsharp"
|
||||
end
|
||||
local block_below_name = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
||||
if block_below_name == "default:glass" then
|
||||
soundname="mesecons_noteblock_hihat"
|
||||
end
|
||||
if block_below_name == "default:stone" then
|
||||
soundname="mesecons_noteblock_kick"
|
||||
end
|
||||
if block_below_name == "default:chest" then
|
||||
soundname="mesecons_noteblock_snare"
|
||||
end
|
||||
if block_below_name == "default:tree" then
|
||||
soundname="mesecons_noteblock_crash"
|
||||
end
|
||||
if block_below_name == "default:wood" then
|
||||
soundname="mesecons_noteblock_litecrash"
|
||||
end
|
||||
minetest.sound_play(soundname,
|
||||
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
||||
end
|
Before Width: | Height: | Size: 759 B |
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
mesecons_mvps
|
|
@ -1,746 +0,0 @@
|
|||
-- Get mesecon rules of pistons
|
||||
piston_rules =
|
||||
{{x=0, y=0, z=1}, --everything apart from z- (pusher side)
|
||||
{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0},
|
||||
{x=1, y=1, z=0},
|
||||
{x=1, y=-1, z=0},
|
||||
{x=-1, y=1, z=0},
|
||||
{x=-1, y=-1, z=0},
|
||||
{x=0, y=1, z=1},
|
||||
{x=0, y=-1, z=1}}
|
||||
|
||||
local piston_up_rules =
|
||||
{{x=0, y=0, z=-1}, --everything apart from y+ (pusher side)
|
||||
{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0},
|
||||
{x=0, y=0, z=1},
|
||||
{x=1, y=-1, z=0},
|
||||
{x=-1, y=-1, z=0},
|
||||
{x=0, y=-1, z=1},
|
||||
{x=0, y=-1, z=-1}}
|
||||
|
||||
local piston_down_rules =
|
||||
{{x=0, y=0, z=-1}, --everything apart from y- (pusher side)
|
||||
{x=1, y=0, z=0},
|
||||
{x=-1, y=0, z=0},
|
||||
{x=0, y=0, z=1},
|
||||
{x=1, y=1, z=0},
|
||||
{x=-1, y=1, z=0},
|
||||
{x=0, y=1, z=1},
|
||||
{x=0, y=1, z=-1}}
|
||||
|
||||
local piston_get_rules = function (node)
|
||||
local rules = piston_rules
|
||||
for i = 1, node.param2 do
|
||||
rules = mesecon:rotate_rules_left(rules)
|
||||
end
|
||||
return rules
|
||||
end
|
||||
|
||||
piston_facedir_direction = function (node)
|
||||
local rules = {{x = 0, y = 0, z = -1}}
|
||||
for i = 1, node.param2 do
|
||||
rules = mesecon:rotate_rules_left(rules)
|
||||
end
|
||||
return rules[1]
|
||||
end
|
||||
|
||||
piston_get_direction = function (dir, node)
|
||||
if type(dir) == "function" then
|
||||
return dir(node)
|
||||
else
|
||||
return dir
|
||||
end
|
||||
end
|
||||
|
||||
local piston_remove_pusher = function (pos, node)
|
||||
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
local pusherpos = mesecon:addPosRule(pos, dir)
|
||||
local pushername = minetest.env:get_node(pusherpos).name
|
||||
|
||||
if pushername == pistonspec.pusher then --make sure there actually is a pusher (for compatibility reasons mainly)
|
||||
minetest.env:remove_node(pusherpos)
|
||||
nodeupdate(pusherpos)
|
||||
end
|
||||
end
|
||||
|
||||
local piston_on = function (pos, node)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
local np = mesecon:addPosRule(pos, dir)
|
||||
success, stack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
|
||||
if success then
|
||||
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
mesecon:mvps_process_stack(stack)
|
||||
end
|
||||
end
|
||||
|
||||
local piston_off = function (pos, node)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.offname})
|
||||
piston_remove_pusher (pos, node)
|
||||
|
||||
if pistonspec.sticky then
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
pullpos = mesecon:addPosRule(pos, dir)
|
||||
stack = mesecon:mvps_pull_single(pullpos, dir)
|
||||
mesecon:mvps_process_stack(stack)
|
||||
end
|
||||
end
|
||||
|
||||
local piston_orientate = function (pos, placer)
|
||||
-- not placed by player
|
||||
if not placer then return end
|
||||
|
||||
-- placer pitch in degrees
|
||||
local pitch = placer:get_look_pitch() * (180 / math.pi)
|
||||
|
||||
local node = minetest.env:get_node(pos)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
if pitch > 55 then --looking upwards
|
||||
minetest.env:add_node(pos, {name=pistonspec.piston_down})
|
||||
elseif pitch < -55 then --looking downwards
|
||||
minetest.env:add_node(pos, {name=pistonspec.piston_up})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Horizontal pistons
|
||||
|
||||
local pt = 3/16 -- pusher thickness
|
||||
|
||||
local piston_pusher_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-2/16, -2/16, -.5 + pt, 2/16, 2/16, .5 + pt},
|
||||
{-.5 , -.5 , -.5 , .5 , .5 , -.5 + pt},
|
||||
}
|
||||
}
|
||||
|
||||
local piston_on_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-.5, -.5, -.5 + pt, .5, .5, .5}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- Normal (non-sticky) ones:
|
||||
|
||||
local pistonspec_normal = {
|
||||
offname = "mesecons_pistons:piston_normal_off",
|
||||
onname = "mesecons_pistons:piston_normal_on",
|
||||
dir = piston_facedir_direction,
|
||||
pusher = "mesecons_pistons:piston_pusher_normal",
|
||||
piston_down = "mesecons_pistons:piston_down_normal_off",
|
||||
piston_up = "mesecons_pistons:piston_up_normal_off",
|
||||
}
|
||||
|
||||
-- offstate
|
||||
minetest.register_node("mesecons_pistons:piston_normal_off", {
|
||||
description = "Piston",
|
||||
tiles = {
|
||||
"mesecons_piston_top.png",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_left.png",
|
||||
"mesecons_piston_right.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_pusher_front.png"
|
||||
},
|
||||
groups = {cracky = 3},
|
||||
paramtype2 = "facedir",
|
||||
after_place_node = piston_orientate,
|
||||
mesecons_piston = pistonspec_normal,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_get_rules
|
||||
}}
|
||||
})
|
||||
|
||||
-- onstate
|
||||
minetest.register_node("mesecons_pistons:piston_normal_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_top.png",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_left.png",
|
||||
"mesecons_piston_right.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_on_front.png"
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
after_dig_node = piston_remove_pusher,
|
||||
node_box = piston_on_box,
|
||||
selection_box = piston_on_box,
|
||||
mesecons_piston = pistonspec_normal,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_get_rules
|
||||
}}
|
||||
})
|
||||
|
||||
-- pusher
|
||||
minetest.register_node("mesecons_pistons:piston_pusher_normal", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_top.png",
|
||||
"mesecons_piston_pusher_bottom.png",
|
||||
"mesecons_piston_pusher_left.png",
|
||||
"mesecons_piston_pusher_right.png",
|
||||
"mesecons_piston_pusher_back.png",
|
||||
"mesecons_piston_pusher_front.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
corresponding_piston = "mesecons_pistons:piston_normal_on",
|
||||
selection_box = piston_pusher_box,
|
||||
node_box = piston_pusher_box,
|
||||
})
|
||||
|
||||
-- Sticky ones
|
||||
|
||||
local pistonspec_sticky = {
|
||||
offname = "mesecons_pistons:piston_sticky_off",
|
||||
onname = "mesecons_pistons:piston_sticky_on",
|
||||
dir = piston_facedir_direction,
|
||||
pusher = "mesecons_pistons:piston_pusher_sticky",
|
||||
sticky = true,
|
||||
piston_down = "mesecons_pistons:piston_down_sticky_off",
|
||||
piston_up = "mesecons_pistons:piston_up_sticky_off",
|
||||
}
|
||||
|
||||
-- offstate
|
||||
minetest.register_node("mesecons_pistons:piston_sticky_off", {
|
||||
description = "Sticky Piston",
|
||||
tiles = {
|
||||
"mesecons_piston_top.png",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_left.png",
|
||||
"mesecons_piston_right.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_pusher_front_sticky.png"
|
||||
},
|
||||
groups = {cracky = 3},
|
||||
paramtype2 = "facedir",
|
||||
after_place_node = piston_orientate,
|
||||
mesecons_piston = pistonspec_sticky,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_get_rules
|
||||
}}
|
||||
})
|
||||
|
||||
-- onstate
|
||||
minetest.register_node("mesecons_pistons:piston_sticky_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_top.png",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_left.png",
|
||||
"mesecons_piston_right.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_on_front.png"
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
after_dig_node = piston_remove_pusher,
|
||||
node_box = piston_on_box,
|
||||
selection_box = piston_on_box,
|
||||
mesecons_piston = pistonspec_sticky,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_get_rules
|
||||
}}
|
||||
})
|
||||
|
||||
-- pusher
|
||||
minetest.register_node("mesecons_pistons:piston_pusher_sticky", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_top.png",
|
||||
"mesecons_piston_pusher_bottom.png",
|
||||
"mesecons_piston_pusher_left.png",
|
||||
"mesecons_piston_pusher_right.png",
|
||||
"mesecons_piston_pusher_back.png",
|
||||
"mesecons_piston_pusher_front_sticky.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
corresponding_piston = "mesecons_pistons:piston_sticky_on",
|
||||
selection_box = piston_pusher_box,
|
||||
node_box = piston_pusher_box,
|
||||
})
|
||||
|
||||
--
|
||||
--
|
||||
-- UP
|
||||
--
|
||||
--
|
||||
|
||||
local piston_up_pusher_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-2/16, -.5 - pt, -2/16, 2/16, .5 - pt, 2/16},
|
||||
{-.5 , .5 - pt, -.5 , .5 , .5 , .5},
|
||||
}
|
||||
}
|
||||
|
||||
local piston_up_on_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-.5, -.5, -.5 , .5, .5-pt, .5}
|
||||
}
|
||||
}
|
||||
|
||||
-- Normal
|
||||
|
||||
local pistonspec_normal_up = {
|
||||
offname = "mesecons_pistons:piston_up_normal_off",
|
||||
onname = "mesecons_pistons:piston_up_normal_on",
|
||||
dir = {x = 0, y = 1, z = 0},
|
||||
pusher = "mesecons_pistons:piston_up_pusher_normal"
|
||||
}
|
||||
|
||||
-- offstate
|
||||
minetest.register_node("mesecons_pistons:piston_up_normal_off", {
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_front.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_left.png^[transformR270",
|
||||
"mesecons_piston_right.png^[transformR90",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_top.png^[transformR180",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
mesecons_piston = pistonspec_normal_up,
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- onstate
|
||||
minetest.register_node("mesecons_pistons:piston_up_normal_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_on_front.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_left.png^[transformR270",
|
||||
"mesecons_piston_right.png^[transformR90",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_top.png^[transformR180",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
after_dig_node = piston_remove_pusher,
|
||||
node_box = piston_up_on_box,
|
||||
selection_box = piston_up_on_box,
|
||||
mesecons_piston = pistonspec_normal_up,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- pusher
|
||||
minetest.register_node("mesecons_pistons:piston_up_pusher_normal", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_front.png",
|
||||
"mesecons_piston_pusher_back.png",
|
||||
"mesecons_piston_pusher_left.png^[transformR270",
|
||||
"mesecons_piston_pusher_right.png^[transformR90",
|
||||
"mesecons_piston_pusher_bottom.png",
|
||||
"mesecons_piston_pusher_top.png^[transformR180",
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
corresponding_piston = "mesecons_pistons:piston_up_normal_on",
|
||||
selection_box = piston_up_pusher_box,
|
||||
node_box = piston_up_pusher_box,
|
||||
})
|
||||
|
||||
|
||||
|
||||
-- Sticky
|
||||
|
||||
|
||||
local pistonspec_sticky_up = {
|
||||
offname = "mesecons_pistons:piston_up_sticky_off",
|
||||
onname = "mesecons_pistons:piston_up_sticky_on",
|
||||
dir = {x = 0, y = 1, z = 0},
|
||||
pusher = "mesecons_pistons:piston_up_pusher_sticky",
|
||||
sticky = true
|
||||
}
|
||||
|
||||
-- offstate
|
||||
minetest.register_node("mesecons_pistons:piston_up_sticky_off", {
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_front_sticky.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_left.png^[transformR270",
|
||||
"mesecons_piston_right.png^[transformR90",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_top.png^[transformR180",
|
||||
"mesecons_piston_tb.png"
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_sticky_off",
|
||||
mesecons_piston = pistonspec_sticky_up,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- onstate
|
||||
minetest.register_node("mesecons_pistons:piston_up_sticky_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_on_front.png",
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_left.png^[transformR270",
|
||||
"mesecons_piston_right.png^[transformR90",
|
||||
"mesecons_piston_bottom.png",
|
||||
"mesecons_piston_top.png^[transformR180",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
after_dig_node = piston_remove_pusher,
|
||||
node_box = piston_up_on_box,
|
||||
selection_box = piston_up_on_box,
|
||||
mesecons_piston = pistonspec_sticky_up,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_up_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- pusher
|
||||
minetest.register_node("mesecons_pistons:piston_up_pusher_sticky", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_front_sticky.png",
|
||||
"mesecons_piston_pusher_back.png",
|
||||
"mesecons_piston_pusher_left.png^[transformR270",
|
||||
"mesecons_piston_pusher_right.png^[transformR90",
|
||||
"mesecons_piston_pusher_bottom.png",
|
||||
"mesecons_piston_pusher_top.png^[transformR180",
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
corresponding_piston = "mesecons_pistons:piston_up_sticky_on",
|
||||
selection_box = piston_up_pusher_box,
|
||||
node_box = piston_up_pusher_box,
|
||||
})
|
||||
|
||||
--
|
||||
--
|
||||
-- DOWN
|
||||
--
|
||||
--
|
||||
|
||||
local piston_down_pusher_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-2/16, -.5 + pt, -2/16, 2/16, .5 + pt, 2/16},
|
||||
{-.5 , -.5 , -.5 , .5 , -.5 + pt, .5},
|
||||
}
|
||||
}
|
||||
|
||||
local piston_down_on_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-.5, -.5+pt, -.5 , .5, .5, .5}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- Normal
|
||||
|
||||
local pistonspec_normal_down = {
|
||||
offname = "mesecons_pistons:piston_down_normal_off",
|
||||
onname = "mesecons_pistons:piston_down_normal_on",
|
||||
dir = {x = 0, y = -1, z = 0},
|
||||
pusher = "mesecons_pistons:piston_down_pusher_normal",
|
||||
}
|
||||
|
||||
-- offstate
|
||||
minetest.register_node("mesecons_pistons:piston_down_normal_off", {
|
||||
tiles = {
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_pusher_front.png",
|
||||
"mesecons_piston_left.png^[transformR90",
|
||||
"mesecons_piston_right.png^[transformR270",
|
||||
"mesecons_piston_bottom.png^[transformR180",
|
||||
"mesecons_piston_top.png",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
mesecons_piston = pistonspec_normal_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- onstate
|
||||
minetest.register_node("mesecons_pistons:piston_down_normal_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_on_front.png",
|
||||
"mesecons_piston_left.png^[transformR90",
|
||||
"mesecons_piston_right.png^[transformR270",
|
||||
"mesecons_piston_bottom.png^[transformR180",
|
||||
"mesecons_piston_top.png",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_normal_off",
|
||||
after_dig_node = piston_remove_pusher,
|
||||
node_box = piston_down_on_box,
|
||||
selection_box = piston_down_on_box,
|
||||
mesecons_piston = pistonspec_normal_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- pusher
|
||||
minetest.register_node("mesecons_pistons:piston_down_pusher_normal", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_back.png",
|
||||
"mesecons_piston_pusher_front.png",
|
||||
"mesecons_piston_pusher_left.png^[transformR90",
|
||||
"mesecons_piston_pusher_right.png^[transformR270",
|
||||
"mesecons_piston_pusher_bottom.png^[transformR180",
|
||||
"mesecons_piston_pusher_top.png",
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
corresponding_piston = "mesecons_pistons:piston_down_normal_on",
|
||||
selection_box = piston_down_pusher_box,
|
||||
node_box = piston_down_pusher_box,
|
||||
})
|
||||
|
||||
-- Sticky
|
||||
|
||||
local pistonspec_sticky_down = {
|
||||
onname = "mesecons_pistons:piston_down_sticky_on",
|
||||
offname = "mesecons_pistons:piston_down_sticky_off",
|
||||
dir = {x = 0, y = -1, z = 0},
|
||||
pusher = "mesecons_pistons:piston_down_pusher_sticky",
|
||||
sticky = true
|
||||
}
|
||||
|
||||
-- offstate
|
||||
minetest.register_node("mesecons_pistons:piston_down_sticky_off", {
|
||||
tiles = {
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_pusher_front_sticky.png",
|
||||
"mesecons_piston_left.png^[transformR90",
|
||||
"mesecons_piston_right.png^[transformR270",
|
||||
"mesecons_piston_bottom.png^[transformR180",
|
||||
"mesecons_piston_top.png",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_sticky_off",
|
||||
mesecons_piston = pistonspec_sticky_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_on = piston_on,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- onstate
|
||||
minetest.register_node("mesecons_pistons:piston_down_sticky_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_back.png",
|
||||
"mesecons_piston_on_front.png",
|
||||
"mesecons_piston_left.png^[transformR90",
|
||||
"mesecons_piston_right.png^[transformR270",
|
||||
"mesecons_piston_bottom.png^[transformR180",
|
||||
"mesecons_piston_top.png",
|
||||
},
|
||||
inventory_image = "mesecons_piston_top.png",
|
||||
wield_image = "mesecons_piston_top.png",
|
||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
drop = "mesecons_pistons:piston_sticky_off",
|
||||
after_dig_node = piston_remove_pusher,
|
||||
node_box = piston_down_on_box,
|
||||
selection_box = piston_down_on_box,
|
||||
mesecons_piston = pistonspec_sticky_down,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector={
|
||||
action_off = piston_off,
|
||||
rules = piston_down_rules,
|
||||
}}
|
||||
})
|
||||
|
||||
-- pusher
|
||||
minetest.register_node("mesecons_pistons:piston_down_pusher_sticky", {
|
||||
drawtype = "nodebox",
|
||||
tiles = {
|
||||
"mesecons_piston_pusher_back.png",
|
||||
"mesecons_piston_pusher_front_sticky.png",
|
||||
"mesecons_piston_pusher_left.png^[transformR90",
|
||||
"mesecons_piston_pusher_right.png^[transformR270",
|
||||
"mesecons_piston_pusher_bottom.png^[transformR180",
|
||||
"mesecons_piston_pusher_top.png",
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
diggable = false,
|
||||
corresponding_piston = "mesecons_pistons:piston_down_sticky_on",
|
||||
selection_box = piston_down_pusher_box,
|
||||
node_box = piston_down_pusher_box,
|
||||
})
|
||||
|
||||
|
||||
-- Register pushers as stoppers if they would be seperated from the piston
|
||||
local piston_pusher_get_stopper = function (node, dir, stack, stackid)
|
||||
if (stack[stackid + 1]
|
||||
and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].corresponding_piston
|
||||
and stack[stackid + 1].node.param2 == node.param2)
|
||||
or (stack[stackid - 1]
|
||||
and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].corresponding_piston
|
||||
and stack[stackid - 1].node.param2 == node.param2) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local piston_pusher_up_down_get_stopper = function (node, dir, stack, stackid)
|
||||
if (stack[stackid + 1]
|
||||
and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].corresponding_piston)
|
||||
or (stack[stackid - 1]
|
||||
and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].corresponding_piston) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_normal", piston_pusher_get_stopper)
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_pusher_sticky", piston_pusher_get_stopper)
|
||||
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal", piston_pusher_up_down_get_stopper)
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky", piston_pusher_up_down_get_stopper)
|
||||
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal", piston_pusher_up_down_get_stopper)
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky", piston_pusher_up_down_get_stopper)
|
||||
|
||||
|
||||
-- Register pistons as stoppers if they would be seperated from the stopper
|
||||
local piston_up_down_get_stopper = function (node, dir, stack, stackid)
|
||||
if (stack[stackid + 1]
|
||||
and stack[stackid + 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher)
|
||||
or (stack[stackid - 1]
|
||||
and stack[stackid - 1].node.name == minetest.registered_nodes[node.name].mesecons_piston.pusher) then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local piston_get_stopper = function (node, dir, stack, stackid)
|
||||
pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
dir = piston_get_direction(pistonspec.dir, node)
|
||||
local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir)
|
||||
local pushernode = minetest.env:get_node(pusherpos)
|
||||
|
||||
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
|
||||
for _, s in ipairs(stack) do
|
||||
if mesecon:cmpPos(s.pos, pusherpos) -- pusher is also to be pushed
|
||||
and s.node.param2 == node.param2 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_get_stopper)
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_get_stopper)
|
||||
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_normal_on", piston_up_down_get_stopper)
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_up_sticky_on", piston_up_down_get_stopper)
|
||||
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_normal_on", piston_up_down_get_stopper)
|
||||
mesecon:register_mvps_stopper("mesecons_pistons:piston_down_sticky_on", piston_up_down_get_stopper)
|
||||
|
||||
--craft recipes
|
||||
minetest.register_craft({
|
||||
output = 'mesecons_pistons:piston_normal_off',
|
||||
recipe = {
|
||||
{"group:wood", "group:wood", "group:wood"},
|
||||
{"default:cobble", "default:steel_ingot", "default:cobble"},
|
||||
{"default:cobble", "default:redstone_dust", "default:cobble"},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "mesecons_pistons:piston_sticky_off",
|
||||
recipe = {
|
||||
{"mesecons_materials:glue"},
|
||||
{"mesecons_pistons:piston_normal_off"},
|
||||
}
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
mesecons
|
|
@ -1,122 +0,0 @@
|
|||
local pp_box_off = {
|
||||
type = "fixed",
|
||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
|
||||
}
|
||||
|
||||
local pp_box_on = {
|
||||
type = "fixed",
|
||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
|
||||
}
|
||||
|
||||
pp_on_timer = function (pos, elapsed)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local ppspec = minetest.registered_nodes[node.name].pressureplate
|
||||
|
||||
-- This is a workaround for a strange bug that occurs when the server is started
|
||||
-- For some reason the first time on_timer is called, the pos is wrong
|
||||
if not ppspec then return end
|
||||
|
||||
local objs = minetest.env:get_objects_inside_radius(pos, 1)
|
||||
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
|
||||
|
||||
if objs[1] == nil and node.name == ppspec.onstate then
|
||||
minetest.env:add_node(pos, {name = ppspec.offstate})
|
||||
mesecon:receptor_off(pos)
|
||||
-- force deactivation of mesecon two blocks below (hacky)
|
||||
if not mesecon:connected_to_receptor(two_below) then
|
||||
mesecon:turnoff(two_below)
|
||||
end
|
||||
else
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
if objpos.y > pos.y-1 and objpos.y < pos.y then
|
||||
minetest.env:add_node(pos, {name=ppspec.onstate})
|
||||
mesecon:receptor_on(pos)
|
||||
-- force activation of mesecon two blocks below (hacky)
|
||||
mesecon:turnon(two_below)
|
||||
end
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Register a Pressure Plate
|
||||
-- offstate: name of the pressure plate when inactive
|
||||
-- onstate: name of the pressure plate when active
|
||||
-- description: description displayed in the player's inventory
|
||||
-- tiles_off: textures of the pressure plate when inactive
|
||||
-- tiles_on: textures of the pressure plate when active
|
||||
-- image: inventory and wield image of the pressure plate
|
||||
-- recipe: crafting recipe of the pressure plate
|
||||
|
||||
function mesecon:register_pressure_plate(offstate, onstate, description, texture_off, texture_on, recipe)
|
||||
local ppspec = {
|
||||
offstate = offstate,
|
||||
onstate = onstate
|
||||
}
|
||||
|
||||
minetest.register_node(offstate, {
|
||||
drawtype = "nodebox",
|
||||
tiles = {texture_off},
|
||||
wield_image = texture_off,
|
||||
paramtype = "light",
|
||||
selection_box = pp_box_off,
|
||||
node_box = pp_box_off,
|
||||
groups = {snappy = 2, oddly_breakable_by_hand = 3},
|
||||
description = description,
|
||||
pressureplate = ppspec,
|
||||
on_timer = pp_on_timer,
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node(onstate, {
|
||||
drawtype = "nodebox",
|
||||
tiles = {texture_on},
|
||||
paramtype = "light",
|
||||
selection_box = pp_box_on,
|
||||
node_box = pp_box_on,
|
||||
groups = {snappy = 2, oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
|
||||
drop = offstate,
|
||||
pressureplate = ppspec,
|
||||
on_timer = pp_on_timer,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}},
|
||||
on_construct = function(pos)
|
||||
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
|
||||
if not mesecon:connected_to_receptor(two_below) then
|
||||
mesecon:turnoff(two_below)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = offstate,
|
||||
recipe = recipe,
|
||||
})
|
||||
end
|
||||
|
||||
mesecon:register_pressure_plate(
|
||||
"mesecons_pressureplates:pressure_plate_wood_off",
|
||||
"mesecons_pressureplates:pressure_plate_wood_on",
|
||||
"Wooden Pressure Plate",
|
||||
"default_wood.png",
|
||||
"default_wood.png",
|
||||
{{"default:wood", "default:wood"}})
|
||||
|
||||
mesecon:register_pressure_plate(
|
||||
"mesecons_pressureplates:pressure_plate_stone_off",
|
||||
"mesecons_pressureplates:pressure_plate_stone_on",
|
||||
"Stone Pressure Plate",
|
||||
"default_stone.png",
|
||||
"default_stone.png",
|
||||
{{"default:cobble", "default:cobble"}})
|
|
@ -1,2 +0,0 @@
|
|||
mesecons
|
||||
mesecons_materials
|
|
@ -1,88 +0,0 @@
|
|||
local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 } -- Solar Pannel
|
||||
|
||||
-- Solar Panel
|
||||
minetest.register_node("mesecons_solarpanel:solar_panel_on", {
|
||||
drawtype = "nodebox",
|
||||
tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png",
|
||||
"jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
|
||||
wield_image = "jeija_solar_panel.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
drop = "mesecons_solarpanel:solar_panel_off",
|
||||
groups = {dig_immediate=3, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.on
|
||||
}}
|
||||
})
|
||||
|
||||
-- Solar Panel
|
||||
minetest.register_node("mesecons_solarpanel:solar_panel_off", {
|
||||
drawtype = "nodebox",
|
||||
tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png",
|
||||
"jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
|
||||
wield_image = "jeija_solar_panel.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
is_ground_content = true,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = boxes
|
||||
},
|
||||
groups = {dig_immediate=3},
|
||||
description="Solar Panel",
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
mesecons = {receptor = {
|
||||
state = mesecon.state.off
|
||||
}}
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = '"mesecons_solarpanel:solar_panel_off" 1',
|
||||
recipe = {
|
||||
{'default:glass', 'default:glass', 'default:glass'},
|
||||
{'default:glass', 'default:glass', 'default:glass'},
|
||||
{'default:restone_dust', 'default:restone_dust', 'default:restone_dust'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"mesecons_solarpanel:solar_panel_off"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local light = minetest.env:get_node_light(pos, nil)
|
||||
|
||||
if light >= 12 then
|
||||
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
|
||||
mesecon:receptor_on(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_abm(
|
||||
{nodenames = {"mesecons_solarpanel:solar_panel_on"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local light = minetest.env:get_node_light(pos, nil)
|
||||
|
||||
if light < 12 then
|
||||
minetest.env:set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
|
||||
mesecon:receptor_off(pos)
|
||||
end
|
||||
end,
|
||||
})
|
|
@ -1 +0,0 @@
|
|||
-- place texture packs for mesecons into the textures folder here
|
Before Width: | Height: | Size: 253 B |
Before Width: | Height: | Size: 497 B |
Before Width: | Height: | Size: 418 B |
Before Width: | Height: | Size: 323 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 1.0 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 517 B |
Before Width: | Height: | Size: 687 B |
Before Width: | Height: | Size: 454 B |
Before Width: | Height: | Size: 540 B |
Before Width: | Height: | Size: 305 B |
Before Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 514 B |
Before Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 224 B |
Before Width: | Height: | Size: 213 B |
Before Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 232 B |
Before Width: | Height: | Size: 226 B |
Before Width: | Height: | Size: 136 B |
Before Width: | Height: | Size: 622 B |
Before Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 436 B |
Before Width: | Height: | Size: 437 B |
Before Width: | Height: | Size: 440 B |
Before Width: | Height: | Size: 575 B |