Update code to standards of Minetest 0.4.8.

This commit is contained in:
Uberi 2013-11-30 22:13:00 -05:00
parent b4654cedb7
commit 16b4b79c51
22 changed files with 148 additions and 155 deletions

View File

@ -132,7 +132,7 @@ function mesecon:receptor_off_i(pos, rules)
if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then if not mesecon:connected_to_receptor(np, mesecon:invertRule(rule)) then
mesecon:turnoff(np, rulename) mesecon:turnoff(np, rulename)
else else
mesecon:changesignal(np, minetest.env:get_node(np), rulename, mesecon.state.off) mesecon:changesignal(np, minetest.get_node(np), rulename, mesecon.state.off)
end end
end end
end end

View File

@ -237,7 +237,7 @@ function execute_actions(dtime)
local nactions = mesecon.to_update local nactions = mesecon.to_update
mesecon.to_update = {} mesecon.to_update = {}
for _,i in ipairs(nactions) do for _,i in ipairs(nactions) do
node = minetest.env:get_node(i.pos) node = minetest.get_node(i.pos)
if node.name=="ignore" then if node.name=="ignore" then
add_action(i.pos, i.action, i.rname) add_action(i.pos, i.action, i.rname)
else else
@ -395,7 +395,7 @@ end
-- some more general high-level stuff -- some more general high-level stuff
function mesecon:is_power_on(pos, rulename) function mesecon:is_power_on(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_on(node.name, rulename) or mesecon:is_receptor_on(node.name) then if mesecon:is_conductor_on(node.name, rulename) or mesecon:is_receptor_on(node.name) then
return true return true
end end
@ -403,7 +403,7 @@ function mesecon:is_power_on(pos, rulename)
end end
function mesecon:is_power_off(pos, rulename) function mesecon:is_power_off(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_off(node.name, rulename) or mesecon:is_receptor_off(node.name) then if mesecon:is_conductor_off(node.name, rulename) or mesecon:is_receptor_off(node.name) then
return true return true
end end
@ -411,7 +411,7 @@ function mesecon:is_power_off(pos, rulename)
end end
function mesecon:turnon(pos, rulename) function mesecon:turnon(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_off(node.name, rulename) then if mesecon:is_conductor_off(node.name, rulename) then
local rules = mesecon:conductor_get_rules(node) local rules = mesecon:conductor_get_rules(node)
@ -425,7 +425,7 @@ function mesecon:turnon(pos, rulename)
return return
end end
minetest.env:add_node(pos, {name = mesecon:get_conductor_on(node.name, rulename), param2 = node.param2}) minetest.add_node(pos, {name = mesecon:get_conductor_on(node.name, rulename), param2 = node.param2})
for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
@ -444,7 +444,7 @@ function mesecon:turnon(pos, rulename)
end end
function mesecon:turnoff(pos, rulename) function mesecon:turnoff(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_conductor_on(node.name, rulename) then if mesecon:is_conductor_on(node.name, rulename) then
local rules = mesecon:conductor_get_rules(node) local rules = mesecon:conductor_get_rules(node)
@ -458,7 +458,7 @@ function mesecon:turnoff(pos, rulename)
return return
end end
--]] --]]
minetest.env:add_node(pos, {name = mesecon:get_conductor_off(node.name, rulename), param2 = node.param2}) minetest.add_node(pos, {name = mesecon:get_conductor_off(node.name, rulename), param2 = node.param2})
for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do for _, rule in ipairs(mesecon:rule2meta(rulename, rules)) do
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
@ -479,7 +479,7 @@ end
function mesecon:connected_to_receptor(pos, rulename) function mesecon:connected_to_receptor(pos, rulename)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
-- Check if conductors around are connected -- Check if conductors around are connected
local rules = mesecon:get_any_inputrules(node) local rules = mesecon:get_any_inputrules(node)
@ -507,7 +507,7 @@ function mesecon:find_receptor_on(pos, checked, rulename)
-- add current position to checked -- add current position to checked
table.insert(checked, {x=pos.x, y=pos.y, z=pos.z}) table.insert(checked, {x=pos.x, y=pos.y, z=pos.z})
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if mesecon:is_receptor_on(node.name) then if mesecon:is_receptor_on(node.name) then
return true return true
@ -529,8 +529,8 @@ function mesecon:find_receptor_on(pos, checked, rulename)
end end
function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
local outputnode = minetest.env:get_node(output) local outputnode = minetest.get_node(output)
local inputnode = minetest.env:get_node(input) local inputnode = minetest.get_node(input)
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode) local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
local inputrules = mesecon:get_any_inputrules (inputnode) local inputrules = mesecon:get_any_inputrules (inputnode)
if not outputrules or not inputrules then if not outputrules or not inputrules then
@ -556,14 +556,14 @@ function mesecon:rules_link_anydir(pos1, pos2)
end end
function mesecon:is_powered(pos, rule) function mesecon:is_powered(pos, rule)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local rules = mesecon:get_any_inputrules(node) local rules = mesecon:get_any_inputrules(node)
if not rules then return false end if not rules then return false end
if not rule then if not rule then
for _, rule in ipairs(mesecon:flattenrules(rules)) do for _, rule in ipairs(mesecon:flattenrules(rules)) do
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
local nn = minetest.env:get_node(np) local nn = minetest.get_node(np)
if (mesecon:is_conductor_on (nn.name, mesecon:invertRule(rule)) or mesecon:is_receptor_on (nn.name)) if (mesecon:is_conductor_on (nn.name, mesecon:invertRule(rule)) or mesecon:is_receptor_on (nn.name))
and mesecon:rules_link(np, pos) then and mesecon:rules_link(np, pos) then
@ -572,7 +572,7 @@ function mesecon:is_powered(pos, rule)
end end
else else
local np = mesecon:addPosRule(pos, rule) local np = mesecon:addPosRule(pos, rule)
local nn = minetest.env:get_node(np) local nn = minetest.get_node(np)
if (mesecon:is_conductor_on (nn.name, mesecon:invertRule(rule)) or mesecon:is_receptor_on (nn.name)) if (mesecon:is_conductor_on (nn.name, mesecon:invertRule(rule)) or mesecon:is_receptor_on (nn.name))
and mesecon:rules_link(np, pos) then and mesecon:rules_link(np, pos) then

