Update Bluestone

This commit is contained in:
MoNTE48 2019-06-22 12:22:18 +02:00
parent a51369d706
commit a1ba95d0a2
42 changed files with 2473 additions and 2746 deletions

View File

@ -1 +0,0 @@
0.41 DEV

View File

@ -0,0 +1,101 @@
mesecon.queue.actions={} -- contains all ActionQueue actions
function mesecon.queue:add_function(name, func)
mesecon.queue.funcs[name] = func
end
-- If add_action with twice the same overwritecheck and same position are called, the first one is overwritten
-- use overwritecheck nil to never overwrite, but just add the event to the queue
-- priority specifies the order actions are executed within one globalstep, highest first
-- should be between 0 and 1
function mesecon.queue:add_action(pos, func, params, time, overwritecheck, priority)
-- Create Action Table:
time = time or 0 -- time <= 0 --> execute, time > 0 --> wait time until execution
priority = priority or 1
local action = { pos=mesecon.tablecopy(pos),
func=func,
params=mesecon.tablecopy(params or {}),
time=time,
owcheck=(overwritecheck and mesecon.tablecopy(overwritecheck)) or nil,
priority=priority}
local toremove = nil
-- Otherwise, add the action to the queue
if overwritecheck then -- check if old action has to be overwritten / removed:
for i, ac in ipairs(mesecon.queue.actions) do
if(vector.equals(pos, ac.pos)
and mesecon.cmpAny(overwritecheck, ac.owcheck)) then
toremove = i
break
end
end
end
if (toremove ~= nil) then
table.remove(mesecon.queue.actions, toremove)
end
table.insert(mesecon.queue.actions, action)
end
-- execute the stored functions on a globalstep
-- if however, the pos of a function is not loaded (get_node_or_nil == nil), do NOT execute the function
-- this makes sure that resuming mesecons circuits when restarting minetest works fine
-- However, even that does not work in some cases, that's why we delay the time the globalsteps
-- start to be execute by 5 seconds
local get_highest_priority = function (actions)
local highestp = -1
local highesti
for i, ac in ipairs(actions) do
if ac.priority > highestp then
highestp = ac.priority
highesti = i
end
end
return highesti
end
local m_time = 0
local resumetime = mesecon.setting("resumetime", 4)
minetest.register_globalstep(function (dtime)
m_time = m_time + dtime
-- don't even try if server has not been running for XY seconds; resumetime = time to wait
-- after starting the server before processing the ActionQueue, don't set this too low
if (m_time < resumetime) then return end
local actions = mesecon.tablecopy(mesecon.queue.actions)
local actions_now={}
mesecon.queue.actions = {}
-- sort actions into two categories:
-- those toexecute now (actions_now) and those to execute later (mesecon.queue.actions)
for i, ac in ipairs(actions) do
if ac.time > 0 then
ac.time = ac.time - dtime -- executed later
table.insert(mesecon.queue.actions, ac)
else
table.insert(actions_now, ac)
end
end
while(#actions_now > 0) do -- execute highest priorities first, until all are executed
local hp = get_highest_priority(actions_now)
mesecon.queue:execute(actions_now[hp])
table.remove(actions_now, hp)
end
end)
function mesecon.queue:execute(action)
mesecon.queue.funcs[action.func](action.pos, unpack(action.params))
end
-- Store and read the ActionQueue to / from a file
-- so that upcoming actions are remembered when the game
-- is restarted
mesecon.queue.actions = mesecon.file2table("mesecon_actionqueue")
minetest.register_on_shutdown(function()
mesecon.table2file("mesecon_actionqueue", mesecon.queue.actions)
end)

View File

@ -39,53 +39,26 @@
-- } -- }
--} --}
-- PUBLIC VARIABLES -- PUBLIC VARIABLES
mesecon={} -- contains all functions and all global variables mesecon={} -- contains all functions and all global variables
mesecon.actions_on={} -- Saves registered function callbacks for mesecon on | DEPRECATED mesecon.queue={} -- contains the ActionQueue
mesecon.actions_off={} -- Saves registered function callbacks for mesecon off | DEPRECATED mesecon.queue.funcs={} -- contains all ActionQueue functions
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
local wpath = minetest.get_worldpath()
local function read_file(fn)
local f = io.open(fn, "r")
if f==nil then return {} end
local t = f:read("*all")
f:close()
if t=="" or t==nil then return {} end
return minetest.deserialize(t)
end
local function write_file(fn, tbl)
local f = io.open(fn, "w")
f:write(minetest.serialize(tbl))
f:close()
end
mesecon.to_update = read_file(wpath.."/mesecon_to_update")
mesecon.r_to_update = read_file(wpath.."/mesecon_r_to_update")
minetest.register_on_shutdown(function()
write_file(wpath.."/mesecon_to_update",mesecon.to_update)
write_file(wpath.."/mesecon_r_to_update",mesecon.r_to_update)
end)
-- Settings -- Settings
dofile(minetest.get_modpath("mesecons").."/settings.lua") dofile(minetest.get_modpath("mesecons").."/settings.lua")
-- Presets (eg default rules)
dofile(minetest.get_modpath("mesecons").."/presets.lua");
-- Utilities like comparing positions, -- Utilities like comparing positions,
-- adding positions and rules, -- adding positions and rules,
-- mostly things that make the source look cleaner -- mostly things that make the source look cleaner
dofile(minetest.get_modpath("mesecons").."/util.lua"); dofile(minetest.get_modpath("mesecons").."/util.lua");
-- Presets (eg default rules)
dofile(minetest.get_modpath("mesecons").."/presets.lua");
-- The ActionQueue
-- Saves all the actions that have to be execute in the future
dofile(minetest.get_modpath("mesecons").."/actionqueue.lua");
-- Internal stuff -- Internal stuff
-- This is the most important file -- This is the most important file
-- it handles signal transmission and basically everything else -- it handles signal transmission and basically everything else
@ -96,51 +69,61 @@ dofile(minetest.get_modpath("mesecons").."/internal.lua");
-- API -- API
-- these are the only functions you need to remember -- these are the only functions you need to remember
function mesecon:receptor_on_i(pos, rules) mesecon.queue:add_function("receptor_on", function (pos, rules)
rules = rules or mesecon.rules.default rules = rules or mesecon.rules.default
for _, rule in ipairs(mesecon:flattenrules(rules)) do -- if area (any of the rule targets) is not loaded, keep trying and call this again later
local np = mesecon:addPosRule(pos, rule) for _, rule in ipairs(mesecon.flattenrules(rules)) do
local link, rulename = mesecon:rules_link(pos, np, rules) local np = vector.add(pos, rule)
if link then -- if area is not loaded, keep trying
mesecon:turnon(np, rulename) if minetest.get_node_or_nil(np) == nil then
end mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
return
end end
end end
function mesecon:receptor_on(pos, rules) -- execute action
if MESECONS_GLOBALSTEP then for _, rule in ipairs(mesecon.flattenrules(rules)) do
rules = rules or mesecon.rules.default local np = vector.add(pos, rule)
mesecon.r_to_update[#mesecon.r_to_update+1]={pos=pos, rules=rules, action="on"} local rulenames = mesecon.rules_link_rule_all(pos, rule)
else for _, rulename in ipairs(rulenames) do
mesecon:receptor_on_i(pos, rules) mesecon.turnon(np, rulename)
end
end end
end)
function mesecon.receptor_on(pos, rules)
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
end end
function mesecon:receptor_off_i(pos, rules) mesecon.queue:add_function("receptor_off", function (pos, rules)
rules = rules or mesecon.rules.default rules = rules or mesecon.rules.default
for _, rule in ipairs(mesecon:flattenrules(rules)) do -- if area (any of the rule targets) is not loaded, keep trying and call this again later
local np = mesecon:addPosRule(pos, rule) for _, rule in ipairs(mesecon.flattenrules(rules)) do
local link, rulename = mesecon:rules_link(pos, np, rules) local np = vector.add(pos, rule)
if link then if minetest.get_node_or_nil(np) == nil then
if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
mesecon:turnoff(np, rulename) return
else
mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off)
end
end
end end
end end
function mesecon:receptor_off(pos, rules) for _, rule in ipairs(mesecon.flattenrules(rules)) do
if MESECONS_GLOBALSTEP then local np = vector.add(pos, rule)
rules = rules or mesecon.rules.default local rulenames = mesecon.rules_link_rule_all(pos, rule)
mesecon.r_to_update[#mesecon.r_to_update+1]={pos=pos, rules=rules, action="off"} for _, rulename in ipairs(rulenames) do
if not mesecon.connected_to_receptor(np, mesecon.invertRule(rule)) then
mesecon.turnoff(np, rulename)
else else
mesecon:receptor_off_i(pos, rules) mesecon.changesignal(np, minetest.get_node(np), rulename, mesecon.state.off, 2)
end
end end
end end
end)
function mesecon.receptor_off(pos, rules)
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
end
--The actual wires --The actual wires
dofile(minetest.get_modpath("mesecons").."/wires.lua"); dofile(minetest.get_modpath("mesecons").."/wires.lua");

File diff suppressed because it is too large Load Diff

View File

@ -15,6 +15,8 @@ mesecon.rules.default =
{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.pplate = mesecon.mergetable(mesecon.rules.default, {{x=0, y=-2, z=0}})
mesecon.rules.buttonlike = mesecon.rules.buttonlike =
{{x = 1, y = 0, z = 0}, {{x = 1, y = 0, z = 0},
{x = 1, y = 1, z = 0}, {x = 1, y = 1, z = 0},
@ -29,14 +31,22 @@ mesecon.rules.flat =
{x = 0, y = 0, z = 1}, {x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1}} {x = 0, y = 0, z =-1}}
mesecon.rules.alldirs =
{{x= 1, y= 0, z= 0},
{x=-1, y= 0, z= 0},
{x= 0, y= 1, z= 0},
{x= 0, y=-1, z= 0},
{x= 0, y= 0, z= 1},
{x= 0, y= 0, z=-1}}
mesecon.rules.buttonlike_get = function(node) mesecon.rules.buttonlike_get = function(node)
local rules = mesecon.rules.buttonlike local rules = mesecon.rules.buttonlike
if node.param2 == 2 then if node.param2 == 2 then
rules=mesecon:rotate_rules_left(rules) rules=mesecon.rotate_rules_left(rules)
elseif node.param2 == 3 then elseif node.param2 == 3 then
rules=mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
elseif node.param2 == 0 then elseif node.param2 == 0 then
rules=mesecon:rotate_rules_right(rules) rules=mesecon.rotate_rules_right(rules)
end end
return rules return rules
end end

View File

@ -1,38 +1,100 @@
-- Dig and place services
mesecon.on_placenode = function (pos, node) mesecon.on_placenode = function (pos, node)
if mesecon:is_receptor_on(node.name) then mesecon.update_autoconnect(pos, node)
mesecon:receptor_on(pos, mesecon:receptor_get_rules(node))
elseif mesecon:is_powered(pos) then -- Receptors: Send on signal when active
if mesecon:is_conductor(node.name) then if mesecon.is_receptor_on(node.name) then
mesecon:turnon (pos) mesecon.receptor_on(pos, mesecon.receptor_get_rules(node))
--mesecon:receptor_on (pos, mesecon:conductor_get_rules(node)) end
else
mesecon:changesignal(pos, node, mesecon:effector_get_rules(node), "on") -- Conductors: Send turnon signal when powered or replace by respective offstate conductor
mesecon:activate(pos, node) -- if placed conductor is an onstate one
if mesecon.is_conductor(node.name) then
local sources = mesecon.is_powered(pos)
if sources then
-- also call receptor_on if itself is powered already, so that neighboring
-- conductors will be activated (when pushing an on-conductor with a piston)
for _, s in ipairs(sources) do
local rule = vector.subtract(pos, s)
mesecon.turnon(pos, rule)
end
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
elseif mesecon.is_conductor_on(node) then
minetest.swap_node(pos, {name = mesecon.get_conductor_off(node)})
end
end
-- Effectors: Send changesignal and activate or deactivate
if mesecon.is_effector(node.name) then
local powered_rules = {}
local unpowered_rules = {}
-- for each input rule, check if powered
for _, r in ipairs(mesecon.effector_get_rules(node)) do
local powered = mesecon.is_powered(pos, r)
if powered then table.insert(powered_rules, r)
else table.insert(unpowered_rules, r) end
local state = powered and mesecon.state.on or mesecon.state.off
mesecon.changesignal(pos, node, r, state, 1)
end
if (#powered_rules > 0) then
for _, r in ipairs(powered_rules) do
mesecon.activate(pos, node, r, 1)
end
else
for _, r in ipairs(unpowered_rules) do
mesecon.deactivate(pos, node, r, 1)
end
end end
elseif mesecon:is_conductor_on(node.name) then
minetest.swap_node(pos, {name = mesecon:get_conductor_off(node.name)})
elseif mesecon:is_effector_on (node.name) then
mesecon:deactivate(pos, node)
end end
end end
mesecon.on_dignode = function (pos, node) mesecon.on_dignode = function (pos, node)
if mesecon:is_conductor_on(node.name) then if mesecon.is_conductor_on(node) then
mesecon:receptor_off(pos, mesecon:conductor_get_rules(node)) mesecon.receptor_off(pos, mesecon.conductor_get_rules(node))
elseif mesecon:is_receptor_on(node.name) then elseif mesecon.is_receptor_on(node.name) then
mesecon:receptor_off(pos, mesecon:receptor_get_rules(node)) mesecon.receptor_off(pos, mesecon.receptor_get_rules(node))
end end
mesecon.queue:add_action(pos, "update_autoconnect", {node})
end end
minetest.register_abm({ mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect)
nodenames = {"group:overheat"},
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
meta:set_int("heat",0)
end,
})
minetest.register_on_placenode(mesecon.on_placenode) minetest.register_on_placenode(mesecon.on_placenode)
minetest.register_on_dignode(mesecon.on_dignode) minetest.register_on_dignode(mesecon.on_dignode)
-- Overheating service for fast circuits
-- returns true if heat is too high
mesecon.do_overheat = function(pos)
local meta = minetest.get_meta(pos)
local heat = meta:get_int("heat") or 0
heat = heat + 1
meta:set_int("heat", heat)
if heat < mesecon.setting("overheat_max", 20) then
mesecon.queue:add_action(pos, "cooldown", {}, 1, nil, 0)
else
return true
end
return false
end
mesecon.queue:add_function("cooldown", function (pos)
if minetest.get_item_group(minetest.get_node(pos).name, "overheat") == 0 then
return -- node has been moved, this one does not use overheating - ignore
end
local meta = minetest.get_meta(pos)
local heat = meta:get_int("heat")
if (heat > 0) then
meta:set_int("heat", heat - 1)
end
end)

View File

@ -1,9 +1,15 @@
-- SETTINGS -- SETTINGS
BLINKY_PLANT_INTERVAL = 3 function mesecon.setting(setting, default)
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires if type(default) == "boolean" then
PRESSURE_PLATE_INTERVAL = 0.1 local read = minetest.setting_getbool("mesecon."..setting)
OBJECT_DETECTOR_RADIUS = 6 if read == nil then
PISTON_MAXIMUM_PUSH = 15 return default
MOVESTONE_MAXIMUM_PUSH = 100 else
MESECONS_GLOBALSTEP = true -- true = receptors/effectors won't be updated return read
-- until next globalstep, decreases server load end
elseif type(default) == "string" then
return minetest.setting_get("mesecon."..setting) or default
elseif type(default) == "number" then
return tonumber(minetest.setting_get("mesecon."..setting) or default)
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 B

View File

@ -1,24 +1,12 @@
function mesecon:move_node(pos, newpos) function mesecon.move_node(pos, newpos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.add_node(newpos, node) minetest.set_node(newpos, node)
minetest.get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end
--[[ new functions: function mesecon.flattenrules(allrules)
mesecon:flattenrules(allrules)
mesecon:rule2bit(findrule, allrules)
mesecon:rule2meta(findrule, allrules)
dec2bin(n)
mesecon:getstate(nodename, states)
mesecon:getbinstate(nodename, states)
mesecon:get_bit(binary, bit)
mesecon:set_bit(binary, bit, value)
mesecon:invertRule(r)
--]]
function mesecon:flattenrules(allrules)
--[[ --[[
{ {
{ {
@ -38,7 +26,7 @@ function mesecon:flattenrules(allrules)
local shallowrules = {} local shallowrules = {}
for _, metarule in ipairs( allrules) do for _, metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do for _, rule in ipairs(metarule ) do
table.insert(shallowrules, rule) table.insert(shallowrules, rule)
end end
end end
@ -53,62 +41,65 @@ function mesecon:flattenrules(allrules)
--]] --]]
end end
function mesecon:rule2bit(findrule, allrules) function mesecon.rule2bit(findrule, allrules)
--get the bit of the metarule the rule is in, or bit 1 --get the bit of the metarule the rule is in, or bit 1
if (allrules[1] and if (allrules[1] and
allrules[1].x) or allrules[1].x) or
not findrule then not findrule then
return 1 return 1
end end
for m,metarule in ipairs( allrules) do for m,metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do for _, rule in ipairs(metarule ) do
if mesecon:cmpPos(findrule, rule) then if vector.equals(findrule, rule) then
return m return m
end end
end end
end end
end end
function mesecon:rule2meta(findrule, allrules) function mesecon.rule2metaindex(findrule, allrules)
--get the metarule the rule is in, or allrules --get the metarule the rule is in, or allrules
if allrules[1].x then if allrules[1].x then
return allrules return nil
end end
if not(findrule) then if not(findrule) then
return mesecon:flattenrules(allrules) return mesecon.flattenrules(allrules)
end end
for m, metarule in ipairs( allrules) do for m, metarule in ipairs( allrules) do
for _, rule in ipairs(metarule ) do for _, rule in ipairs(metarule ) do
if mesecon:cmpPos(findrule, rule) then if vector.equals(findrule, rule) then
return metarule return m
end end
end end
end end
end end
local convert_base function mesecon.rule2meta(findrule, allrules)
if convert_base then if #allrules == 0 then return {} end
print(
"base2dec is tonumber(num,base1)\n".. local index = mesecon.rule2metaindex(findrule, allrules)
"commonlib needs dec2base(num,base2)\n".. if index == nil then
"and it needs base2base(num,base1,base2),\n".. if allrules[1].x then
"which is dec2base(tonumber(num,base1),base2)" return allrules
)
else else
function dec2bin(n) return {}
end
end
return allrules[index]
end
function mesecon.dec2bin(n)
local x, y = math.floor(n / 2), n % 2 local x, y = math.floor(n / 2), n % 2
if (n > 1) then if (n > 1) then
return dec2bin(x)..y return mesecon.dec2bin(x)..y
else else
return ""..y return ""..y
end end
end end
end
function mesecon:getstate(nodename, states) function mesecon.getstate(nodename, states)
for state, name in ipairs(states) do for state, name in ipairs(states) do
if name == nodename then if name == nodename then
return state return state
@ -117,48 +108,41 @@ function mesecon:getstate(nodename, states)
error(nodename.." doesn't mention itself in "..dump(states)) error(nodename.." doesn't mention itself in "..dump(states))
end end
function mesecon:getbinstate(nodename, states) function mesecon.getbinstate(nodename, states)
return dec2bin(mesecon:getstate(nodename, states)-1) return mesecon.dec2bin(mesecon.getstate(nodename, states)-1)
end end
function mesecon:get_bit(binary,bit) function mesecon.get_bit(binary,bit)
bit = bit or 1 bit = bit or 1
local c = binary:len()-(bit-1) local c = binary:len()-(bit-1)
return binary:sub(c,c) == "1" return binary:sub(c,c) == "1"
end end
function mesecon:set_bit(binary,bit,value) function mesecon.set_bit(binary,bit,value)
if value == "1" then if value == "1" then
if not mesecon:get_bit(binary,bit) then if not mesecon.get_bit(binary,bit) then
return dec2bin(tonumber(binary,2)+math.pow(2,bit-1)) return mesecon.dec2bin(tonumber(binary,2)+math.pow(2,bit-1))
end end
elseif value == "0" then elseif value == "0" then
if mesecon:get_bit(binary,bit) then if mesecon.get_bit(binary,bit) then
return dec2bin(tonumber(binary,2)-math.pow(2,bit-1)) return mesecon.dec2bin(tonumber(binary,2)-math.pow(2,bit-1))
end end
end end
return binary return binary
end end
function mesecon:invertRule(r) function mesecon.invertRule(r)
return {x = -r.x, y = -r.y, z = -r.z} return vector.multiply(r, -1)
end end
function mesecon:addPosRule(p, r) function mesecon.tablecopy(table) -- deep table copy
return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z} if type(table) ~= "table" then return table end -- no need to copy
end
function mesecon:cmpPos(p1, p2)
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
end
function mesecon:tablecopy(table) -- deep table copy
local newtable = {} local newtable = {}
for idx, item in pairs(table) do for idx, item in pairs(table) do
if type(item) == "table" then if type(item) == "table" then
newtable[idx] = mesecon:tablecopy(item) newtable[idx] = mesecon.tablecopy(item)
else else
newtable[idx] = item newtable[idx] = item
end end
@ -166,3 +150,126 @@ function mesecon:tablecopy(table) -- deep table copy
return newtable return newtable
end end
function mesecon.cmpAny(t1, t2)
if type(t1) ~= type(t2) then return false end
if type(t1) ~= "table" and type(t2) ~= "table" then return t1 == t2 end
for i, e in pairs(t1) do
if not mesecon.cmpAny(e, t2[i]) then return false end
end
return true
end
-- does not overwrite values; number keys (ipairs) are appended, not overwritten
function mesecon.mergetable(source, dest)
local rval = mesecon.tablecopy(dest)
for k, v in pairs(source) do
rval[k] = dest[k] or mesecon.tablecopy(v)
end
for i, v in ipairs(source) do
table.insert(rval, mesecon.tablecopy(v))
end
return rval
end
function mesecon.register_node(name, spec_common, spec_off, spec_on)
spec_common.drop = spec_common.drop or name .. "_off"
spec_common.__mesecon_basename = name
spec_on.__mesecon_state = "on"
spec_off.__mesecon_state = "off"
spec_on = mesecon.mergetable(spec_common, spec_on);
spec_off = mesecon.mergetable(spec_common, spec_off);
minetest.register_node(name .. "_on", spec_on)
minetest.register_node(name .. "_off", spec_off)
end
-- swap onstate and offstate nodes, returns new state
function mesecon.flipstate(pos, node)
local nodedef = minetest.registered_nodes[node.name]
local newstate
if (nodedef.__mesecon_state == "on") then newstate = "off" end
if (nodedef.__mesecon_state == "off") then newstate = "on" end
minetest.swap_node(pos, {name = nodedef.__mesecon_basename .. "_" .. newstate,
param2 = node.param2})
return newstate
end
-- File writing / reading utilities
local wpath = minetest.get_worldpath()
function mesecon.file2table(filename)
local f = io.open(wpath..DIR_DELIM..filename, "r")
if f == nil then return {} end
local t = f:read("*all")
f:close()
if t == "" or t == nil then return {} end
return minetest.deserialize(t)
end
function mesecon.table2file(filename, table)
local f = io.open(wpath..DIR_DELIM..filename, "w")
f:write(minetest.serialize(table))
f:close()
end
-- Forceloading: Force server to load area if node is nil
local BLOCKSIZE = 16
-- convert node position --> block hash
local function hash_blockpos(pos)
return minetest.hash_node_position({
x = math.floor(pos.x/BLOCKSIZE),
y = math.floor(pos.y/BLOCKSIZE),
z = math.floor(pos.z/BLOCKSIZE)
})
end
-- convert block hash --> node position
local function unhash_blockpos(hash)
return vector.multiply(minetest.get_position_from_hash(hash), BLOCKSIZE)
end
mesecon.forceloaded_blocks = {}
-- get node and force-load area
function mesecon.get_node_force(pos)
local hash = hash_blockpos(pos)
if mesecon.forceloaded_blocks[hash] == nil then
-- if no more forceload spaces are available, try again next time
if minetest.forceload_block(pos) then
mesecon.forceloaded_blocks[hash] = 0
end
else
mesecon.forceloaded_blocks[hash] = 0
end
return minetest.get_node_or_nil(pos)
end
minetest.register_globalstep(function (dtime)
for hash, time in pairs(mesecon.forceloaded_blocks) do
-- unload forceloaded blocks after 10 minutes without usage
if (time > mesecon.setting("forceload_timeout", 600)) then
minetest.forceload_free_block(unhash_blockpos(hash))
mesecon.forceloaded_blocks[hash] = nil
else
mesecon.forceloaded_blocks[hash] = time + dtime
end
end
end)
-- Store and read the forceloaded blocks to / from a file
-- so that those blocks are remembered when the game
-- is restarted
mesecon.forceloaded_blocks = mesecon.file2table("mesecon_forceloaded")
minetest.register_on_shutdown(function()
mesecon.table2file("mesecon_forceloaded", mesecon.forceloaded_blocks)
end)

View File

@ -1,238 +1,236 @@
-- naming scheme: wire:(xp)(zp)(xm)(zm)_on/off -- naming scheme: wire:(xp)(zp)(xm)(zm)(xpyp)(zpyp)(xmyp)(zmyp)_on/off
-- The conditions in brackets define whether there is a mesecon at that place or not -- where x= x direction, z= z direction, y= y direction, p = +1, m = -1, e.g. xpym = {x=1, y=-1, z=0}
-- 1 = there is one; 0 = there is none -- The (xp)/(zpyp)/.. statements shall be replaced by either 0 or 1
-- y always means y+ -- Where 0 means the wire has no visual connection to that direction and
-- 1 means that the wire visually connects to that other node.
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 } -- ## Update wire looks ##
-- #######################
box_xp = {1/16, -.5, -1/16, 8/16, -.5+1/64, 1/16} -- self_pos = pos of any mesecon node, from_pos = pos of conductor to getconnect for
box_zp = {-1/16, -.5, 1/16, 1/16, -.5+1/64, 8/16} local wire_getconnect = function (from_pos, self_pos)
box_xm = {-8/16, -.5, -1/16, -1/16, -.5+1/64, 1/16} local node = minetest.get_node(self_pos)
box_zm = {-1/16, -.5, -8/16, 1/16, -.5+1/64, -1/16} if minetest.registered_nodes[node.name]
and minetest.registered_nodes[node.name].mesecons then
-- rules of node to possibly connect to
local rules = {}
if (minetest.registered_nodes[node.name].mesecon_wire) then
rules = mesecon.rules.default
else
rules = mesecon.get_any_rules(node)
end
box_xpy = {.5-1/16, -.5+1/64, -1/16, .5, .4999+1/64, 1/16} for _, r in ipairs(mesecon.flattenrules(rules)) do
box_zpy = {-1/16, -.5+1/64, .5-1/16, 1/16, .4999+1/64, .5} if (vector.equals(vector.add(self_pos, r), from_pos)) then
box_xmy = {-.5, -.5+1/64, -1/16, -.5+1/16, .4999+1/64, 1/16} return true
box_zmy = {-1/16, -.5+1/64, -.5, 1/16, .4999+1/64, -.5+1/16} end
end
end
return false
end
-- Registering the wires -- Update this node
local wire_updateconnect = function (pos)
local connections = {}
for xp=0, 1 do for _, r in ipairs(mesecon.rules.default) do
for zp=0, 1 do if wire_getconnect(pos, vector.add(pos, r)) then
for xm=0, 1 do table.insert(connections, r)
for zm=0, 1 do end
for xpy=0, 1 do end
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 nid = {}
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm ).. for _, vec in ipairs(connections) do
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy) -- flat component
if vec.x == 1 then nid[0] = "1" end
if vec.z == 1 then nid[1] = "1" end
if vec.x == -1 then nid[2] = "1" end
if vec.z == -1 then nid[3] = "1" end
if nodeid == "00000000" then -- slopy component
groups = {dig_immediate = 3, mesecon_conductor_craftable=1} if vec.y == 1 then
wiredesc = "Mesecon" if vec.x == 1 then nid[4] = "1" end
else if vec.z == 1 then nid[5] = "1" end
groups = {dig_immediate = 3, not_in_creative_inventory = 1} if vec.x == -1 then nid[6] = "1" end
wiredesc = "Mesecons Wire (ID: "..nodeid..")" if vec.z == -1 then nid[7] = "1" end
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 = "Bluestone Dust",
drawtype = "nodebox",
tiles = tiles_off,
inventory_image = "default_bluestone_dust.png",
wield_image = "default_bluestone_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,
drop = "mesecons:wire_00000000_off",
mesecons = {conductor={
state = mesecon.state.off,
onstate = "mesecons:wire_"..nodeid.."_on"
}}
})
minetest.register_node("mesecons:wire_"..nodeid.."_on", {
description = "Bluestone Dust",
drawtype = "nodebox",
tiles = tiles_on,
inventory_image = "default_bluestone_dust.png",
wield_image = "default_bluestone_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,
drop = "mesecons:wire_00000000_off",
mesecons = {conductor={
state = mesecon.state.on,
offstate = "mesecons:wire_"..nodeid.."_off"
}}
})
end
end
end
end
end
end
end end
end end
-- Updating the wires: local nodeid = (nid[0] or "0")..(nid[1] or "0")..(nid[2] or "0")..(nid[3] or "0")
-- Place the right connection wire ..(nid[4] or "0")..(nid[5] or "0")..(nid[6] or "0")..(nid[7] or "0")
local state_suffix = string.find(minetest.get_node(pos).name, "_off") and "_off" or "_on"
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid..state_suffix})
end
local update_on_place_dig = function (pos, node) local update_on_place_dig = function (pos, node)
if minetest.registered_nodes[node.name] -- Update placed node (get_node again as it may have been dug)
and minetest.registered_nodes[node.name].mesecons then local nn = minetest.get_node(pos)
mesecon:update_autoconnect(pos) if (minetest.registered_nodes[nn.name])
end and (minetest.registered_nodes[nn.name].mesecon_wire) then
wire_updateconnect(pos)
end end
minetest.register_on_placenode(update_on_place_dig) -- Update nodes around it
minetest.register_on_dignode(update_on_place_dig) local rules = {}
if minetest.registered_nodes[node.name]
function mesecon:update_autoconnect(pos, secondcall, replace_old) and minetest.registered_nodes[node.name].mesecon_wire then
local xppos = {x=pos.x+1, y=pos.y, z=pos.z} rules = mesecon.rules.default
local zppos = {x=pos.x, y=pos.y, z=pos.z+1} else
local xmpos = {x=pos.x-1, y=pos.y, z=pos.z} rules = mesecon.get_any_rules(node)
local zmpos = {x=pos.x, y=pos.y, z=pos.z-1}
local xpympos = {x=pos.x+1, y=pos.y-1, z=pos.z}
local zpympos = {x=pos.x, y=pos.y-1, z=pos.z+1}
local xmympos = {x=pos.x-1, y=pos.y-1, z=pos.z}
local zmympos = {x=pos.x, y=pos.y-1, z=pos.z-1}
local xpypos = {x=pos.x+1, y=pos.y+1, z=pos.z}
local zpypos = {x=pos.x, y=pos.y+1, z=pos.z+1}
local xmypos = {x=pos.x-1, y=pos.y+1, z=pos.z}
local zmypos = {x=pos.x, y=pos.y+1, z=pos.z-1}
if secondcall == nil then
mesecon:update_autoconnect(xppos, true)
mesecon:update_autoconnect(zppos, true)
mesecon:update_autoconnect(xmpos, true)
mesecon:update_autoconnect(zmpos, true)
mesecon:update_autoconnect(xpypos, true)
mesecon:update_autoconnect(zpypos, true)
mesecon:update_autoconnect(xmypos, true)
mesecon:update_autoconnect(zmypos, true)
mesecon:update_autoconnect(xpympos, true)
mesecon:update_autoconnect(zpympos, true)
mesecon:update_autoconnect(xmympos, true)
mesecon:update_autoconnect(zmympos, true)
end
local nodename = minetest.get_node(pos).name
if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end
local xp, xm, zp, zm, xpy, zpy, xmy, zmy
if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end
if mesecon:rules_link_anydir(pos, xmpos) then xm = 1 else xm = 0 end
if mesecon:rules_link_anydir(pos, zppos) then zp = 1 else zp = 0 end
if mesecon:rules_link_anydir(pos, zmpos) then zm = 1 else zm = 0 end
if mesecon:rules_link_anydir(pos, xpympos) then xp = 1 end
if mesecon:rules_link_anydir(pos, xmympos) then xm = 1 end
if mesecon:rules_link_anydir(pos, zpympos) then zp = 1 end
if mesecon:rules_link_anydir(pos, zmympos) then zm = 1 end
if mesecon:rules_link_anydir(pos, xpypos) then xpy = 1 else xpy = 0 end
if mesecon:rules_link_anydir(pos, zpypos) then zpy = 1 else zpy = 0 end
if mesecon:rules_link_anydir(pos, xmypos) then xmy = 1 else xmy = 0 end
if mesecon:rules_link_anydir(pos, zmypos) then zmy = 1 else zmy = 0 end
if xpy == 1 then xp = 1 end
if zpy == 1 then zp = 1 end
if xmy == 1 then xm = 1 end
if zmy == 1 then zm = 1 end
local nodeid = tostring(xp )..tostring(zp )..tostring(xm )..tostring(zm )..
tostring(xpy)..tostring(zpy)..tostring(xmy)..tostring(zmy)
if string.find(nodename, "_off") ~= nil then
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
end
end end
if (not rules) then return end
for _, r in ipairs(mesecon.flattenrules(rules)) do
local np = vector.add(pos, r)
if minetest.registered_nodes[minetest.get_node(np).name]
and minetest.registered_nodes[minetest.get_node(np).name].mesecon_wire then
wire_updateconnect(np)
end
end
end
function mesecon.update_autoconnect(pos, node)
if (not node) then node = minetest.get_node(pos) end
update_on_place_dig(pos, node)
end
-- ############################
-- ## Wire node registration ##
-- ############################
-- Nodeboxes:
local box_center = {-1/16, -.5, -1/16, 1/16, -.5+1/16, 1/16}
local box_bump1 = { -2/16, -8/16, -2/16, 2/16, -13/32, 2/16 }
local nbox_nid =
{
[0] = {1/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}, -- x positive
[1] = {-1/16, -.5, 1/16, 1/16, -.5+1/16, 8/16}, -- z positive
[2] = {-8/16, -.5, -1/16, -1/16, -.5+1/16, 1/16}, -- x negative
[3] = {-1/16, -.5, -8/16, 1/16, -.5+1/16, -1/16}, -- z negative
[4] = {.5-1/16, -.5+1/16, -1/16, .5, .4999+1/16, 1/16}, -- x positive up
[5] = {-1/16, -.5+1/16, .5-1/16, 1/16, .4999+1/16, .5}, -- z positive up
[6] = {-.5, -.5+1/16, -1/16, -.5+1/16, .4999+1/16, 1/16}, -- x negative up
[7] = {-1/16, -.5+1/16, -.5, 1/16, .4999+1/16, -.5+1/16} -- z negative up
}
local tiles_off = { "mesecons_wire_off.png" }
local tiles_on = { "mesecons_wire_on.png" }
local selectionbox =
{
type = "fixed",
fixed = {-.5, -.5, -.5, .5, -.5+4/16, .5}
}
-- go to the next nodeid (ex.: 01000011 --> 01000100)
local nid_inc = function() end
nid_inc = function (nid)
local i = 0
while nid[i-1] ~= 1 do
nid[i] = (nid[i] ~= 1) and 1 or 0
i = i + 1
end
-- BUT: Skip impossible nodeids:
if ((nid[0] == 0 and nid[4] == 1) or (nid[1] == 0 and nid[5] == 1)
or (nid[2] == 0 and nid[6] == 1) or (nid[3] == 0 and nid[7] == 1)) then
return nid_inc(nid)
end
return i <= 8
end
register_wires = function()
local nid = {}
while true do
-- Create group specifiction and nodeid string (see note above for details)
local nodeid = (nid[0] or "0")..(nid[1] or "0")..(nid[2] or "0")..(nid[3] or "0")
..(nid[4] or "0")..(nid[5] or "0")..(nid[6] or "0")..(nid[7] or "0")
-- Calculate nodebox
local nodebox = {type = "fixed", fixed={box_center}}
for i=0,7 do
if nid[i] == 1 then
table.insert(nodebox.fixed, nbox_nid[i])
end
end
-- Add bump to nodebox if curved
if (nid[0] == 1 and nid[1] == 1) or (nid[1] == 1 and nid[2] == 1)
or (nid[2] == 1 and nid[3] == 1) or (nid[3] == 1 and nid[0] == 1) then
table.insert(nodebox.fixed, box_bump1)
end
-- If nothing to connect to, still make a nodebox of a straight wire
if nodeid == "00000000" then
nodebox.fixed = {-8/16, -.5, -1/16, 8/16, -.5+1/16, 1/16}
end
local rules = {}
if (nid[0] == 1) then table.insert(rules, vector.new( 1, 0, 0)) end
if (nid[1] == 1) then table.insert(rules, vector.new( 0, 0, 1)) end
if (nid[2] == 1) then table.insert(rules, vector.new(-1, 0, 0)) end
if (nid[3] == 1) then table.insert(rules, vector.new( 0, 0, -1)) end
if (nid[0] == 1) then table.insert(rules, vector.new( 1, -1, 0)) end
if (nid[1] == 1) then table.insert(rules, vector.new( 0, -1, 1)) end
if (nid[2] == 1) then table.insert(rules, vector.new(-1, -1, 0)) end
if (nid[3] == 1) then table.insert(rules, vector.new( 0, -1, -1)) end
if (nid[4] == 1) then table.insert(rules, vector.new( 1, 1, 0)) end
if (nid[5] == 1) then table.insert(rules, vector.new( 0, 1, 1)) end
if (nid[6] == 1) then table.insert(rules, vector.new(-1, 1, 0)) end
if (nid[7] == 1) then table.insert(rules, vector.new( 0, 1, -1)) end
local meseconspec_off = { conductor = {
rules = rules,
state = mesecon.state.off,
onstate = "mesecons:wire_"..nodeid.."_on"
}}
local meseconspec_on = { conductor = {
rules = rules,
state = mesecon.state.on,
offstate = "mesecons:wire_"..nodeid.."_off"
}}
local groups_on = {dig_immediate = 3, mesecon_conductor_craftable = 1,
not_in_creative_inventory = 1}
local groups_off = {dig_immediate = 3, mesecon_conductor_craftable = 1}
if nodeid ~= "00000000" then
groups_off["not_in_creative_inventory"] = 1
end
mesecon.register_node("mesecons:wire_"..nodeid, {
description = "Mesecon",
drawtype = "nodebox",
inventory_image = "bluestone_dust.png",
wield_image = "bluestone_dust.png",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
selection_box = selectionbox,
node_box = nodebox,
walkable = false,
drop = "mesecons:wire_00000000_off",
mesecon_wire = true
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},
{tiles = tiles_on, mesecons = meseconspec_on, groups = groups_on})
if (nid_inc(nid) == false) then return end
end
end
register_wires()
-- ##############
-- ## Crafting ##
-- ##############
minetest.register_craft({
type = "cooking",
output = "mesecons:wire_00000000_off 8",
recipe = "default:stone_with_bluestone",
})

