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
mesecon:turnoff(np, rulename)
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

View File

@ -237,7 +237,7 @@ function execute_actions(dtime)
local nactions = mesecon.to_update
mesecon.to_update = {}
for _,i in ipairs(nactions) do
node = minetest.env:get_node(i.pos)
node = minetest.get_node(i.pos)
if node.name=="ignore" then
add_action(i.pos, i.action, i.rname)
else
@ -395,7 +395,7 @@ end
-- some more general high-level stuff
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
return true
end
@ -403,7 +403,7 @@ function mesecon:is_power_on(pos, rulename)
end
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
return true
end
@ -411,7 +411,7 @@ function mesecon:is_power_off(pos, rulename)
end
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
local rules = mesecon:conductor_get_rules(node)
@ -425,7 +425,7 @@ function mesecon:turnon(pos, rulename)
return
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
local np = mesecon:addPosRule(pos, rule)
@ -444,7 +444,7 @@ function mesecon:turnon(pos, rulename)
end
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
local rules = mesecon:conductor_get_rules(node)
@ -458,7 +458,7 @@ function mesecon:turnoff(pos, rulename)
return
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
local np = mesecon:addPosRule(pos, rule)
@ -479,7 +479,7 @@ end
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
local rules = mesecon:get_any_inputrules(node)
@ -507,7 +507,7 @@ function mesecon:find_receptor_on(pos, checked, rulename)
-- add current position to checked
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
return true
@ -529,8 +529,8 @@ function mesecon:find_receptor_on(pos, checked, rulename)
end
function mesecon:rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
local outputnode = minetest.env:get_node(output)
local inputnode = minetest.env:get_node(input)
local outputnode = minetest.get_node(output)
local inputnode = minetest.get_node(input)
local outputrules = dug_outputrules or mesecon:get_any_outputrules (outputnode)
local inputrules = mesecon:get_any_inputrules (inputnode)
if not outputrules or not inputrules then
@ -556,14 +556,14 @@ function mesecon:rules_link_anydir(pos1, pos2)
end
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)
if not rules then return false end
if not rule then
for _, rule in ipairs(mesecon:flattenrules(rules)) do
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))
and mesecon:rules_link(np, pos) then
@ -572,7 +572,7 @@ function mesecon:is_powered(pos, rule)
end
else
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))
and mesecon:rules_link(np, pos) then

View File

@ -29,7 +29,7 @@ minetest.register_abm({
interval = 1.0,
chance = 1,
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)
end,
})

View File

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

View File

@ -207,7 +207,7 @@ function mesecon:update_autoconnect(pos, secondcall, replace_old)
mesecon:update_autoconnect(zmympos, true)
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 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
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_off"})
else
minetest.env:set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
minetest.set_node(pos, {name = "mesecons:wire_"..nodeid.."_on" })
end
end

View File

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

View File