View File

@ -29,7 +29,7 @@ minetest.register_abm({
interval = 1.0, interval = 1.0,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("heat",0) meta:set_int("heat",0)
end, end,
}) })

View File

@ -1,9 +1,9 @@
function mesecon:move_node(pos, newpos) function mesecon:move_node(pos, newpos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.env:get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.env:add_node(newpos, node) minetest.add_node(newpos, node)
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end
--[[ new functions: --[[ new functions:

View File

@ -207,7 +207,7 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
mesecon:update_autoconnect(zmympos, true) mesecon:update_autoconnect(zmympos, true)
end end
nodename = minetest.env:get_node(pos).name nodename = minetest.get_node(pos).name
if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end if string.find(nodename, "mesecons:wire_") == nil and not replace_old then return nil end
if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end if mesecon:rules_link_anydir(pos, xppos) then xp = 1 else xp = 0 end
@ -235,9 +235,9 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
if string.find(nodename, "_off") ~= nil then if string.find(nodename, "_off") ~= nil then
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"}) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else else
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" }) minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
end end
end end

View File

@ -81,8 +81,8 @@ minetest.register_abm(
interval = BLINKY_PLANT_INTERVAL, interval = BLINKY_PLANT_INTERVAL,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
--minetest.env:remove_node(pos) --minetest.remove_node(pos)
minetest.env:add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"}) minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_on"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end, end,
@ -93,8 +93,8 @@ minetest.register_abm({
interval = BLINKY_PLANT_INTERVAL, interval = BLINKY_PLANT_INTERVAL,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
--minetest.env:remove_node(pos) --minetest.remove_node(pos)
minetest.env:add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"}) minetest.add_node(pos, {name="mesecons_blinkyplant:blinky_plant_off"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end, end,

View File

@ -3,7 +3,7 @@
-- and then turns off again -- and then turns off again
mesecon.button_turnoff = function (pos) mesecon.button_turnoff = function (pos)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if node.name=="mesecons_button:button_on" then --has not been dug if node.name=="mesecons_button:button_on" then --has not been dug
minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2}) minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos}) minetest.sound_play("mesecons_button_pop", {pos=pos})

View File

@ -16,7 +16,7 @@ minetest.register_chatcommand("tell", {
minetest.chat_send_player(name, "Invalid usage: " .. param) minetest.chat_send_player(name, "Invalid usage: " .. param)
return return
end end
if not minetest.env:get_player_by_name(target) then if not minetest.get_player_by_name(target) then
minetest.chat_send_player(name, "Invalid target: " .. target) minetest.chat_send_player(name, "Invalid target: " .. target)
end end
minetest.chat_send_player(target, name .. " whispers: " .. message, false) minetest.chat_send_player(target, name .. " whispers: " .. message, false)
@ -41,7 +41,7 @@ minetest.register_chatcommand("hp", {
minetest.chat_send_player(name, "Invalid usage: " .. param) minetest.chat_send_player(name, "Invalid usage: " .. param)
return return
end end
local player = minetest.env:get_player_by_name(target) local player = minetest.get_player_by_name(target)
if player then if player then
player:set_hp(value) player:set_hp(value)
else else
@ -72,7 +72,7 @@ local initialize_data = function(meta, player, command, param)
end end
local construct = function(pos) local construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("player", "@nearest") meta:set_string("player", "@nearest")
meta:set_string("command", "time") meta:set_string("command", "time")
@ -85,14 +85,14 @@ end
local after_place = function(pos, placer) local after_place = function(pos, placer)
if placer then if placer then
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name()) meta:set_string("owner", placer:get_player_name())
initialize_data(meta, "@nearest", "time", "7000") initialize_data(meta, "@nearest", "time", "7000")
end end
end end
local receive_fields = function(pos, formname, fields, sender) local receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if fields.nearest then if fields.nearest then
initialize_data(meta, "@nearest", fields.command, fields.param) initialize_data(meta, "@nearest", fields.command, fields.param)
elseif fields.farthest then elseif fields.farthest then
@ -146,7 +146,7 @@ local commandblock_action_on = function(pos, node)
minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"}) minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local command = minetest.chatcommands[meta:get_string("command")] local command = minetest.chatcommands[meta:get_string("command")]
if command == nil then if command == nil then
return return
@ -179,7 +179,7 @@ minetest.register_node("mesecons_commandblock:commandblock_off", {
after_place_node = after_place, after_place_node = after_place,
on_receive_fields = receive_fields, on_receive_fields = receive_fields,
can_dig = function(pos,player) can_dig = function(pos,player)
local owner = minetest.env:get_meta(pos):get_string("owner") local owner = minetest.get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name() return owner == "" or owner == player:get_player_name()
end, end,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
@ -197,7 +197,7 @@ minetest.register_node("mesecons_commandblock:commandblock_on", {
after_place_node = after_place, after_place_node = after_place,
on_receive_fields = receive_fields, on_receive_fields = receive_fields,
can_dig = function(pos,player) can_dig = function(pos,player)
local owner = minetest.env:get_meta(pos):get_string("owner") local owner = minetest.get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name() return owner == "" or owner == player:get_player_name()
end, end,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),

View File

@ -38,27 +38,27 @@ function doors:register_door(name, def)
local tb = def.tiles_bottom local tb = def.tiles_bottom
local function after_dig_node(pos, name) local function after_dig_node(pos, name)
if minetest.env:get_node(pos).name == name then if minetest.get_node(pos).name == name then
minetest.env:remove_node(pos) minetest.remove_node(pos)
end end
end end
local function on_rightclick(pos, dir, check_name, replace, replace_dir, params) local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
pos.y = pos.y+dir pos.y = pos.y+dir
if not minetest.env:get_node(pos).name == check_name then if not minetest.get_node(pos).name == check_name then
return return
end end
local p2 = minetest.env:get_node(pos).param2 local p2 = minetest.get_node(pos).param2
p2 = params[p2+1] p2 = params[p2+1]
local meta = minetest.env:get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.env:set_node(pos, {name=replace_dir, param2=p2}) minetest.set_node(pos, {name=replace_dir, param2=p2})
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
pos.y = pos.y-dir pos.y = pos.y-dir
meta = minetest.env:get_meta(pos):to_table() meta = minetest.get_meta(pos):to_table()
minetest.env:set_node(pos, {name=replace, param2=p2}) minetest.set_node(pos, {name=replace, param2=p2})
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end
local function on_mesecons_signal_open (pos, node) local function on_mesecons_signal_open (pos, node)
@ -73,7 +73,7 @@ function doors:register_door(name, def)
if not def.only_placer_can_open then if not def.only_placer_can_open then
return true return true
end end
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local pn = player:get_player_name() local pn = player:get_player_name()
return meta:get_string("doors_owner") == pn return meta:get_string("doors_owner") == pn
end end

View File

@ -3,14 +3,14 @@
-- The radius can be specified in mesecons/settings.lua -- The radius can be specified in mesecons/settings.lua
local object_detector_make_formspec = function (pos) local object_detector_make_formspec = function (pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[9,2.5]" .. meta:set_string("formspec", "size[9,2.5]" ..
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]".. "field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]") "field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]")
end end
local object_detector_on_receive_fields = function (pos, formname, fields) local object_detector_on_receive_fields = function (pos, formname, fields)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("scanname", fields.scanname) meta:set_string("scanname", fields.scanname)
meta:set_string("digiline_channel", fields.digiline_channel) meta:set_string("digiline_channel", fields.digiline_channel)
object_detector_make_formspec(pos) object_detector_make_formspec(pos)
@ -18,10 +18,10 @@ end
-- returns true if player was found, false if not -- returns true if player was found, false if not
local object_detector_scan = function (pos) local object_detector_scan = function (pos)
local objs = minetest.env:get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS) local objs = minetest.get_objects_inside_radius(pos, OBJECT_DETECTOR_RADIUS)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil! local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
local scanname = minetest.env:get_meta(pos):get_string("scanname") local scanname = minetest.get_meta(pos):get_string("scanname")
if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified
return true return true
end end
@ -33,7 +33,7 @@ end
object_detector_digiline = { object_detector_digiline = {
effector = { effector = {
action = function (pos, node, channel, msg) action = function (pos, node, channel, msg)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local active_channel = meta:get_string("digiline_channel") local active_channel = meta:get_string("digiline_channel")
if channel == active_channel then if channel == active_channel then
meta:set_string("scanname", msg) meta:set_string("scanname", msg)

View File

@ -27,7 +27,7 @@ function update_gate(pos)
gate = get_gate(pos) gate = get_gate(pos)
L = rotate_ports( L = rotate_ports(
yc_get_real_portstates(pos), yc_get_real_portstates(pos),
minetest.env:get_node(pos).param2 minetest.get_node(pos).param2
) )
if gate == "diode" then if gate == "diode" then
set_gate(pos, L.a) set_gate(pos, L.a)
@ -44,7 +44,7 @@ end
function set_gate(pos, on) function set_gate(pos, on)
gate = get_gate(pos) gate = get_gate(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if on ~= gate_state(pos) then if on ~= gate_state(pos) then
yc_heat(meta) yc_heat(meta)
--minetest.after(0.5, yc_cool, meta) --minetest.after(0.5, yc_cool, meta)
@ -66,19 +66,19 @@ function set_gate(pos, on)
end end
function get_gate(pos) function get_gate(pos)
return minetest.registered_nodes[minetest.env:get_node(pos).name].mesecons_gate return minetest.registered_nodes[minetest.get_node(pos).name].mesecons_gate
end end
function gate_state(pos) function gate_state(pos)
name = minetest.env:get_node(pos).name name = minetest.get_node(pos).name
return string.find(name, "_on") ~= nil return string.find(name, "_on") ~= nil
end end
function pop_gate(pos) function pop_gate(pos)
gate = get_gate(pos) gate = get_gate(pos)
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.after(0.2, yc_overheat_off, pos) minetest.after(0.2, yc_overheat_off, pos)
minetest.env:add_item(pos, "mesecons_gates:"..gate.."_off") minetest.add_item(pos, "mesecons_gates:"..gate.."_off")
end end
function rotate_ports(L, param2) function rotate_ports(L, param2)
@ -151,7 +151,7 @@ for _, gate in ipairs(gates) do
node_box = node_box, node_box = node_box,
walkable = true, walkable = true,
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("heat", 0) meta:set_int("heat", 0)
update_gate(pos) update_gate(pos)
end, end,

View File

@ -63,8 +63,8 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z} local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.env:get_node(waterpos).name=="default:water_flowing" then if minetest.get_node(waterpos).name=="default:water_flowing" then
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"}) minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
end end
@ -77,8 +77,8 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z} local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.env:get_node(waterpos).name~="default:water_flowing" then if minetest.get_node(waterpos).name~="default:water_flowing" then
minetest.env:add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"}) minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
nodeupdate(pos) nodeupdate(pos)
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
end end

View File

@ -172,7 +172,7 @@ local getinterrupt = function(pos)
local interrupt = function (time, iid) -- iid = interrupt id local interrupt = function (time, iid) -- iid = interrupt id
if type(time) ~= "number" then return end if type(time) ~= "number" then return end
local iid = iid or math.random() local iid = iid or math.random()
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {} local interrupts = minetest.deserialize(meta:get_string("lc_interrupts")) or {}
local found = false local found = false
local search = safe_serialize(iid) local search = safe_serialize(iid)
@ -202,7 +202,7 @@ end
local create_environment = function(pos, mem, event) local create_environment = function(pos, mem, event)
-- Gather variables for the environment -- Gather variables for the environment
local vports = minetest.registered_nodes[minetest.env:get_node(pos).name].virtual_portstates local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d} vports = {a = vports.a, b = vports.b, c = vports.c, d = vports.d}
local rports = get_real_portstates(pos) local rports = get_real_portstates(pos)
@ -288,7 +288,7 @@ local do_overheat = function (pos, meta)
if overheat(meta) then if overheat(meta) then
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
minetest.swap_node(pos, {name = BASENAME.."_burnt", param2 = node.param2}) minetest.swap_node(pos, {name = BASENAME.."_burnt", param2 = node.param2})
minetest.env:get_meta(pos):set_string("lc_interrupts", "") minetest.get_meta(pos):set_string("lc_interrupts", "")
minetest.after(0.2, overheat_off, pos) -- wait for pending operations minetest.after(0.2, overheat_off, pos) -- wait for pending operations
return true return true
end end
@ -328,7 +328,7 @@ end
---------------------- ----------------------
lc_update = function (pos, event) lc_update = function (pos, event)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if not interrupt_allow(meta, event) then return end if not interrupt_allow(meta, event) then return end
if do_overheat(pos, meta) then return end if do_overheat(pos, meta) then return end
@ -355,17 +355,10 @@ lc_update = function (pos, event)
end end
local reset_meta = function(pos, code, errmsg) local reset_meta = function(pos, code, errmsg)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("code", code) meta:set_string("code", code)
if minetest.formspec_escape then
code = minetest.formspec_escape(code or "") code = minetest.formspec_escape(code or "")
errmsg = minetest.formspec_escape(errmsg or "") errmsg = minetest.formspec_escape(errmsg or "")
else
code = string.gsub(code or "", "%[", "(") -- would otherwise
code = string.gsub(code, "%]", ")") -- corrupt formspec
errmsg = string.gsub(errmsg or "", "%[", "(") -- would otherwise
errmsg = string.gsub(errmsg, "%]", ")") -- corrupt formspec
end
meta:set_string("formspec", "size[10,8]".. meta:set_string("formspec", "size[10,8]"..
"background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]".. "background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]"..
"textarea[0.2,0.6;10.2,5;code;;"..code.."]".. "textarea[0.2,0.6;10.2,5;code;;"..code.."]"..
@ -376,7 +369,7 @@ local reset_meta = function(pos, code, errmsg)
end end
local reset = function (pos) local reset = function (pos)
minetest.env:get_meta(pos):set_string("lc_interrupts", "") minetest.get_meta(pos):set_string("lc_interrupts", "")
action(pos, {a=false, b=false, c=false, d=false}, true) action(pos, {a=false, b=false, c=false, d=false}, true)
end end

View File

@ -80,7 +80,7 @@ minetest.register_node(nodename, {
} }
}, },
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("code", "") meta:set_string("code", "")
meta:set_string("formspec", "size[9,2.5]".. meta:set_string("formspec", "size[9,2.5]"..
"field[0.256,-0.2;9,2;code;Code:;]".. "field[0.256,-0.2;9,2;code;Code:;]"..
@ -98,7 +98,7 @@ minetest.register_node(nodename, {
meta:set_string("eeprom", r) meta:set_string("eeprom", r)
end, end,
on_receive_fields = function(pos, formanme, fields, sender) on_receive_fields = function(pos, formanme, fields, sender)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if fields.band then if fields.band then
fields.code = "sbi(C, A&B) :A and B are inputs, C is output" fields.code = "sbi(C, A&B) :A and B are inputs, C is output"
elseif fields.bxor then elseif fields.bxor then
@ -151,7 +151,7 @@ minetest.register_craft({
function yc_reset(pos) function yc_reset(pos)
yc_action(pos, {a=false, b=false, c=false, d=false}) yc_action(pos, {a=false, b=false, c=false, d=false})
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("heat", 0) meta:set_int("heat", 0)
meta:set_int("afterid", 0) meta:set_int("afterid", 0)
local r = "" local r = ""
@ -160,13 +160,13 @@ function yc_reset(pos)
end end
function update_yc(pos) function update_yc(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
yc_heat(meta) yc_heat(meta)
--minetest.after(0.5, yc_cool, meta) --minetest.after(0.5, yc_cool, meta)
if (yc_overheat(meta)) then if (yc_overheat(meta)) then
minetest.env:remove_node(pos) minetest.remove_node(pos)
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
minetest.env:add_item(pos, "mesecons_microcontroller:microcontroller0000") minetest.add_item(pos, "mesecons_microcontroller:microcontroller0000")
end end
local code = meta:get_string("code") local code = meta:get_string("code")
@ -195,7 +195,7 @@ function yc_code_remove_commentary(code)
end end
function yc_parsecode(code, pos) function yc_parsecode(code, pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local endi = 1 local endi = 1
local Lreal = yc_get_real_portstates(pos) local Lreal = yc_get_real_portstates(pos)
local Lvirtual = yc_get_virtual_portstates(pos) local Lvirtual = yc_get_virtual_portstates(pos)
@ -243,7 +243,7 @@ function yc_parsecode(code, pos)
end end
if Lvirtual == nil then return nil end if Lvirtual == nil then return nil end
if eeprom == nil then return nil else if eeprom == nil then return nil else
minetest.env:get_meta(pos):set_string("eeprom", eeprom) end minetest.get_meta(pos):set_string("eeprom", eeprom) end
end end
yc_action(pos, Lvirtual) yc_action(pos, Lvirtual)
return true return true
@ -429,14 +429,14 @@ function yc_command_after(params, pos)
local code = string.sub(params[2], 2, #params[2] - 1) local code = string.sub(params[2], 2, #params[2] - 1)
local afterid = math.random(10000) local afterid = math.random(10000)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_int("afterid", afterid) meta:set_int("afterid", afterid)
minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid}) minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid})
return true return true
end end
function yc_command_after_execute(params) function yc_command_after_execute(params)
local meta = minetest.env:get_meta(params.pos) local meta = minetest.get_meta(params.pos)
if meta:get_int("afterid") == params.afterid then --make sure the node has not been changed if meta:get_int("afterid") == params.afterid then --make sure the node has not been changed
if yc_parsecode(params.code, params.pos) == nil then if yc_parsecode(params.code, params.pos) == nil then
meta:set_string("infotext", "Code in after() not valid!") meta:set_string("infotext", "Code in after() not valid!")
@ -653,7 +653,7 @@ function yc_get_real_portstates(pos) -- port powered or not (by itself or from o
end end
function yc_get_virtual_portstates(pos) -- portstates according to the name function yc_get_virtual_portstates(pos) -- portstates according to the name
name = minetest.env:get_node(pos).name name = minetest.get_node(pos).name
b, a = string.find(name, ":microcontroller") b, a = string.find(name, ":microcontroller")
if a == nil then return nil end if a == nil then return nil end
a = a + 1 a = a + 1

View File

@ -66,9 +66,9 @@ minetest.register_node("mesecons_movestones:movestone", {
action_on = function (pos, node) action_on = function (pos, node)
local direction=mesecon:get_movestone_direction(pos) local direction=mesecon:get_movestone_direction(pos)
if not direction then return end if not direction then return end
minetest.env:remove_node(pos) minetest.remove_node(pos)
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity") minetest.add_entity(pos, "mesecons_movestones:movestone_entity")
end end
}} }}
}) })
@ -93,13 +93,13 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
if not direction then -- no mesecon power if not direction then -- no mesecon power
--push only solid nodes --push only solid nodes
local name = minetest.env:get_node(pos).name local name = minetest.get_node(pos).name
if name ~= "air" and name ~= "ignore" if name ~= "air" and name ~= "ignore"
and ((not minetest.registered_nodes[name]) and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then or minetest.registered_nodes[name].liquidtype == "none") then
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH) mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
end end
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"}) minetest.add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove() self.object:remove()
return return
end end
@ -107,7 +107,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
local success, stack, oldstack = local success, stack, oldstack =
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH) mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
if not success then -- Too large stack/stopper in the way if not success then -- Too large stack/stopper in the way
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"}) minetest.add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove() self.object:remove()
return return
else else
@ -145,9 +145,9 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
action_on = function (pos, node) action_on = function (pos, node)
local direction=mesecon:get_movestone_direction(pos) local direction=mesecon:get_movestone_direction(pos)
if not direction then return end if not direction then return end
minetest.env:remove_node(pos) minetest.remove_node(pos)
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity") minetest.add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
end end
}} }}
}) })
@ -179,7 +179,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
if not direction then -- no mesecon power if not direction then -- no mesecon power
--push only solid nodes --push only solid nodes
local name = minetest.env:get_node(pos).name local name = minetest.get_node(pos).name
if name ~= "air" and name ~= "ignore" if name ~= "air" and name ~= "ignore"
and ((not minetest.registered_nodes[name]) and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then or minetest.registered_nodes[name].liquidtype == "none") then
@ -187,7 +187,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
--STICKY --STICKY
mesecon:mvps_pull_all(pos, self.lastdir) mesecon:mvps_pull_all(pos, self.lastdir)
end end
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"}) minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove() self.object:remove()
return return
end end
@ -195,7 +195,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
local success, stack, oldstack = local success, stack, oldstack =
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH) mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
if not success then -- Too large stack/stopper in the way if not success then -- Too large stack/stopper in the way
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"}) minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove() self.object:remove()
return return
else else