View File

@ -4,72 +4,72 @@
mesecon.button_turnoff = function (pos) mesecon.button_turnoff = function (pos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if node.name=="mesecons_button:button_stone_on" then --has not been dug if node.name=="mesecons_button:button_stone_on" then --has not been dug
minetest.swap_node(pos, {name = "mesecons_button:button_stone_off", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_button:button_stone_off", param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos}) minetest.sound_play("mesecons_button_pop", {pos=pos})
local rules = mesecon.rules.buttonlike_get(node) local rules = mesecon.rules.buttonlike_get(node)
mesecon:receptor_off(pos, rules) mesecon.receptor_off(pos, rules)
elseif node.name=="mesecons_button:button_wood_on" then --has not been dug elseif node.name=="mesecons_button:button_wood_on" then --has not been dug
minetest.swap_node(pos, {name = "mesecons_button:button_wood_off", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_button:button_wood_off", param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos}) minetest.sound_play("mesecons_button_pop", {pos=pos})
local rules = mesecon.rules.buttonlike_get(node) local rules = mesecon.rules.buttonlike_get(node)
mesecon:receptor_off(pos, rules) mesecon.receptor_off(pos, rules)
end end
end end
local boxes_off = { -4/16, -2/16, 8/16, 4/16, 2/16, 6/16 } -- The button 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 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", { minetest.register_node("mesecons_button:button_stone_off", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_stone.png"}, tiles = {"default_stone.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
legacy_wallmounted = true, legacy_wallmounted = true,
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = boxes_off fixed = boxes_off
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = boxes_off -- the button itself fixed = boxes_off -- the button itself
}, },
groups = {dig_immediate=2, attached_node=1}, groups = {dig_immediate=2, attached_node=1},
description = "Stone Button", description = "Stone Button",
on_punch = function (pos, node) on_punch = function (pos, node)
minetest.swap_node(pos, {name = "mesecons_button:button_stone_on", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_button:button_stone_on", param2=node.param2})
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node)) mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_button_push", {pos=pos}) minetest.sound_play("mesecons_button_push", {pos=pos})
minetest.after(1, mesecon.button_turnoff, pos) minetest.after(1, mesecon.button_turnoff, pos)
end, end,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = { mesecons = {receptor = {
state = mesecon.state.off, state = mesecon.state.off,
rules = mesecon.rules.buttonlike_get rules = mesecon.rules.buttonlike_get
}} }}
}) })
minetest.register_node("mesecons_button:button_stone_on", { minetest.register_node("mesecons_button:button_stone_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_stone.png"}, tiles = {"default_stone.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
legacy_wallmounted = true, legacy_wallmounted = true,
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = boxes_on fixed = boxes_on
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = boxes_on -- the button itself fixed = boxes_on -- the button itself
}, },
groups = {dig_immediate=2, not_in_creative_inventory=1}, groups = {dig_immediate=2, not_in_creative_inventory=1},
drop = 'mesecons_button:button_stone_off', drop = 'mesecons_button:button_stone_off',
description = "Stone Button", description = "Stone Button",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = { mesecons = {receptor = {
state = mesecon.state.on, state = mesecon.state.on,
@ -78,72 +78,72 @@ minetest.register_node("mesecons_button:button_stone_on", {
}) })
minetest.register_node("mesecons_button:button_wood_off", { minetest.register_node("mesecons_button:button_wood_off", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_wood.png"}, tiles = {"default_wood.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
legacy_wallmounted = true, legacy_wallmounted = true,
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = boxes_off fixed = boxes_off
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = boxes_off -- the button itself fixed = boxes_off -- the button itself
}, },
groups = {dig_immediate=2}, groups = {dig_immediate=2},
description = "Wood Button", description = "Wood Button",
on_punch = function (pos, node) on_punch = function (pos, node)
minetest.swap_node(pos, {name = "mesecons_button:button_wood_on", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_button:button_wood_on", param2=node.param2})
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node)) mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_button_push", {pos=pos}) minetest.sound_play("mesecons_button_push", {pos=pos})
minetest.after(1, mesecon.button_turnoff, pos) minetest.after(1, mesecon.button_turnoff, pos)
end, end,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = { mesecons = {receptor = {
state = mesecon.state.off, state = mesecon.state.off,
rules = mesecon.rules.buttonlike_get rules = mesecon.rules.buttonlike_get
}} }}
}) })
minetest.register_node("mesecons_button:button_wood_on", { minetest.register_node("mesecons_button:button_wood_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_wood.png"}, tiles = {"default_wood.png"},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
legacy_wallmounted = true, legacy_wallmounted = true,
walkable = false, walkable = false,
sunlight_propagates = true, sunlight_propagates = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = boxes_on fixed = boxes_on
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = boxes_on -- the button itself fixed = boxes_on -- the button itself
}, },
groups = {dig_immediate=2, not_in_creative_inventory=1}, groups = {dig_immediate=2, not_in_creative_inventory=1},
drop = 'mesecons_button:button_wood_off', drop = 'mesecons_button:button_wood_off',
description = "Wood Button", description = "Wood Button",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = {receptor = { mesecons = {receptor = {
state = mesecon.state.on, state = mesecon.state.on,
rules = mesecon.rules.buttonlike_get rules = mesecon.rules.buttonlike_get
}} }}
}) })
minetest.register_craft({ minetest.register_craft({
output = "mesecons_button:button_stone_off 2", output = "mesecons_button:button_stone_off 2",
recipe = { recipe = {
{"default:cobble"}, {"default:cobble"},
} }
}) })
minetest.register_craft({ minetest.register_craft({
output = "mesecons_button:button_wood_off 2", output = "mesecons_button:button_wood_off 2",
recipe = { recipe = {
{"group:wood"}, {"group:wood"},
} }
}) })