@ -3,7 +3,7 @@
-- and then turns off again
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
minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2})
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)
return
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)
end
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)
return
end
local player = minetest.env:get_player_by_name(target)
local player = minetest.get_player_by_name(target)
if player then
player:set_hp(value)
else
@ -72,7 +72,7 @@ local initialize_data = function(meta, player, command, param)
end
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("command", "time")
@ -85,14 +85,14 @@ end
local after_place = function(pos, placer)
if placer then
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
initialize_data(meta, "@nearest", "time", "7000")
end
end
local receive_fields = function(pos, formname, fields, sender)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if fields.nearest then
initialize_data(meta, "@nearest", fields.command, fields.param)
elseif fields.farthest then
@ -146,7 +146,7 @@ local commandblock_action_on = function(pos, node)
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")]
if command == nil then
return
@ -179,7 +179,7 @@ minetest.register_node("mesecons_commandblock:commandblock_off", {
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = function(pos,player)
local owner = minetest.env:get_meta(pos):get_string("owner")
local owner = minetest.get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name()
end,
sounds = default.node_sound_stone_defaults(),
@ -197,7 +197,7 @@ minetest.register_node("mesecons_commandblock:commandblock_on", {
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = function(pos,player)
local owner = minetest.env:get_meta(pos):get_string("owner")
local owner = minetest.get_meta(pos):get_string("owner")
return owner == "" or owner == player:get_player_name()
end,
sounds = default.node_sound_stone_defaults(),

View File

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

View File

@ -3,14 +3,14 @@
-- The radius can be specified in mesecons/settings.lua
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]" ..
"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}]")
end
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("digiline_channel", fields.digiline_channel)
object_detector_make_formspec(pos)
@ -18,10 +18,10 @@ end
-- returns true if player was found, false if not
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
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
return true
end
@ -33,7 +33,7 @@ end
object_detector_digiline = {
effector = {
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")
if channel == active_channel then
meta:set_string("scanname", msg)

View File

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

View File

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

View File

@ -172,7 +172,7 @@ local getinterrupt = function(pos)
local interrupt = function (time, iid) -- iid = interrupt id
if type(time) ~= "number" then return end
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 found = false
local search = safe_serialize(iid)
@ -202,7 +202,7 @@ end
local create_environment = function(pos, mem, event)
-- 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}
local rports = get_real_portstates(pos)
@ -288,7 +288,7 @@ local do_overheat = function (pos, meta)
if overheat(meta) then
local node = minetest.get_node(pos)
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
return true
end
@ -328,7 +328,7 @@ end
----------------------
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 do_overheat(pos, meta) then return end
@ -355,17 +355,10 @@ lc_update = function (pos, event)
end
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)
if minetest.formspec_escape then
code = minetest.formspec_escape(code 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
code = minetest.formspec_escape(code or "")
errmsg = minetest.formspec_escape(errmsg or "")
meta:set_string("formspec", "size[10,8]"..
"background[-0.2,-0.25;10.4,8.75;jeija_luac_background.png]"..
"textarea[0.2,0.6;10.2,5;code;;"..code.."]"..
@ -376,7 +369,7 @@ local reset_meta = function(pos, code, errmsg)
end
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)
end

View File

@ -80,7 +80,7 @@ minetest.register_node(nodename, {
}
},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("code", "")
meta:set_string("formspec", "size[9,2.5]"..
"field[0.256,-0.2;9,2;code;Code:;]"..
@ -98,7 +98,7 @@ minetest.register_node(nodename, {
meta:set_string("eeprom", r)
end,
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
fields.code = "sbi(C, A&B) :A and B are inputs, C is output"
elseif fields.bxor then
@ -151,7 +151,7 @@ minetest.register_craft({
function yc_reset(pos)
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("afterid", 0)
local r = ""
@ -160,13 +160,13 @@ function yc_reset(pos)
end
function update_yc(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
yc_heat(meta)
--minetest.after(0.5, yc_cool, meta)
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.env:add_item(pos, "mesecons_microcontroller:microcontroller0000")
minetest.add_item(pos, "mesecons_microcontroller:microcontroller0000")
end
local code = meta:get_string("code")
@ -195,7 +195,7 @@ function yc_code_remove_commentary(code)
end
function yc_parsecode(code, pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local endi = 1
local Lreal = yc_get_real_portstates(pos)
local Lvirtual = yc_get_virtual_portstates(pos)
@ -243,7 +243,7 @@ function yc_parsecode(code, pos)
end
if Lvirtual == nil then return nil end
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
yc_action(pos, Lvirtual)
return true
@ -429,14 +429,14 @@ function yc_command_after(params, pos)
local code = string.sub(params[2], 2, #params[2] - 1)
local afterid = math.random(10000)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("afterid", afterid)
minetest.after(time, yc_command_after_execute, {pos = pos, code = code, afterid = afterid})
return true
end
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 yc_parsecode(params.code, params.pos) == nil then
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
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")
if a == nil then return nil end
a = a + 1

View File

@ -66,9 +66,9 @@ minetest.register_node("mesecons_movestones:movestone", {
action_on = function (pos, node)
local direction=mesecon:get_movestone_direction(pos)
if not direction then return end
minetest.env:remove_node(pos)
minetest.remove_node(pos)
mesecon:update_autoconnect(pos)
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
minetest.add_entity(pos, "mesecons_movestones:movestone_entity")
end
}}
})
@ -93,13 +93,13 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
if not direction then -- no mesecon power
--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"
and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then
mesecon:mvps_push(pos, self.lastdir, MOVESTONE_MAXIMUM_PUSH)
end
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
minetest.add_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove()
return
end
@ -107,7 +107,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
local success, stack, oldstack =
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
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()
return
else
@ -145,9 +145,9 @@ minetest.register_node("mesecons_movestones:sticky_movestone", {
action_on = function (pos, node)
local direction=mesecon:get_movestone_direction(pos)
if not direction then return end
minetest.env:remove_node(pos)
minetest.remove_node(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
}}
})
@ -179,7 +179,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
if not direction then -- no mesecon power
--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"
and ((not minetest.registered_nodes[name])
or minetest.registered_nodes[name].liquidtype == "none") then
@ -187,7 +187,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
--STICKY
mesecon:mvps_pull_all(pos, self.lastdir)
end
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
minetest.add_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove()
return
end
@ -195,7 +195,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
local success, stack, oldstack =
mesecon:mvps_push(pos, direction, MOVESTONE_MAXIMUM_PUSH)
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()
return
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 )
for _, n in ipairs(stack) do
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)
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 nodes = {}
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
-- don't push at all, something is in the way (unloaded map or too many nodes)
return nil
@ -73,8 +73,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- remove all nodes
for _, n in ipairs(nodes) do
n.meta = minetest.env:get_meta(n.pos):to_table()
minetest.env:remove_node(n.pos)
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 )
@ -86,8 +86,8 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- add nodes
for _, n in ipairs(nodes) do
np = mesecon:addPosRule(n.pos, dir)
minetest.env:add_node(np, n.node)
minetest.env:get_meta(np):from_table(n.meta)
minetest.add_node(np, n.node)
minetest.get_meta(np):from_table(n.meta)
end
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)
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
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.env:get_meta(np):to_table()
minetest.env:remove_node(np)
minetest.env:add_node(pos, nn)
minetest.env:get_meta(pos):from_table(meta)
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)
@ -127,9 +127,9 @@ end
function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: direction of pull
local lpos = {x=pos.x-direction.x, y=pos.y-direction.y, z=pos.z-direction.z} -- 1 away
local lnode = minetest.env:get_node(lpos)
local 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.env:get_node(lpos2)
local lnode2 = minetest.get_node(lpos2)
--avoid pulling solid nodes
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}
repeat
lnode2 = minetest.env:get_node(lpos2)
minetest.env:add_node(oldpos, {name=lnode2.name})
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.env:get_node(lpos2)
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.env:remove_node(oldpos)
minetest.remove_node(oldpos)
end
function mesecon:mvps_move_objects(pos, dir, nodestack)
@ -174,7 +174,7 @@ function mesecon:mvps_move_objects(pos, dir, 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
table.insert(objects_to_move, obj)
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
for _, n in ipairs(nodestack) do
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
table.insert(objects_to_move, obj)
end
@ -197,7 +197,7 @@ function mesecon:mvps_move_objects(pos, dir, nodestack)
local np = mesecon:addPosRule(obj:getpos(), dir)
--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])
or minetest.registered_nodes[nn.name].walkable) then
obj:setpos(np)