View File

@ -31,7 +31,7 @@ function mesecon:mvps_process_stack(stack)
-- update mesecons for placed nodes ( has to be done after all nodes have been added ) -- update mesecons for placed nodes ( has to be done after all nodes have been added )
for _, n in ipairs(stack) do for _, n in ipairs(stack) do
nodeupdate(n.pos) nodeupdate(n.pos)
mesecon.on_placenode(n.pos, minetest.env:get_node(n.pos)) mesecon.on_placenode(n.pos, minetest.get_node(n.pos))
mesecon:update_autoconnect(n.pos) mesecon:update_autoconnect(n.pos)
end end
end end
@ -41,7 +41,7 @@ function mesecon:mvps_get_stack(pos, dir, maximum)
local np = {x = pos.x, y = pos.y, z = pos.z} local np = {x = pos.x, y = pos.y, z = pos.z}
local nodes = {} local nodes = {}
while true do while true do
local nn = minetest.env:get_node_or_nil(np) local nn = minetest.get_node_or_nil(np)
if not nn or #nodes > maximum then if not nn or #nodes > maximum then
-- don't push at all, something is in the way (unloaded map or too many nodes) -- don't push at all, something is in the way (unloaded map or too many nodes)
return nil return nil
@ -73,8 +73,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- remove all nodes -- remove all nodes
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
n.meta = minetest.env:get_meta(n.pos):to_table() n.meta = minetest.get_meta(n.pos):to_table()
minetest.env:remove_node(n.pos) minetest.remove_node(n.pos)
end end
-- update mesecons for removed nodes ( has to be done after all nodes have been removed ) -- update mesecons for removed nodes ( has to be done after all nodes have been removed )
@ -86,8 +86,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- add nodes -- add nodes
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
np = mesecon:addPosRule(n.pos, dir) np = mesecon:addPosRule(n.pos, dir)
minetest.env:add_node(np, n.node) minetest.add_node(np, n.node)
minetest.env:get_meta(np):from_table(n.meta) minetest.get_meta(np):from_table(n.meta)
end end
local oldstack = mesecon:tablecopy(nodes) local oldstack = mesecon:tablecopy(nodes)
@ -105,15 +105,15 @@ end
function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons) function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: direction of pull (matches push direction for sticky pistons)
np = mesecon:addPosRule(pos, dir) np = mesecon:addPosRule(pos, dir)
nn = minetest.env:get_node(np) nn = minetest.get_node(np)
if ((not minetest.registered_nodes[nn.name]) --unregistered node if ((not minetest.registered_nodes[nn.name]) --unregistered node
or minetest.registered_nodes[nn.name].liquidtype == "none") --non-liquid 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 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.env:get_meta(np):to_table() local meta = minetest.get_meta(np):to_table()
minetest.env:remove_node(np) minetest.remove_node(np)
minetest.env:add_node(pos, nn) minetest.add_node(pos, nn)
minetest.env:get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
nodeupdate(np) nodeupdate(np)
nodeupdate(pos) nodeupdate(pos)
@ -127,9 +127,9 @@ end
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
local lnode = minetest.env:get_node(lpos) local 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 lpos2 = {x=pos.x-direction.x*2, y=pos.y-direction.y*2, z=pos.z-direction.z*2} -- 2 away
local lnode2 = minetest.env:get_node(lpos2) local lnode2 = minetest.get_node(lpos2)
--avoid pulling solid nodes --avoid pulling solid nodes
if lnode.name ~= "ignore" if lnode.name ~= "ignore"
@ -149,19 +149,19 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
local oldpos = {x=lpos2.x + direction.x, y=lpos2.y + direction.y, z=lpos2.z + direction.z} local oldpos = {x=lpos2.x + direction.x, y=lpos2.y + direction.y, z=lpos2.z + direction.z}
repeat repeat
lnode2 = minetest.env:get_node(lpos2) lnode2 = minetest.get_node(lpos2)
minetest.env:add_node(oldpos, {name=lnode2.name}) minetest.add_node(oldpos, {name=lnode2.name})
nodeupdate(oldpos) nodeupdate(oldpos)
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z} oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
lpos2.x = lpos2.x-direction.x lpos2.x = lpos2.x-direction.x
lpos2.y = lpos2.y-direction.y lpos2.y = lpos2.y-direction.y
lpos2.z = lpos2.z-direction.z lpos2.z = lpos2.z-direction.z
lnode = minetest.env:get_node(lpos2) lnode = minetest.get_node(lpos2)
until lnode.name == "air" until lnode.name == "air"
or lnode.name == "ignore" or lnode.name == "ignore"
or (minetest.registered_nodes[lnode2.name] or (minetest.registered_nodes[lnode2.name]
and minetest.registered_nodes[lnode2.name].liquidtype ~= "none") and minetest.registered_nodes[lnode2.name].liquidtype ~= "none")
minetest.env:remove_node(oldpos) minetest.remove_node(oldpos)
end end
function mesecon:mvps_move_objects(pos, dir, nodestack) function mesecon:mvps_move_objects(pos, dir, nodestack)
@ -174,7 +174,7 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
z = dir.z * #nodestack}) z = dir.z * #nodestack})
local objects = minetest.env: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
table.insert(objects_to_move, obj) table.insert(objects_to_move, obj)
end end
@ -184,7 +184,7 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
-- 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 = mesecon:addPosRule(n.pos, {x=0, y=1, z=0})
local objects = minetest.env: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)
end end
@ -197,7 +197,7 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
local np = mesecon:addPosRule(obj:getpos(), dir) local np = mesecon:addPosRule(obj:getpos(), dir)
--move only if destination is not solid --move only if destination is not solid
local nn = minetest.env:get_node(np) local nn = minetest.get_node(np)
if not ((not minetest.registered_nodes[nn.name]) if not ((not minetest.registered_nodes[nn.name])
or minetest.registered_nodes[nn.name].walkable) then or minetest.registered_nodes[nn.name].walkable) then
obj:setpos(np) obj:setpos(np)