View File

@ -1,148 +0,0 @@
doors = {}
-- Registers a door - REDEFINITION ONLY | DOORS MOD MUST HAVE BEEN LOADED BEFORE
-- name: The name of the door
-- def: a table with the folowing fields:
-- description
-- inventory_image
-- groups
-- tiles_bottom: the tiles of the bottom part of the door {front, side}
-- tiles_top: the tiles of the bottom part of the door {front, side}
-- If the following fields are not defined the default values are used
-- node_box_bottom
-- node_box_top
-- selection_box_bottom
-- selection_box_top
-- only_placer_can_open: if true only the player who placed the door can
-- open it
function doors:register_door(name, def)
def.groups.not_in_creative_inventory = 1
local box = {{-0.5, -0.5, -0.5, 0.5, 0.5, -0.5+1.5/16}}
if not def.node_box_bottom then
def.node_box_bottom = box
end
if not def.node_box_top then
def.node_box_top = box
end
if not def.selection_box_bottom then
def.selection_box_bottom= box
end
if not def.selection_box_top then
def.selection_box_top = box
end
local tt = def.tiles_top
local tb = def.tiles_bottom
local function after_dig_node(pos, name)
if minetest.get_node(pos).name == name then
minetest.remove_node(pos)
end
end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir
if not minetest.get_node(pos).name == check_name then
return
end
local p2 = minetest.get_node(pos).param2
p2 = params[p2+1]
local meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir
meta = minetest.get_meta(pos):to_table()
minetest.set_node(pos, {name=replace, param2=p2})
minetest.get_meta(pos):from_table(meta)
end
local function on_mesecons_signal_open (pos, node)
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
local function on_mesecons_signal_close (pos, node)
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
local function check_player_priv(pos, player)
if not def.only_placer_can_open then
return true
end
local meta = minetest.get_meta(pos)
local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn
end
minetest.register_node(":"..name.."_b_1", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1], tb[1].."^[transformfx"},
paramtype = "light",
paramtype2 = "facedir",
drop = name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y+1
after_dig_node(pos, name.."_t_1")
end,
on_rightclick = function(pos, node, puncher)
if check_player_priv(pos, puncher) then
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
end,
mesecons = {effector = {
action_on = on_mesecons_signal_open
}},
can_dig = check_player_priv,
})
minetest.register_node(":"..name.."_b_2", {
tiles = {tb[2], tb[2], tb[2], tb[2], tb[1].."^[transformfx", tb[1]},
paramtype = "light",
paramtype2 = "facedir",
drop = name,
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = def.node_box_bottom
},
selection_box = {
type = "fixed",
fixed = def.selection_box_bottom
},
groups = def.groups,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
pos.y = pos.y+1
after_dig_node(pos, name.."_t_2")
end,
on_rightclick = function(pos, node, puncher)
if check_player_priv(pos, puncher) then
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
end,
mesecons = {effector = {
action_off = on_mesecons_signal_close
}},
can_dig = check_player_priv,
})
end