View File

@ -6,12 +6,12 @@ minetest.register_node("mesecons_noteblock:noteblock", {
visual_scale = 1.3,
paramtype="light",
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,
on_punch = function (pos, node) -- change sound when punched
local param2 = node.param2+1
if param2==12 then param2=0 end
minetest.env:add_node(pos, {name = node.name, param2 = param2})
minetest.add_node(pos, {name = node.name, param2 = param2})
mesecon.noteblock_play(pos, param2)
end,
sounds = default.node_sound_wood_defaults(),
@ -58,7 +58,7 @@ mesecon.noteblock_play = function (pos, param2)
elseif param2==7 then
soundname="mesecons_noteblock_gsharp"
end
local block_below_name = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
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
soundname="mesecons_noteblock_hihat"
end

View File

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

View File

@ -9,18 +9,18 @@ local pp_box_on = {
}
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
-- This is a workaround for a strange bug that occurs when the server is started
-- For some reason the first time on_timer is called, the pos is wrong
if not ppspec then return end
local objs = minetest.env:get_objects_inside_radius(pos, 1)
local objs = minetest.get_objects_inside_radius(pos, 1)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})
if objs[1] == nil and node.name == ppspec.onstate then
minetest.env:add_node(pos, {name = ppspec.offstate})
minetest.add_node(pos, {name = ppspec.offstate})
mesecon:receptor_off(pos)
-- force deactivation of mesecon two blocks below (hacky)
if not mesecon:connected_to_receptor(two_below) then
@ -30,7 +30,7 @@ pp_on_timer = function (pos, elapsed)
for k, obj in pairs(objs) do
local objpos = obj:getpos()
if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.env:add_node(pos, {name=ppspec.onstate})
minetest.add_node(pos, {name=ppspec.onstate})
mesecon:receptor_on(pos)
-- force activation of mesecon two blocks below (hacky)
mesecon:turnon(two_below)
@ -71,7 +71,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
state = mesecon.state.off
}},
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
minetest.get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
end,
})
@ -90,7 +90,7 @@ function mesecon:register_pressure_plate(offstate, onstate, description, texture
state = mesecon.state.on
}},
on_construct = function(pos)
minetest.env:get_node_timer(pos):start(PRESSURE_PLATE_INTERVAL)
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})

View File

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

View File

@ -91,7 +91,7 @@ mesecon:add_rules("receiver_pos_all", {
function mesecon:receiver_get_pos_from_rcpt(pos, param2)
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
rules = mesecon:rotate_rules_left(rules)
elseif param2 == 3 then
@ -107,17 +107,17 @@ function mesecon:receiver_get_pos_from_rcpt(pos, param2)
end
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 nn = minetest.env:get_node(pos)
local nn = minetest.get_node(pos)
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
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))
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
mesecon:update_autoconnect(pos)
end
@ -125,11 +125,11 @@ end
function mesecon:receiver_remove(rcpt_pos, dugnode)
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
minetest.env:dig_node(pos)
minetest.dig_node(pos)
local node = {name = "mesecons:wire_00000000_off"}
minetest.env:add_node(pos, node)
minetest.add_node(pos, node)
mesecon:update_autoconnect(pos)
mesecon.on_placenode(pos, node)
end
@ -156,7 +156,7 @@ minetest.register_on_placenode(function (pos, node)
x = pos.x + rules[i].x,
y = pos.y + rules[i].y,
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)
end
i = i + 1

View File

@ -71,10 +71,10 @@ minetest.register_abm(
interval = 1,
chance = 1,
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
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)
end
end,
@ -85,10 +85,10 @@ minetest.register_abm(
interval = 1,
chance = 1,
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
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)
end
end,