View File

@ -6,12 +6,12 @@ minetest.register_node("mesecons_noteblock:noteblock", {
visual_scale = 1.3, visual_scale = 1.3,
paramtype="light", paramtype="light",
after_place_node = function(pos) after_place_node = function(pos)
minetest.env: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.env: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(),
@ -58,7 +58,7 @@ mesecon.noteblock_play = function (pos, param2)
elseif param2==7 then elseif param2==7 then
soundname="mesecons_noteblock_gsharp" soundname="mesecons_noteblock_gsharp"
end end
local block_below_name = minetest.env: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

View File

@ -62,9 +62,9 @@ local piston_remove_pusher = function(pos, node)
dir = piston_get_direction(pistonspec.dir, node) dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(pos, dir) local pusherpos = mesecon:addPosRule(pos, dir)
local pushername = minetest.env:get_node(pusherpos).name local pushername = minetest.get_node(pusherpos).name
minetest.env:remove_node(pusherpos) minetest.remove_node(pusherpos)
minetest.sound_play("piston_retract", { minetest.sound_play("piston_retract", {
pos = pos, pos = pos,
max_hear_distance = 20, max_hear_distance = 20,
@ -80,8 +80,8 @@ local piston_on = function(pos, node)
local np = mesecon:addPosRule(pos, dir) local np = mesecon:addPosRule(pos, dir)
local success, stack, oldstack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH) local success, stack, oldstack = mesecon:mvps_push(np, dir, PISTON_MAXIMUM_PUSH)
if success then if success then
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.onname}) minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname})
minetest.env:add_node(np, {param2 = node.param2, name = pistonspec.pusher}) minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher})
minetest.sound_play("piston_extend", { minetest.sound_play("piston_extend", {
pos = pos, pos = pos,
max_hear_distance = 20, max_hear_distance = 20,
@ -94,7 +94,7 @@ end
local piston_off = function(pos, node) local piston_off = function(pos, node)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
minetest.env:add_node(pos, {param2 = node.param2, name = pistonspec.offname}) minetest.add_node(pos, {param2 = node.param2, name = pistonspec.offname})
piston_remove_pusher(pos, node) piston_remove_pusher(pos, node)
if pistonspec.sticky then if pistonspec.sticky then
@ -112,12 +112,12 @@ local piston_orientate = function(pos, placer)
-- placer pitch in degrees -- placer pitch in degrees
local pitch = placer:get_look_pitch() * (180 / math.pi) local pitch = placer:get_look_pitch() * (180 / math.pi)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
if pitch > 55 then --looking upwards if pitch > 55 then --looking upwards
minetest.env:add_node(pos, {name=pistonspec.piston_down}) minetest.add_node(pos, {name=pistonspec.piston_down})
elseif pitch < -55 then --looking downwards elseif pitch < -55 then --looking downwards
minetest.env:add_node(pos, {name=pistonspec.piston_up}) minetest.add_node(pos, {name=pistonspec.piston_up})
end end
end end
@ -717,7 +717,7 @@ local piston_get_stopper = function (node, dir, stack, stackid)
pistonspec = minetest.registered_nodes[node.name].mesecons_piston pistonspec = minetest.registered_nodes[node.name].mesecons_piston
dir = piston_get_direction(pistonspec.dir, node) dir = piston_get_direction(pistonspec.dir, node)
local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir) local pusherpos = mesecon:addPosRule(stack[stackid].pos, dir)
local pushernode = minetest.env:get_node(pusherpos) local pushernode = minetest.get_node(pusherpos)
if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then if minetest.registered_nodes[node.name].mesecons_piston.pusher == pushernode.name then
for _, s in ipairs(stack) do for _, s in ipairs(stack) do

View File

@ -9,18 +9,18 @@ local pp_box_on = {
} }
pp_on_timer = function (pos, elapsed) pp_on_timer = function (pos, elapsed)
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local ppspec = minetest.registered_nodes[node.name].pressureplate local ppspec = minetest.registered_nodes[node.name].pressureplate
-- 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 ppspec then return end
local objs = minetest.env: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 = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
if objs[1] == nil and node.name == ppspec.onstate then if objs[1] == nil and node.name == ppspec.onstate then
minetest.env:add_node(pos, {name = ppspec.offstate}) minetest.add_node(pos, {name = ppspec.offstate})
mesecon:receptor_off(pos) mesecon:receptor_off(pos)
-- force deactivation of mesecon two blocks below (hacky) -- force deactivation of mesecon two blocks below (hacky)
if not mesecon:connected_to_receptor(two_below) then if not mesecon:connected_to_receptor(two_below) then
@ -30,7 +30,7 @@ pp_on_timer = function (pos, elapsed)
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local objpos = obj:getpos() local objpos = obj:getpos()
if objpos.y > pos.y-1 and objpos.y < pos.y then if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.env:add_node(pos, {name=ppspec.onstate}) minetest.add_node(pos, {name=ppspec.onstate})
mesecon:receptor_on(pos) mesecon:receptor_on(pos)
-- force activation of mesecon two blocks below (hacky) -- force activation of mesecon two blocks below (hacky)
mesecon:turnon(two_below) mesecon:turnon(two_below)
@ -71,7 +71,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
state = mesecon.state.off state = mesecon.state.off
}}, }},
on_construct = function(pos) on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end, end,
}) })
@ -90,7 +90,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
state = mesecon.state.on state = mesecon.state.on
}}, }},
on_construct = function(pos) on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL) minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end, end,
after_dig_node = function(pos) after_dig_node = function(pos)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}) local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})