View File

@ -1,44 +1,34 @@
-- Function that get the input/output rules of the delayer -- Function that get the input/output rules of the delayer
local delayer_get_output_rules = function(node) local delayer_get_output_rules = function(node)
local rules = {{x = 0, y = 0, z = 1}} local rules = {{x = 0, y = 0, z = 1}}
for i = 0, node.param2 do for i = 0, node.param2 do
rules = mesecon:rotate_rules_left(rules) rules = mesecon.rotate_rules_left(rules)
end end
return rules return rules
end end
local delayer_get_input_rules = function(node) local delayer_get_input_rules = function(node)
local rules = {{x = 0, y = 0, z = -1}} local rules = {{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do for i = 0, node.param2 do
rules = mesecon:rotate_rules_left(rules) rules = mesecon.rotate_rules_left(rules)
end end
return rules return rules
end end
-- Functions that are called after the delay time -- 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 delayer_activate = function(pos, node)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
local time = def.delayer_time local time = def.delayer_time
minetest.swap_node(pos, {name = def.delayer_onstate, param2=node.param2}) minetest.swap_node(pos, {name = def.delayer_onstate, param2=node.param2})
minetest.after(time, delayer_turnon , {pos = pos, node = node}) mesecon.queue:add_action(pos, "receptor_on", {delayer_get_output_rules(node)}, time, nil)
end end
local delayer_deactivate = function(pos, node) local delayer_deactivate = function(pos, node)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
local time = def.delayer_time local time = def.delayer_time
minetest.swap_node(pos, {name = def.delayer_offstate, param2=node.param2}) minetest.swap_node(pos, {name = def.delayer_offstate, param2=node.param2})
minetest.after(time, delayer_turnoff, {pos = pos, node = node}) mesecon.queue:add_action(pos, "receptor_off", {delayer_get_output_rules(node)}, time, nil)
end end
-- Register the 2 (states) x 4 (delay times) delayers -- Register the 2 (states) x 4 (delay times) delayers
@ -48,11 +38,11 @@ local groups = {}
if i == 1 then if i == 1 then
groups = {bendy=2,snappy=1,dig_immediate=2} groups = {bendy=2,snappy=1,dig_immediate=2}
else else
groups = {bendy=2,snappy = 1,dig_immediate=2, not_in_creative_inventory=1} groups = {bendy=2,snappy = 1,dig_immediate=2, not_in_creative_inventory=1}
end end
local delaytime local delaytime
if i == 1 then delaytime = 0.1 if i == 1 then delaytime = 0.1
elseif i == 2 then delaytime = 0.3 elseif i == 2 then delaytime = 0.3
elseif i == 3 then delaytime = 0.5 elseif i == 3 then delaytime = 0.5
elseif i == 4 then delaytime = 1.0 end elseif i == 4 then delaytime = 1.0 end
@ -60,144 +50,144 @@ elseif i == 4 then delaytime = 1.0 end
local boxes local boxes
if i == 1 then if i == 1 then
boxes = { boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab { -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}, -- still torch
{ 0/16, -6/16, -1/16, 2/16, -1/16, 1/16}, -- moved torch { 0/16, -6/16, -1/16, 2/16, -1/16, 1/16}, -- moved torch
} }
elseif i == 2 then elseif i == 2 then
boxes = { boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab { -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}, -- still torch
{ -2/16, -6/16, -1/16, 0/16, -1/16, 1/16}, -- moved torch { -2/16, -6/16, -1/16, 0/16, -1/16, 1/16}, -- moved torch
} }
elseif i == 3 then elseif i == 3 then
boxes = { boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab { -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}, -- still torch
{ -4/16, -6/16, -1/16, -2/16, -1/16, 1/16}, -- moved torch { -4/16, -6/16, -1/16, -2/16, -1/16, 1/16}, -- moved torch
} }
elseif i == 4 then elseif i == 4 then
boxes = { boxes = {
{ -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, -- the main slab { -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}, -- still torch
{ -6/16, -6/16, -1/16, -4/16, -1/16, 1/16}, -- moved torch { -6/16, -6/16, -1/16, -4/16, -1/16, 1/16}, -- moved torch
} }
end end
minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), { minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
description = "Delayer", description = "Delayer",
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
"mesecons_delayer_off.png", "mesecons_delayer_off.png",
"mesecons_delayer_bottom.png", "mesecons_delayer_bottom.png",
"mesecons_delayer_ends_off.png", "mesecons_delayer_ends_off.png",
"mesecons_delayer_ends_off.png", "mesecons_delayer_ends_off.png",
"mesecons_delayer_sides_off.png", "mesecons_delayer_sides_off.png",
"mesecons_delayer_sides_off.png" "mesecons_delayer_sides_off.png"
}, },
wield_image = "mesecons_delayer_off.png", wield_image = "mesecons_delayer_off.png",
walkable = true, walkable = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = boxes fixed = boxes
}, },
groups = groups, groups = groups,
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
is_ground_content = true, is_ground_content = true,
drop = 'mesecons_delayer:delayer_off_1', drop = 'mesecons_delayer:delayer_off_1',
on_punch = function (pos, node) on_punch = function (pos, node)
if node.name=="mesecons_delayer:delayer_off_1" then if node.name=="mesecons_delayer:delayer_off_1" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_2", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_2" then elseif node.name=="mesecons_delayer:delayer_off_2" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_3", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_3", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_3" then elseif node.name=="mesecons_delayer:delayer_off_3" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_4", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_4", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_4" then elseif node.name=="mesecons_delayer:delayer_off_4" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_1", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_1", param2=node.param2})
end end
end, end,
delayer_time = delaytime, delayer_time = delaytime,
delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i), delayer_onstate = "mesecons_delayer:delayer_on_"..tostring(i),
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = { mesecons = {
receptor = receptor =
{ {
state = mesecon.state.off, state = mesecon.state.off,
rules = delayer_get_output_rules rules = delayer_get_output_rules
}, },
effector = effector =
{ {
rules = delayer_get_input_rules, rules = delayer_get_input_rules,
action_on = delayer_activate action_on = delayer_activate
} }
} }
}) })
minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), { minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
description = "You hacker you", description = "You hacker you",
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
"mesecons_delayer_on.png", "mesecons_delayer_on.png",
"mesecons_delayer_bottom.png", "mesecons_delayer_bottom.png",
"mesecons_delayer_ends_on.png", "mesecons_delayer_ends_on.png",
"mesecons_delayer_ends_on.png", "mesecons_delayer_ends_on.png",
"mesecons_delayer_sides_on.png", "mesecons_delayer_sides_on.png",
"mesecons_delayer_sides_on.png" "mesecons_delayer_sides_on.png"
}, },
walkable = true, walkable = true,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 }, fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = boxes fixed = boxes
}, },
groups = {bendy = 2, snappy = 1, dig_immediate = 2, not_in_creative_inventory = 1}, groups = {bendy = 2, snappy = 1, dig_immediate = 2, not_in_creative_inventory = 1},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
is_ground_content = true, is_ground_content = true,
drop = 'mesecons_delayer:delayer_off_1', drop = 'mesecons_delayer:delayer_off_1',
on_punch = function (pos, node) on_punch = function (pos, node)
if node.name=="mesecons_delayer:delayer_on_1" then if node.name=="mesecons_delayer:delayer_on_1" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_2", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_2" then elseif node.name=="mesecons_delayer:delayer_on_2" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_3", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_3", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_3" then elseif node.name=="mesecons_delayer:delayer_on_3" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_4", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_4", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_4" then elseif node.name=="mesecons_delayer:delayer_on_4" then
minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_1", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_1", param2=node.param2})
end end
end, end,
delayer_time = delaytime, delayer_time = delaytime,
delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i), delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i),
mesecons = { mesecons = {
receptor = receptor =
{ {
state = mesecon.state.on, state = mesecon.state.on,
rules = delayer_get_output_rules rules = delayer_get_output_rules
}, },
effector = effector =
{ {
rules = delayer_get_input_rules, rules = delayer_get_input_rules,
action_off = delayer_deactivate action_off = delayer_deactivate
} }
} }
}) })
end end
minetest.register_craft({ minetest.register_craft({
output = "mesecons_delayer:delayer_off_1", output = "mesecons_delayer:delayer_off_1",
recipe = { recipe = {
{"mesecons_torch:mesecon_torch_on", "", "mesecons_torch:mesecon_torch_on"}, {"mesecons_torch:mesecon_torch_on", "", "mesecons_torch:mesecon_torch_on"},
{"default:cobble","default:cobble", "default:cobble"}, {"default:cobble","default:cobble", "default:cobble"},
} }
}) })

View File

@ -0,0 +1,98 @@
-- Modified, from minetest_game/mods/doors/init.lua
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y + dir
if not minetest.get_node(pos).name == check_name then
return
end
local p2 = minetest.get_node(pos).param2
p2 = params[p2 + 1]
minetest.swap_node(pos, {name = replace_dir, param2 = p2})
pos.y = pos.y - dir
minetest.swap_node(pos, {name = replace, param2 = p2})
if (minetest.get_meta(pos):get_int("right") ~= 0) == (params[1] ~= 3) then
minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
else
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
end
end
local function meseconify_door(name)
if minetest.registered_items[name .. "_b_1"] then
-- old style double-node doors
local function toggle_state1 (pos, node)
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
end
local function toggle_state2 (pos, node)
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
end
minetest.override_item(name.."_b_1", {
mesecons = {effector = {
action_on = toggle_state1,
action_off = toggle_state1,
rules = mesecon.rules.pplate
}}
})
minetest.override_item(name.."_b_2", {
mesecons = {effector = {
action_on = toggle_state2,
action_off = toggle_state2,
rules = mesecon.rules.pplate
}}
})
elseif minetest.registered_items[name .. "_a"] then
-- new style mesh node based doors
local override = {
mesecons = {effector = {
action_on = function(pos, node)
local door = doors.get(pos)
if door then
door:open()
end
end,
action_off = function(pos, node)
local door = doors.get(pos)
if door then
door:close()
end
end,
rules = mesecon.rules.pplate
}}
}
minetest.override_item(name .. "_a", override)
minetest.override_item(name .. "_b", override)
end
end
meseconify_door("doors:door_wood")
meseconify_door("doors:door_steel")
meseconify_door("doors:door_glass")
meseconify_door("doors:door_obsidian_glass")
if doors and doors.get then
local override = {
mesecons = {effector = {
action_on = function(pos, node)
local door = doors.get(pos)
if door then
door:open()
end
end,
action_off = function(pos, node)
local door = doors.get(pos)
if door then
door:close()
end
end,
}},
}
minetest.override_item("doors:trapdoor", override)
minetest.override_item("doors:trapdoor_open", override)
minetest.override_item("doors:trapdoor_steel", override)
minetest.override_item("doors:trapdoor_steel_open", override)
end

View File

@ -1,3 +0,0 @@
mesecons
default

View File

@ -1,5 +0,0 @@
-- dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua");
-- The crossing code is not active right now because it is hard to maintain
dofile(minetest.get_modpath("mesecons_extrawires").."/mesewire.lua");

View File

@ -1,9 +0,0 @@
local mesewire_rules =
{
{x = 1, y = 0, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y =-1, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},
}

View File

@ -1,14 +1,14 @@
--GLUE -- Glue
minetest.register_craftitem("mesecons_materials:glue", { minetest.register_craftitem("mesecons_materials:glue", {
image = "jeija_glue.png", image = "mesecons_glue.png",
on_place_on_ground = minetest.craftitem_place_item, on_place_on_ground = minetest.craftitem_place_item,
description="Glue", description="Glue",
}) })
minetest.register_craft({ minetest.register_craft({
output = "mesecons_materials:glue 2", output = "mesecons_materials:glue 2",
type = "cooking", type = "cooking",
recipe = "default:sapling", recipe = "group:sapling",
cooktime = 2 cooktime = 2
}) })

View File