View File

@ -8,7 +8,7 @@ minetest.register_node("mesecons_random:removestone", {
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
mesecons = {effector = { mesecons = {effector = {
action_on = function (pos, node) action_on = function (pos, node)
minetest.env:remove_node(pos) minetest.remove_node(pos)
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
end end
}} }}
@ -68,8 +68,8 @@ minetest.register_node("mesecons_random:ghoststone_active", {
on_construct = function(pos) on_construct = function(pos)
--remove shadow --remove shadow
pos2 = {x = pos.x, y = pos.y + 1, z = pos.z} pos2 = {x = pos.x, y = pos.y + 1, z = pos.z}
if ( minetest.env:get_node(pos2).name == "air" ) then if ( minetest.get_node(pos2).name == "air" ) then
minetest.env:dig_node(pos2) minetest.dig_node(pos2)
end end
end end
}) })

View File

@ -91,7 +91,7 @@ mesecon:add_rules("receiver_pos_all", {
function mesecon:receiver_get_pos_from_rcpt(pos, param2) function mesecon:receiver_get_pos_from_rcpt(pos, param2)
local rules = mesecon:get_rules("receiver_pos") local rules = mesecon:get_rules("receiver_pos")
if param2 == nil then param2 = minetest.env:get_node(pos).param2 end if param2 == nil then param2 = minetest.get_node(pos).param2 end
if param2 == 2 then if param2 == 2 then
rules = mesecon:rotate_rules_left(rules) rules = mesecon:rotate_rules_left(rules)
elseif param2 == 3 then elseif param2 == 3 then
@ -107,17 +107,17 @@ function mesecon:receiver_get_pos_from_rcpt(pos, param2)
end end
function mesecon:receiver_place(rcpt_pos) function mesecon:receiver_place(rcpt_pos)
local node = minetest.env:get_node(rcpt_pos) local node = minetest.get_node(rcpt_pos)
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2) local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
local nn = minetest.env:get_node(pos) local nn = minetest.get_node(pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.env:dig_node(pos) minetest.dig_node(pos)
if mesecon:is_power_on(rcpt_pos) then if mesecon:is_power_on(rcpt_pos) then
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2}) minetest.add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
mesecon:receptor_on(pos, receiver_get_rules(node)) mesecon:receptor_on(pos, receiver_get_rules(node))
else else
minetest.env:add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2}) minetest.add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
end end
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
end end
@ -125,11 +125,11 @@ end
function mesecon:receiver_remove(rcpt_pos, dugnode) function mesecon:receiver_remove(rcpt_pos, dugnode)
local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2) local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
local nn = minetest.env:get_node(pos) local nn = minetest.get_node(pos)
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.env:dig_node(pos) minetest.dig_node(pos)
local node = {name = "mesecons:wire_00000000_off"} local node = {name = "mesecons:wire_00000000_off"}
minetest.env:add_node(pos, node) minetest.add_node(pos, node)
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
mesecon.on_placenode(pos, node) mesecon.on_placenode(pos, node)
end end
@ -156,7 +156,7 @@ minetest.register_on_placenode(function (pos, node)
x = pos.x + rules[i].x, x = pos.x + rules[i].x,
y = pos.y + rules[i].y, y = pos.y + rules[i].y,
z = pos.z + rules[i].z} z = pos.z + rules[i].z}
if minetest.get_item_group(minetest.env:get_node(np).name, "mesecon_needs_receiver") == 1 then if minetest.get_item_group(minetest.get_node(np).name, "mesecon_needs_receiver") == 1 then
mesecon:receiver_place(np) mesecon:receiver_place(np)
end end
i = i + 1 i = i + 1

View File

@ -71,10 +71,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light >= 12 then if light >= 12 then
minetest.env: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,
@ -85,10 +85,10 @@ minetest.register_abm(
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.env:get_node_light(pos, nil) local light = minetest.get_node_light(pos, nil)
if light < 12 then if light < 12 then
minetest.env: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,