@ -1,178 +1,214 @@
--register stoppers for movestones/pistons --register stoppers for movestones/pistons
mesecon.mvps_stoppers={} mesecon.mvps_stoppers={}
mesecon.on_mvps_move = {}
mesecon.mvps_unmov = {} mesecon.mvps_unmov = {}
function mesecon:is_mvps_stopper(node, pushdir, stack, stackid) --- Objects (entities) that cannot be moved
local get_stopper = mesecon.mvps_stoppers[node.name] function mesecon.register_mvps_unmov(objectname)
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
-- Objects that cannot be moved (e.g. movestones)
function mesecon:register_mvps_unmov(objectname)
mesecon.mvps_unmov[objectname] = true; mesecon.mvps_unmov[objectname] = true;
end end
function mesecon:is_mvps_unmov(objectname) function mesecon.is_mvps_unmov(objectname)
return mesecon.mvps_unmov[objectname] return mesecon.mvps_unmov[objectname]
end end
function mesecon:mvps_process_stack(stack) -- Nodes that cannot be pushed / pulled by movestones, pistons
-- update mesecons for placed nodes ( has to be done after all nodes have been added ) function mesecon.is_mvps_stopper(node, pushdir, stack, stackid)
for _, n in ipairs(stack) do -- unknown nodes are always stoppers
nodeupdate(n.pos) if not minetest.registered_nodes[node.name] then
mesecon.on_placenode(n.pos, minetest.get_node(n.pos)) return true
mesecon:update_autoconnect(n.pos) end
end
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 end
function mesecon:mvps_get_stack(pos, dir, maximum) function mesecon.register_mvps_stopper(nodename, get_stopper)
-- determine the number of nodes to be pushed if get_stopper == nil then
local np = {x = pos.x, y = pos.y, z = pos.z} get_stopper = true
local nodes = {} end
while true do mesecon.mvps_stoppers[nodename] = get_stopper
local nn = minetest.get_node_or_nil(np) end
if not nn or #nodes > maximum then
-- don't push at all, something is in the way (unloaded map or too many nodes)
return nil
end
if nn.name == "air" -- Functions to be called on mvps movement
or (minetest.registered_nodes[nn.name] function mesecon.register_on_mvps_move(callback)
and minetest.registered_nodes[nn.name].liquidtype ~= "none") then --is liquid mesecon.on_mvps_move[#mesecon.on_mvps_move+1] = callback
break end
end
table.insert (nodes, {node = nn, pos = np}) local function on_mvps_move(moved_nodes)
for _, callback in ipairs(mesecon.on_mvps_move) do
callback(moved_nodes)
end
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
mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
end
end
-- tests if the node can be pushed into, e.g. air, water, grass
local function node_replaceable(name)
if name == "ignore" then return true end
if minetest.registered_nodes[name] then
return minetest.registered_nodes[name].buildable_to or false
end
return false
end
function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky)
-- determine the number of nodes to be pushed
local nodes = {}
local frontiers = {pos}
while #frontiers > 0 do
local np = frontiers[1]
local nn = minetest.get_node(np)
if not node_replaceable(nn.name) then
table.insert(nodes, {node = nn, pos = np})
if #nodes > maximum then return nil end
-- add connected nodes to frontiers, connected is a vector list
-- the vectors must be absolute positions
local connected = {}
if minetest.registered_nodes[nn.name]
and minetest.registered_nodes[nn.name].mvps_sticky then
connected = minetest.registered_nodes[nn.name].mvps_sticky(np, nn)
end
table.insert(connected, vector.add(np, dir))
-- If adjacent node is sticky block and connects add that
-- position to the connected table
for _, r in ipairs(mesecon.rules.alldirs) do
local adjpos = vector.add(np, r)
local adjnode = minetest.get_node(adjpos)
if minetest.registered_nodes[adjnode.name]
and minetest.registered_nodes[adjnode.name].mvps_sticky then
local sticksto = minetest.registered_nodes[adjnode.name]
.mvps_sticky(adjpos, adjnode)
-- connects to this position?
for _, link in ipairs(sticksto) do
if vector.equals(link, np) then
table.insert(connected, adjpos)
end
end
end
end
if all_pull_sticky then
table.insert(connected, vector.subtract(np, dir))
end
-- Make sure there are no duplicates in frontiers / nodes before
-- adding nodes in "connected" to frontiers
for _, cp in ipairs(connected) do
local duplicate = false
for _, rp in ipairs(nodes) do
if vector.equals(cp, rp.pos) then
duplicate = true
end
end
for _, fp in ipairs(frontiers) do
if vector.equals(cp, fp) then
duplicate = true
end
end
if not duplicate then
table.insert(frontiers, cp)
end
end
end
table.remove(frontiers, 1)
end
np = mesecon:addPosRule(np, dir)
end
return nodes return nodes
end end
function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: direction of push; maximum: maximum nodes to be pushed function mesecon.mvps_push(pos, dir, maximum)
local nodes = mesecon:mvps_get_stack(pos, dir, maximum) return mesecon.mvps_push_or_pull(pos, dir, dir, maximum)
end
function mesecon.mvps_pull_all(pos, dir, maximum)
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum, true)
end
function mesecon.mvps_pull_single(pos, dir, maximum)
return mesecon.mvps_push_or_pull(pos, vector.multiply(dir, -1), dir, maximum)
end
-- pos: pos of mvps; stackdir: direction of building the stack
-- movedir: direction of actual movement
-- maximum: maximum nodes to be pushed
-- all_pull_sticky: All nodes are sticky in the direction that they are pulled from
function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sticky)
local nodes = mesecon.mvps_get_stack(pos, movedir, maximum, all_pull_sticky)
if not nodes then return end if not nodes then return end
-- determine if one of the nodes blocks the push -- determine if one of the nodes blocks the push / pull
for id, n in ipairs(nodes) do for id, n in ipairs(nodes) do
if mesecon:is_mvps_stopper(n.node, dir, nodes, id) then if mesecon.is_mvps_stopper(n.node, movedir, nodes, id) then
return return
end end
end
-- remove all nodes
for _, n in ipairs(nodes) do
n.meta = minetest.get_meta(n.pos):to_table()
minetest.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
local np = mesecon:addPosRule(n.pos, dir)
minetest.add_node(np, n.node)
minetest.get_meta(np):from_table(n.meta)
end
local oldstack = mesecon:tablecopy(nodes)
for i in ipairs(nodes) do
nodes[i].pos = mesecon:addPosRule(nodes[i].pos, dir)
end
for _, n in ipairs(nodes) do
mesecon.on_placenode(n.pos, n.node)
mesecon:update_autoconnect(n.pos)
end end
-- remove all nodes
for _, n in ipairs(nodes) do
n.meta = minetest.get_meta(n.pos):to_table()
minetest.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)
end
-- add nodes
for _, n in ipairs(nodes) do
local np = vector.add(n.pos, movedir)
minetest.set_node(np, n.node)
minetest.get_meta(np):from_table(n.meta)
end
local moved_nodes = {}
local oldstack = mesecon.tablecopy(nodes)
for i in ipairs(nodes) do
moved_nodes[i] = {}
moved_nodes[i].oldpos = nodes[i].pos
nodes[i].pos = vector.add(nodes[i].pos, movedir)
moved_nodes[i].pos = nodes[i].pos
moved_nodes[i].node = nodes[i].node
moved_nodes[i].meta = nodes[i].meta
end
on_mvps_move(moved_nodes)
return true, nodes, oldstack return true, nodes, oldstack
end end
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons) mesecon.register_on_mvps_move(function(moved_nodes)
local np = mesecon:addPosRule(pos, dir) for _, n in ipairs(moved_nodes) do
local nn = minetest.get_node(np) mesecon.on_placenode(n.pos, n.node)
mesecon.update_autoconnect(n.pos)
if ((not minetest.registered_nodes[nn.name]) --unregistered node
or minetest.registered_nodes[nn.name].liquidtype == "none") --non-liquid node
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then --non-stopper node
local meta = minetest.get_meta(np):to_table()
minetest.remove_node(np)
minetest.add_node(pos, nn)
minetest.get_meta(pos):from_table(meta)
nodeupdate(np)
nodeupdate(pos)
mesecon.on_dignode(np, nn)
mesecon:update_autoconnect(np)
mesecon:update_autoconnect(pos)
mesecon.on_placenode(pos, nn)
end
return {{pos = np, node = {param2 = 0, name = "air"}}, {pos = pos, node = nn}}
end end
end)
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull function mesecon.mvps_move_objects(pos, dir, nodestack)
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
local lnode = minetest.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.get_node(lpos2)
--avoid pulling solid nodes
if lnode.name ~= "ignore"
and lnode.name ~= "air"
and ((not minetest.registered_nodes[lnode.name])
or minetest.registered_nodes[lnode.name].liquidtype == "none") then
return
end
--avoid pulling empty or liquid nodes
if lnode2.name == "ignore"
or lnode2.name == "air"
or (minetest.registered_nodes[lnode2.name]
and 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.get_node(lpos2)
minetest.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.get_node(lpos2)
until lnode.name == "air"
or lnode.name == "ignore"
or (minetest.registered_nodes[lnode2.name]
and minetest.registered_nodes[lnode2.name].liquidtype ~= "none")
minetest.remove_node(oldpos)
end
function mesecon:mvps_move_objects(pos, dir, nodestack)
local objects_to_move = {} local objects_to_move = {}
-- Move object at tip of stack -- Move object at tip of stack, pushpos is position at tip of stack
local pushpos = mesecon:addPosRule(pos, -- get pos at tip of stack local pushpos = vector.add(pos, vector.multiply(dir, #nodestack))
{x = dir.x * #nodestack,
y = dir.y * #nodestack,
z = dir.z * #nodestack})
local objects = minetest.get_objects_inside_radius(pushpos, 1) local objects = minetest.get_objects_inside_radius(pushpos, 1)
for _, obj in ipairs(objects) do for _, obj in ipairs(objects) do
@ -183,7 +219,7 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then
-- If gravity positive and dir horizontal, push players standing on the stack -- If gravity positive and dir horizontal, push players standing on the stack
for _, n in ipairs(nodestack) do for _, n in ipairs(nodestack) do
local p_above = mesecon:addPosRule(n.pos, {x=0, y=1, z=0}) local p_above = vector.add(n.pos, {x=0, y=1, z=0})
local objects = minetest.get_objects_inside_radius(p_above, 1) local objects = minetest.get_objects_inside_radius(p_above, 1)
for _, obj in ipairs(objects) do for _, obj in ipairs(objects) do
table.insert(objects_to_move, obj) table.insert(objects_to_move, obj)
@ -193,8 +229,8 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
for _, obj in ipairs(objects_to_move) do for _, obj in ipairs(objects_to_move) do
local entity = obj:get_luaentity() local entity = obj:get_luaentity()
if not entity or not mesecon:is_mvps_unmov(entity.name) then if not entity or not mesecon.is_mvps_unmov(entity.name) then
local np = mesecon:addPosRule(obj:getpos(), dir) local np = vector.add(obj:getpos(), dir)
--move only if destination is not solid --move only if destination is not solid
local nn = minetest.get_node(np) local nn = minetest.get_node(np)
@ -206,5 +242,8 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
end end
end end
mesecon:register_mvps_stopper("default:chest_locked") mesecon.register_mvps_stopper("doors:door_steel_b_1")
mesecon:register_mvps_stopper("default:furnace") mesecon.register_mvps_stopper("doors:door_steel_t_1")
mesecon.register_mvps_stopper("doors:door_steel_b_2")
mesecon.register_mvps_stopper("doors:door_steel_t_2")
mesecon.register_mvps_stopper("default:furnace")

View File

@ -1,79 +1,79 @@
minetest.register_node("mesecons_noteblock:noteblock", { minetest.register_node("mesecons_noteblock:noteblock", {
description = "Noteblock", description = "Noteblock",
tiles = {"mesecons_noteblock.png"}, tiles = {"mesecons_noteblock.png"},
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2}, groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2},
drawtype = "allfaces_optional", drawtype = "allfaces_optional",
visual_scale = 1.3, visual_scale = 1.3,
paramtype="light", paramtype="light",
after_place_node = function(pos) after_place_node = function(pos)
minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0}) minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
end, end,
on_punch = function (pos, node) -- change sound when punched on_punch = function (pos, node) -- change sound when punched
local param2 = node.param2+1 local param2 = node.param2+1
if param2==12 then param2=0 end if param2==12 then param2=0 end
minetest.add_node(pos, {name = node.name, param2 = param2}) minetest.add_node(pos, {name = node.name, param2 = param2})
mesecon.noteblock_play(pos, param2) mesecon.noteblock_play(pos, param2)
end, end,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
mesecons = {effector = { -- play sound when activated mesecons = {effector = { -- play sound when activated
action_on = function (pos, node) action_on = function (pos, node)
mesecon.noteblock_play(pos, node.param2) mesecon.noteblock_play(pos, node.param2)
end end
}} }}
}) })
minetest.register_craft({ minetest.register_craft({
output = "mesecons_noteblock:noteblock 1", output = "mesecons_noteblock:noteblock 1",
recipe = { recipe = {
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "group:wood", "group:wood"},
{"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"}, {"default:steel_ingot", "mesecons:wire_00000000_off", "default:steel_ingot"},
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "group:wood", "group:wood"},
} }
}) })
mesecon.noteblock_play = function (pos, param2) mesecon.noteblock_play = function (pos, param2)
local soundname local soundname
if param2==8 then if param2==8 then
soundname="mesecons_noteblock_a" soundname="mesecons_noteblock_a"
elseif param2==9 then elseif param2==9 then
soundname="mesecons_noteblock_asharp" soundname="mesecons_noteblock_asharp"
elseif param2==10 then elseif param2==10 then
soundname="mesecons_noteblock_b" soundname="mesecons_noteblock_b"
elseif param2==11 then elseif param2==11 then
soundname="mesecons_noteblock_c" soundname="mesecons_noteblock_c"
elseif param2==0 then elseif param2==0 then
soundname="mesecons_noteblock_csharp" soundname="mesecons_noteblock_csharp"
elseif param2==1 then elseif param2==1 then
soundname="mesecons_noteblock_d" soundname="mesecons_noteblock_d"
elseif param2==2 then elseif param2==2 then
soundname="mesecons_noteblock_dsharp" soundname="mesecons_noteblock_dsharp"
elseif param2==3 then elseif param2==3 then
soundname="mesecons_noteblock_e" soundname="mesecons_noteblock_e"
elseif param2==4 then elseif param2==4 then
soundname="mesecons_noteblock_f" soundname="mesecons_noteblock_f"
elseif param2==5 then elseif param2==5 then
soundname="mesecons_noteblock_fsharp" soundname="mesecons_noteblock_fsharp"
elseif param2==6 then elseif param2==6 then
soundname="mesecons_noteblock_g" soundname="mesecons_noteblock_g"
elseif param2==7 then elseif param2==7 then
soundname="mesecons_noteblock_gsharp" soundname="mesecons_noteblock_gsharp"
end end
local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
if block_below_name == "default:glass" then if block_below_name == "default:glass" then
soundname="mesecons_noteblock_hihat" soundname="mesecons_noteblock_hihat"
end end
if block_below_name == "default:stone" then if block_below_name == "default:stone" then
soundname="mesecons_noteblock_kick" soundname="mesecons_noteblock_kick"
end end
if block_below_name == "default:chest" then if block_below_name == "default:chest" then
soundname="mesecons_noteblock_snare" soundname="mesecons_noteblock_snare"
end end
if block_below_name == "default:tree" then if block_below_name == "default:tree" then
soundname="mesecons_noteblock_crash" soundname="mesecons_noteblock_crash"
end end
if block_below_name == "default:wood" then if block_below_name == "default:wood" then
soundname="mesecons_noteblock_litecrash" soundname="mesecons_noteblock_litecrash"
end end
minetest.sound_play(soundname, minetest.sound_play(soundname,
{pos = pos, gain = 1.0, max_hear_distance = 32,}) {pos = pos, gain = 1.0, max_hear_distance = 32,})
end end

File diff suppressed because it is too large Load Diff

View File

@ -1,122 +1,90 @@
local pp_box_off = { local pp_box_off = {
type = "fixed", type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 }, fixed = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
} }
local pp_box_on = { local pp_box_on = {
type = "fixed", type = "fixed",
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 }, fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
} }
local function pp_on_timer(pos, elapsed) pp_on_timer = function (pos, elapsed)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local ppspec = minetest.registered_nodes[node.name].pressureplate local basename = minetest.registered_nodes[node.name].pressureplate_basename
-- This is a workaround for a strange bug that occurs when the server is started -- 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 -- For some reason the first time on_timer is called, the pos is wrong
if not ppspec then return end if not basename then return end
local objs = minetest.get_objects_inside_radius(pos, 1) local objs = minetest.get_objects_inside_radius(pos, 1)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}) local two_below = vector.add(pos, vector.new(0, -2, 0))
if objs[1] == nil and node.name == ppspec.onstate then if objs[1] == nil and node.name == basename .. "_on" then
minetest.add_node(pos, {name = ppspec.offstate}) minetest.set_node(pos, {name = basename .. "_off"})
mesecon:receptor_off(pos) mesecon.receptor_off(pos, mesecon.rules.pplate)
-- force deactivation of mesecon two blocks below (hacky) elseif node.name == basename .. "_off" then
if not mesecon:connected_to_receptor(two_below) then for k, obj in pairs(objs) do
mesecon:turnoff(two_below) local objpos = obj:getpos()
end if objpos.y > pos.y-1 and objpos.y < pos.y then
else minetest.set_node(pos, {name = basename .. "_on"})
for k, obj in pairs(objs) do mesecon.receptor_on(pos, mesecon.rules.pplate )
local objpos = obj:getpos() end
if objpos.y > pos.y-1 and objpos.y < pos.y then end
minetest.add_node(pos, {name=ppspec.onstate}) end
mesecon:receptor_on(pos) return true
-- force activation of mesecon two blocks below (hacky)
mesecon:turnon(two_below)
end
end
end
return true
end end
-- Register a Pressure Plate -- Register a Pressure Plate
-- offstate: name of the pressure plate when inactive -- offstate: name of the pressure plate when inactive
-- onstate: name of the pressure plate when active -- onstate: name of the pressure plate when active
-- description: description displayed in the player's inventory -- description: description displayed in the player's inventory
-- tiles_off: textures of the pressure plate when inactive -- tiles_off: textures of the pressure plate when inactive
-- tiles_on: textures of the pressure plate when active -- tiles_on: textures of the pressure plate when active
-- image: inventory and wield image of the pressure plate -- image: inventory and wield image of the pressure plate
-- recipe: crafting recipe of the pressure plate -- recipe: crafting recipe of the pressure plate
function mesecon:register_pressure_plate(offstate, onstate, description, texture_off, texture_on, recipe) function mesecon.register_pressure_plate(basename, description, textures_off, textures_on, --[[image_w, image_i,]] recipe)
local ppspec = { mesecon.register_node(basename, {
offstate = offstate, drawtype = "nodebox",
onstate = onstate -- inventory_image = image_i,
} -- wield_image = image_w,
paramtype = "light",
description = description,
pressureplate_basename = basename,
on_timer = pp_on_timer,
on_construct = function(pos)
minetest.get_node_timer(pos):start(mesecon.setting("pplate_interval", 0.1))
end,
},{
mesecons = {receptor = { state = mesecon.state.off, rules = mesecon.rules.pplate }},
node_box = pp_box_off,
selection_box = pp_box_off,
groups = {snappy = 2, oddly_breakable_by_hand = 3},
tiles = textures_off
},{
mesecons = {receptor = { state = mesecon.state.on, rules = mesecon.rules.pplate }},
node_box = pp_box_on,
selection_box = pp_box_on,
groups = {snappy = 2, oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
tiles = textures_on
})
minetest.register_node(offstate, { minetest.register_craft({
drawtype = "nodebox", output = basename .. "_off",
tiles = texture_off, recipe = recipe,
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.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.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 end
mesecon:register_pressure_plate( mesecon.register_pressure_plate(
"mesecons_pressureplates:pressure_plate_wood_off", "mesecons_pressureplates:pressure_plate_wood",
"mesecons_pressureplates:pressure_plate_wood_on", "Wooden Pressure Plate",
"Wooden Pressure Plate", {"default_wood.png"},
{"default_wood.png"}, {"default_wood.png"},
{"default_wood.png"}, {{"default:wood", "default:wood"}})
{{"default:wood", "default:wood"}})
mesecon:register_pressure_plate( mesecon.register_pressure_plate(
"mesecons_pressureplates:pressure_plate_stone_off", "mesecons_pressureplates:pressure_plate_stone",
"mesecons_pressureplates:pressure_plate_stone_on", "Stone Pressure Plate",
"Stone Pressure Plate", {"default_stone.png"},
{"default_stone.png"}, {"default_stone.png"},
{"default_stone.png"}, {{"default:cobble", "default:cobble"}})
{{"default:cobble", "default:cobble"}})

View File

@ -2,7 +2,8 @@
minetest.register_node("mesecons_solarpanel:solar_panel_on", { minetest.register_node("mesecons_solarpanel:solar_panel_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { "jeija_solar_panel.png" }, tiles = { "jeija_solar_panel.png" },
inventor = { "jeija_solar_panel.png" }, inventory_image = "jeija_solar_panel.png",
wield_image = "jeija_solar_panel.png",
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
is_ground_content = true, is_ground_content = true,
@ -61,7 +62,7 @@ minetest.register_abm(
if light >= 10 then if light >= 10 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
mesecon:receptor_on(pos) mesecon.receptor_on(pos)
end end
end, end,
}) })
@ -75,7 +76,7 @@ minetest.register_abm(
if light < 10 then if light < 10 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2}) minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
mesecon:receptor_off(pos) mesecon.receptor_off(pos)
end end
end, end,
}) })

View File

@ -2,15 +2,15 @@
local rotate_torch_rules = function (rules, param2) local rotate_torch_rules = function (rules, param2)
if param2 == 5 then if param2 == 5 then
return mesecon:rotate_rules_right(rules) return mesecon.rotate_rules_right(rules)
elseif param2 == 2 then elseif param2 == 2 then
return mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) --180 degrees return mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules)) --180 degrees
elseif param2 == 4 then elseif param2 == 4 then
return mesecon:rotate_rules_left(rules) return mesecon.rotate_rules_left(rules)
elseif param2 == 1 then elseif param2 == 1 then
return mesecon:rotate_rules_down(rules) return mesecon.rotate_rules_down(rules)
elseif param2 == 0 then elseif param2 == 0 then
return mesecon:rotate_rules_up(rules) return mesecon.rotate_rules_up(rules)
else else
return rules return rules
end end
@ -124,8 +124,8 @@ minetest.register_craft({
action = function(pos, node) action = function(pos, node)
local is_powered = false local is_powered = false
for _, rule in ipairs(torch_get_input_rules(node)) do for _, rule in ipairs(torch_get_input_rules(node)) do
local src = mesecon:addPosRule(pos, rule) local src = vector.add(pos, rule)
if mesecon:is_power_on(src) then if mesecon.is_power_on(src) then
is_powered = true is_powered = true
end end
end end
@ -133,11 +133,11 @@ minetest.register_craft({
if is_powered then if is_powered then
if node.name == "mesecons_torch:mesecon_torch_on" then if node.name == "mesecons_torch:mesecon_torch_on" then
minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_off", param2 = node.param2}) minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_off", param2 = node.param2})
mesecon:receptor_off(pos, torch_get_output_rules(node)) mesecon.receptor_off(pos, torch_get_output_rules(node))
end end
elseif node.name == "mesecons_torch:mesecon_torch_off" then elseif node.name == "mesecons_torch:mesecon_torch_off" then
minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_on", param2 = node.param2}) minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_on", param2 = node.param2})
mesecon:receptor_on(pos, torch_get_output_rules(node)) mesecon.receptor_on(pos, torch_get_output_rules(node))
end end
end end
})]] })]]

View File

@ -2,88 +2,89 @@
-- Basically a switch that can be attached to a wall -- Basically a switch that can be attached to a wall
-- Powers the block 2 nodes behind (using a receiver) -- Powers the block 2 nodes behind (using a receiver)
minetest.register_node("mesecons_walllever:wall_lever_off", { minetest.register_node("mesecons_walllever:wall_lever_off", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
"jeija_wall_lever_tb.png", "jeija_wall_lever_tb.png",
"jeija_wall_lever_bottom.png", "jeija_wall_lever_bottom.png",
"jeija_wall_lever_sides.png", "jeija_wall_lever_sides.png",
"jeija_wall_lever_sides.png", "jeija_wall_lever_sides.png",
"jeija_wall_lever_back.png", "jeija_wall_lever_back.png",
"jeija_wall_lever_off.png", "jeija_wall_lever_off.png",
}, },
inventory_image = "jeija_wall_lever.png", inventory_image = "jeija_wall_lever.png",
wield_image = "jeija_wall_lever.png", wield_image = "jeija_wall_lever.png",
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 },
{ -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }}, { -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }},
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base
{ -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }} -- the lever itself. { -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }} -- the lever itself.
}, },
groups = {dig_immediate=2}, groups = {dig_immediate=2},
description="Lever", description="Lever",
on_punch = function (pos, node) on_punch = function (pos, node)
minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_on", param2 = node.param2}) minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_on", param2 = node.param2})
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node)) mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_lever", {pos=pos}) minetest.sound_play("mesecons_lever", {pos=pos})
end, end,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
mesecons = {receptor = { mesecons = {receptor = {
rules = mesecon.rules.buttonlike_get, rules = mesecon.rules.buttonlike_get,
state = mesecon.state.off state = mesecon.state.off
}} }}
}) })
minetest.register_node("mesecons_walllever:wall_lever_on", { minetest.register_node("mesecons_walllever:wall_lever_on", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
"jeija_wall_lever_top.png", "jeija_wall_lever_top.png",
"jeija_wall_lever_tb.png", "jeija_wall_lever_tb.png",
"jeija_wall_lever_sides.png", "jeija_wall_lever_sides.png",
"jeija_wall_lever_sides.png", "jeija_wall_lever_sides.png",
"jeija_wall_lever_back.png", "jeija_wall_lever_back.png",
"jeija_wall_lever_on.png", "jeija_wall_lever_on.png",
}, },
inventory_image = "jeija_wall_lever.png", inventory_image = "jeija_wall_lever.png",
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
sunlight_propagates = true, sunlight_propagates = true,
walkable = false, walkable = false,
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 },
{ -1/16, 0, 7/16, 1/16, 8/16, 5/16 }}, { -1/16, 0, 7/16, 1/16, 8/16, 5/16 }},
}, },
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base
{ -1/16, 0/16, 7/16, 1/16, 8/16, 5/16 }} -- the lever itself. { -1/16, 0/16, 7/16, 1/16, 8/16, 5/16 }} -- the lever itself.
}, },
groups = {dig_immediate = 2, not_in_creative_inventory = 1}, groups = {dig_immediate = 2, not_in_creative_inventory = 1},
drop = "mesecons_walllever:wall_lever_off 1", drop = "mesecons_walllever:wall_lever_off 1",
description="Lever", description="Lever",
on_punch = function (pos, node) on_punch = function (pos, node)
minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_off", param2 = node.param2}) minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_off", param2 = node.param2})
mesecon:receptor_off(pos, mesecon.rules.buttonlike_get(node)) mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_lever", {pos=pos}) minetest.sound_play("mesecons_lever", {pos=pos})
end, end,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
mesecons = {receptor = { mesecons = {receptor = {
rules = mesecon.rules.buttonlike_get, rules = mesecon.rules.buttonlike_get,
state = mesecon.state.on state = mesecon.state.on
}} }}
}) })
minetest.register_craft({ minetest.register_craft({
output = "mesecons_walllever:wall_lever_off 2", output = "mesecons_walllever:wall_lever_off 2",
recipe = { recipe = {
{"default:cobble"}, {"default:cobble"},
{"default:stick"}, {"default:stick"},
} }
}) })

View File

@ -1,244 +0,0 @@
xof 0302txt 0064
// File created by CINEMA 4D
template Header {
<3D82AB43-62DA-11cf-AB39-0020AF71E433>
SWORD major;
SWORD minor;
DWORD flags;
}
template Vector {
<3D82AB5E-62DA-11cf-AB39-0020AF71E433>
FLOAT x;
FLOAT y;
FLOAT z;
}
template Coords2d {
<F6F23F44-7686-11cf-8F52-0040333594A3>
FLOAT u;
FLOAT v;
}
template Matrix4x4 {
<F6F23F45-7686-11cf-8F52-0040333594A3>
array FLOAT matrix[16];
}
template ColorRGBA {
<35FF44E0-6C7C-11cf-8F52-0040333594A3>
FLOAT red;
FLOAT green;
FLOAT blue;
FLOAT alpha;
}
template ColorRGB {
<D3E16E81-7835-11cf-8F52-0040333594A3>
FLOAT red;
FLOAT green;
FLOAT blue;
}
template IndexedColor {
<1630B820-7842-11cf-8F52-0040333594A3>
DWORD index;
ColorRGBA indexColor;
}
template Boolean {
<4885AE61-78E8-11cf-8F52-0040333594A3>
SWORD truefalse;
}
template Boolean2d {
<4885AE63-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template MaterialWrap {
<4885AE60-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template TextureFilename {
<A42790E1-7810-11cf-8F52-0040333594A3>
STRING filename;
}
template Material {
<3D82AB4D-62DA-11cf-AB39-0020AF71E433>
ColorRGBA faceColor;
FLOAT power;
ColorRGB specularColor;
ColorRGB emissiveColor;
[...]
}
template MeshFace {
<3D82AB5F-62DA-11cf-AB39-0020AF71E433>
DWORD nFaceVertexIndices;
array DWORD faceVertexIndices[nFaceVertexIndices];
}
template MeshFaceWraps {
<4885AE62-78E8-11cf-8F52-0040333594A3>
DWORD nFaceWrapValues;
Boolean2d faceWrapValues;
}
template MeshTextureCoords {
<F6F23F40-7686-11cf-8F52-0040333594A3>
DWORD nTextureCoords;
array Coords2d textureCoords[nTextureCoords];
}
template MeshMaterialList {
<F6F23F42-7686-11cf-8F52-0040333594A3>
DWORD nMaterials;
DWORD nFaceIndexes;
array DWORD faceIndexes[nFaceIndexes];
[Material]
}
template MeshNormals {
<F6F23F43-7686-11cf-8F52-0040333594A3>
DWORD nNormals;
array Vector normals[nNormals];
DWORD nFaceNormals;
array MeshFace faceNormals[nFaceNormals];
}
template MeshVertexColors {
<1630B821-7842-11cf-8F52-0040333594A3>
DWORD nVertexColors;
array IndexedColor vertexColors[nVertexColors];
}
template Mesh {
<3D82AB44-62DA-11cf-AB39-0020AF71E433>
DWORD nVertices;
array Vector vertices[nVertices];
DWORD nFaces;
array MeshFace faces[nFaces];
[...]
}
template FrameTransformMatrix {
<F6F23F41-7686-11cf-8F52-0040333594A3>
Matrix4x4 frameMatrix;
}
template Frame {
<3D82AB46-62DA-11cf-AB39-0020AF71E433>
[...]
}
Header {
1;
0;
1;
}
Mesh CINEMA4D_Mesh {
16;
// Lever1
-4.481;-4.311;-6.25;,
-44.655;43.567;-6.25;,
5.095;3.724;-6.25;,
-35.079;51.602;-6.25;,
5.095;3.724;6.25;,
-35.079;51.602;6.25;,
-4.481;-4.311;6.25;,
-44.655;43.567;6.25;,
// Lever_Hold
-25.0;-9.375;-18.75;,
-25.0;9.375;-18.75;,
25.0;-9.375;-18.75;,
25.0;9.375;-18.75;,
25.0;-9.375;18.75;,
25.0;9.375;18.75;,
-25.0;-9.375;18.75;,
-25.0;9.375;18.75;;
12;
// Lever1
4;0,1,3,2;,
4;2,3,5,4;,
4;4,5,7,6;,
4;6,7,1,0;,
4;1,7,5,3;,
4;6,0,2,4;,
// Lever_Hold
4;8,9,11,10;,
4;10,11,13,12;,
4;12,13,15,14;,
4;14,15,9,8;,
4;9,15,13,11;,
4;14,8,10,12;;
MeshNormals {
16;
// Lever1
0.088;-0.161;-0.036;,
-0.144;0.115;-0.036;,
0.144;-0.115;-0.036;,
-0.088;0.161;-0.036;,
0.144;-0.115;0.036;,
-0.088;0.161;0.036;,
0.088;-0.161;0.036;,
-0.144;0.115;0.036;,
// Lever_Hold
-0.144;-0.054;-0.108;,
-0.144;0.054;-0.108;,
0.144;-0.054;-0.108;,
0.144;0.054;-0.108;,
0.144;-0.054;0.108;,
0.144;0.054;0.108;,
-0.144;-0.054;0.108;,
-0.144;0.054;0.108;;
12;
// Lever1
4;0,1,3,2;,
4;2,3,5,4;,
4;4,5,7,6;,
4;6,7,1,0;,
4;1,7,5,3;,
4;6,0,2,4;,
// Lever_Hold
4;8,9,11,10;,
4;10,11,13,12;,
4;12,13,15,14;,
4;14,15,9,8;,
4;9,15,13,11;,
4;14,8,10,12;;
}
MeshTextureCoords {
16;
// Lever1
0.027;0.399;,
0.027;0.437;,
0.035;0.399;,
0.035;0.437;,
0.035;0.437;,
0.035;0.399;,
0.027;0.437;,
0.027;0.399;,
// Lever_Hold
0.0;0.063;,
0.0;0.086;,
0.031;0.063;,
0.031;0.086;,
0.031;0.086;,
0.031;0.063;,
0.0;0.086;,
0.0;0.063;;
}
}

View File

@ -1,274 +0,0 @@
xof 0302txt 0064
// File created by CINEMA 4D
template Header {
<3D82AB43-62DA-11cf-AB39-0020AF71E433>
SWORD major;
SWORD minor;
DWORD flags;
}
template Vector {
<3D82AB5E-62DA-11cf-AB39-0020AF71E433>
FLOAT x;
FLOAT y;
FLOAT z;
}
template Coords2d {
<F6F23F44-7686-11cf-8F52-0040333594A3>
FLOAT u;
FLOAT v;
}
template Matrix4x4 {
<F6F23F45-7686-11cf-8F52-0040333594A3>
array FLOAT matrix[16];
}
template ColorRGBA {
<35FF44E0-6C7C-11cf-8F52-0040333594A3>
FLOAT red;
FLOAT green;
FLOAT blue;
FLOAT alpha;
}
template ColorRGB {
<D3E16E81-7835-11cf-8F52-0040333594A3>
FLOAT red;
FLOAT green;
FLOAT blue;
}
template IndexedColor {
<1630B820-7842-11cf-8F52-0040333594A3>
DWORD index;
ColorRGBA indexColor;
}
template Boolean {
<4885AE61-78E8-11cf-8F52-0040333594A3>
SWORD truefalse;
}
template Boolean2d {
<4885AE63-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template MaterialWrap {
<4885AE60-78E8-11cf-8F52-0040333594A3>
Boolean u;
Boolean v;
}
template TextureFilename {
<A42790E1-7810-11cf-8F52-0040333594A3>
STRING filename;
}
template Material {
<3D82AB4D-62DA-11cf-AB39-0020AF71E433>
ColorRGBA faceColor;
FLOAT power;
ColorRGB specularColor;
ColorRGB emissiveColor;
[...]
}
template MeshFace {
<3D82AB5F-62DA-11cf-AB39-0020AF71E433>
DWORD nFaceVertexIndices;
array DWORD faceVertexIndices[nFaceVertexIndices];
}
template MeshFaceWraps {
<4885AE62-78E8-11cf-8F52-0040333594A3>
DWORD nFaceWrapValues;
Boolean2d faceWrapValues;
}
template MeshTextureCoords {
<F6F23F40-7686-11cf-8F52-0040333594A3>
DWORD nTextureCoords;
array Coords2d textureCoords[nTextureCoords];
}
template MeshMaterialList {
<F6F23F42-7686-11cf-8F52-0040333594A3>
DWORD nMaterials;
DWORD nFaceIndexes;
array DWORD faceIndexes[nFaceIndexes];
[Material]
}
template MeshNormals {
<F6F23F43-7686-11cf-8F52-0040333594A3>
DWORD nNormals;
array Vector normals[nNormals];
DWORD nFaceNormals;
array MeshFace faceNormals[nFaceNormals];
}
template MeshVertexColors {
<1630B821-7842-11cf-8F52-0040333594A3>
DWORD nVertexColors;
array IndexedColor vertexColors[nVertexColors];
}
template Mesh {
<3D82AB44-62DA-11cf-AB39-0020AF71E433>
DWORD nVertices;
array Vector vertices[nVertices];
DWORD nFaces;
array MeshFace faces[nFaces];
[...]
}
template FrameTransformMatrix {
<F6F23F41-7686-11cf-8F52-0040333594A3>
Matrix4x4 frameMatrix;
}
template Frame {
<3D82AB46-62DA-11cf-AB39-0020AF71E433>
[...]
}
Header {
1;
0;
1;
}
Mesh CINEMA4D_Mesh {
16;
// Lever1
4.968;-3.861;6.175;,
44.767;43.898;-0.249;,
-4.623;4.154;6.346;,
35.177;51.913;-0.078;,
-5.577;3.277;-6.087;,
34.222;51.036;-12.511;,
4.014;-4.738;-6.258;,
43.813;43.021;-12.682;,
// Lever_Hold
-25.0;-9.375;-18.75;,
-25.0;9.375;-18.75;,
25.0;-9.375;-18.75;,
25.0;9.375;-18.75;,
25.0;-9.375;18.75;,
25.0;9.375;18.75;,
-25.0;-9.375;18.75;,
-25.0;9.375;18.75;;
12;
// Lever1
4;0,1,3,2;,
4;2,3,5,4;,
4;4,5,7,6;,
4;6,7,1,0;,
4;1,7,5,3;,
4;6,0,2,4;,
// Lever_Hold
4;8,9,11,10;,
4;10,11,13,12;,
4;12,13,15,14;,
4;14,15,9,8;,
4;9,15,13,11;,
4;14,8,10,12;;
MeshNormals {
16;
// Lever1
-0.084;-0.158;0.054;,
0.145;0.117;0.017;,
-0.14;-0.112;0.055;,
0.09;0.164;0.018;,
-0.145;-0.117;-0.017;,
0.084;0.158;-0.054;,
-0.09;-0.164;-0.018;,
0.14;0.112;-0.055;,
// Lever_Hold
-0.144;-0.054;-0.108;,
-0.144;0.054;-0.108;,
0.144;-0.054;-0.108;,
0.144;0.054;-0.108;,
0.144;-0.054;0.108;,
0.144;0.054;0.108;,
-0.144;-0.054;0.108;,
-0.144;0.054;0.108;;
12;
// Lever1
4;0,1,3,2;,
4;2,3,5,4;,
4;4,5,7,6;,
4;6,7,1,0;,
4;1,7,5,3;,
4;6,0,2,4;,
// Lever_Hold
4;8,9,11,10;,
4;10,11,13,12;,
4;12,13,15,14;,
4;14,15,9,8;,
4;9,15,13,11;,
4;14,8,10,12;;
}
MeshTextureCoords {
16;
// Lever1
0.027;0.399;,
0.027;0.437;,
0.035;0.399;,
0.035;0.437;,
0.035;0.437;,
0.035;0.399;,
0.027;0.437;,
0.027;0.399;,
// Lever_Hold
0.0;0.063;,
0.0;0.086;,
0.031;0.063;,
0.031;0.086;,
0.031;0.086;,
0.031;0.063;,
0.0;0.086;,
0.0;0.063;;
}
MeshMaterialList {
2;
12;
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1;
Material C4DMAT_NONE {
1.0;1.0;1.0;1.0;;
1.0;
0.0;0.0;0.0;;
0.0;0.0;0.0;;
}
Material C4DMAT_Terrain {
1.0;1.0;1.0;1.0;;
1.0;
0.0;0.0;0.0;;
0.0;0.0;0.0;;
}
}
}

View File

@ -604,12 +604,6 @@ minetest.register_craft({
recipe = "default:stone_with_coal", recipe = "default:stone_with_coal",
}) })
minetest.register_craft({
type = "cooking",
output = "mesecons:wire_00000000_off 5",
recipe = "default:stone_with_bluestone",
})
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
output = "default:diamond", output = "default:diamond",

View File

@ -773,7 +773,7 @@ minetest.register_node("default:stone_with_bluestone", {
description = "Bluestone Ore", description = "Bluestone Ore",
tiles = {"default_stone.png^default_mineral_bluestone.png"}, tiles = {"default_stone.png^default_mineral_bluestone.png"},
groups = {cracky = 2}, groups = {cracky = 2},
drop = "mesecons:wire_00000000_off 5", drop = "mesecons:wire_00000000_off 8",
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
}) })
@ -1402,7 +1402,7 @@ minetest.register_node("default:ladder_wood", {
default.register_fence("default:fence_wood", { default.register_fence("default:fence_wood", {
description = "Apple Wood Fence", description = "Apple Wood Fence",
texture = "default_wood.png", texture = "default_wood.png",
inventory_image = "default_wood_fence.png", inventory_image = "default_wood_fence.png",
material = "default:wood", material = "default:wood",
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
sounds = default.node_sound_wood_defaults() sounds = default.node_sound_wood_defaults()

View File

@ -424,7 +424,7 @@ local function punch(pos)
else else
state = 1 state = 1
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10}) minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
tmp_node = {name="doors:trapdoors_door_open", param1=me.param1, param2=me.param2} tmp_node = {name="doors:trapdoor_open", param1=me.param1, param2=me.param2}
end end
update_door(pos, tmp_node) update_door(pos, tmp_node)
meta:set_int("state", state) meta:set_int("state", state)
@ -477,7 +477,7 @@ minetest.register_node("doors:trapdoor", {
}) })
minetest.register_node("doors:trapdoors_door_open", { minetest.register_node("doors:trapdoor_open", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_wood.png", "default_wood.png", "default_wood.png", "default_wood.png", "door_trapdoor.png", "door_trapdoor.png"}, tiles = {"default_wood.png", "default_wood.png", "default_wood.png", "default_wood.png", "door_trapdoor.png", "door_trapdoor.png"},
paramtype = "light", paramtype = "light",
@ -506,8 +506,7 @@ minetest.register_node("doors:trapdoors_door_open", {
}) })
minetest.register_alias("doors:trapdoors_door_open", "doors:trapdoor_open")
minetest.register_craft({ minetest.register_craft({
output = 'doors:trapdoor 2', output = 'doors:trapdoor 2',
@ -518,7 +517,7 @@ minetest.register_craft({
} }
}) })
--- Iron Trapdoor ---- --- Steel Trapdoor ----
local me local me
local meta local meta
local state = 0 local state = 0
@ -537,19 +536,19 @@ local function punch(pos)
if state == 1 then if state == 1 then
state = 0 state = 0
minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10}) minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
tmp_node = {name="doors:iron_trapdoor", param1=me.param1, param2=me.param2} tmp_node = {name="doors:trapdoor_steel", param1=me.param1, param2=me.param2}
else else
state = 1 state = 1
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10}) minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
tmp_node = {name="doors:iron_trapdoors_door_open", param1=me.param1, param2=me.param2} tmp_node = {name="doors:trapdoor_steel_open", param1=me.param1, param2=me.param2}
end end
update_door(pos, tmp_node) update_door(pos, tmp_node)
meta:set_int("state", state) meta:set_int("state", state)
end end
minetest.register_node("doors:iron_trapdoor", { minetest.register_node("doors:trapdoor_steel", {
description = "Trapdoor", description = "Steel Trapdoor",
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"iron_trapdoor.png", "iron_trapdoor.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png"}, tiles = {"iron_trapdoor.png", "iron_trapdoor.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png"},
paramtype = "light", paramtype = "light",
@ -557,7 +556,7 @@ minetest.register_node("doors:iron_trapdoor", {
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2,mesecon_effector_on=1, flammable = 0, door=1}, groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2,mesecon_effector_on=1, flammable = 0, door=1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
drop = "doors:iron_trapdoor", drop = "doors:trapdoor_steel",
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -590,8 +589,7 @@ minetest.register_node("doors:iron_trapdoor", {
end, end,
}) })
minetest.register_node("doors:trapdoor_steel_open", {
minetest.register_node("doors:iron_trapdoors_door_open", {
drawtype = "nodebox", drawtype = "nodebox",
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "iron_trapdoor.png", "iron_trapdoor.png"}, tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "iron_trapdoor.png", "iron_trapdoor.png"},
paramtype = "light", paramtype = "light",
@ -600,7 +598,7 @@ minetest.register_node("doors:iron_trapdoors_door_open", {
stack_max = 0, stack_max = 0,
groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 0,door=1,mesecon_effector_on=1}, groups = {snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 0,door=1,mesecon_effector_on=1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
drop = "doors:iron_trapdoor", drop = "doors:trapdoor_steel",
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5} fixed = {-0.5, -0.5, 0.4, 0.5, 0.5, 0.5}
@ -616,6 +614,9 @@ minetest.register_node("doors:iron_trapdoors_door_open", {
}}, }},
}) })
minetest.register_alias("doors:iron_trapdoors_door_open", "doors:trapdoor_steel_open")
minetest.register_alias("doors:iron_trapdoor", "doors:trapdoor_steel")
minetest.register_craft({ minetest.register_craft({
output = 'doors:iron_trapdoor 2', output = 'doors:iron_trapdoor 2',
recipe = { recipe = {