Phased out all deprecated minetest.env:* uses in favor of minetest.*

master
Vanessa Ezekowitz 2013-06-30 23:55:07 -04:00
parent 4a88ed096d
commit 17ee4f6aab
11 changed files with 151 additions and 151 deletions

View File

@ -43,18 +43,18 @@ minetest.register_node("pipeworks:autocrafter",{
tiles={"pipeworks_autocrafter.png"},
groups={snappy=3,tubedevice=1,tubedevice_receiver=1},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("src",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("src",stack)
end,
input_inventory="dst"},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,11]"..
"list[current_name;recipe;0,0;3,3;]"..
@ -68,7 +68,7 @@ minetest.register_node("pipeworks:autocrafter",{
inv:set_size("dst",4*3)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return (inv:is_empty("src") and inv:is_empty("recipe") and inv:is_empty("dst"))
end,
@ -78,7 +78,7 @@ minetest.register_node("pipeworks:autocrafter",{
minetest.register_abm({nodenames={"pipeworks:autocrafter"},interval=1,chance=1,
action=function(pos,node)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
autocraft(inv)
end

View File

@ -19,14 +19,14 @@ function pipe_scanforobjects(pos)
end
function pipe_autoroute(pos, state)
nctr = minetest.env:get_node(pos)
nctr = minetest.get_node(pos)
if (string.find(nctr.name, "pipeworks:pipe_") == nil) then return end
pipes_scansurroundings(pos)
nsurround = pxm..pxp..pym..pyp..pzm..pzp
if nsurround == "000000" then nsurround = "110000" end
minetest.env:add_node(pos, { name = "pipeworks:pipe_"..nsurround..state })
minetest.add_node(pos, { name = "pipeworks:pipe_"..nsurround..state })
end
-- autorouting for pneumatic tubes
@ -62,14 +62,14 @@ function tube_autoroute(pos)
local pzm=0
local pzp=0
local nxm = minetest.env:get_node({ x=pos.x-1, y=pos.y , z=pos.z })
local nxp = minetest.env:get_node({ x=pos.x+1, y=pos.y , z=pos.z })
local nym = minetest.env:get_node({ x=pos.x , y=pos.y-1, z=pos.z })
local nyp = minetest.env:get_node({ x=pos.x , y=pos.y+1, z=pos.z })
local nzm = minetest.env:get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
local nzp = minetest.env:get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
local nxm = minetest.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
local nxp = minetest.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
local nym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
local nyp = minetest.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
local nzm = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
local nzp = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
local nctr = minetest.env:get_node(pos)
local nctr = minetest.get_node(pos)
-- handle the tubes themselves
@ -264,11 +264,11 @@ function tube_autoroute(pos)
nsurround = pxm..pxp..pym..pyp..pzm..pzp
if is_tube(nctr.name) then
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local meta0=meta:to_table()
nctr.name=string.sub(nctr.name,1,-7)..nsurround
minetest.env:add_node(pos, nctr)
local meta=minetest.env:get_meta(pos)
minetest.add_node(pos, nctr)
local meta=minetest.get_meta(pos)
meta:from_table(meta0)
end
@ -284,12 +284,12 @@ function pipes_scansurroundings(pos)
pzm=0
pzp=0
nxm = minetest.env:get_node({ x=pos.x-1, y=pos.y , z=pos.z })
nxp = minetest.env:get_node({ x=pos.x+1, y=pos.y , z=pos.z })
nym = minetest.env:get_node({ x=pos.x , y=pos.y-1, z=pos.z })
nyp = minetest.env:get_node({ x=pos.x , y=pos.y+1, z=pos.z })
nzm = minetest.env:get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
nzp = minetest.env:get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
nxm = minetest.get_node({ x=pos.x-1, y=pos.y , z=pos.z })
nxp = minetest.get_node({ x=pos.x+1, y=pos.y , z=pos.z })
nym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
nyp = minetest.get_node({ x=pos.x , y=pos.y+1, z=pos.z })
nzm = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z-1 })
nzp = minetest.get_node({ x=pos.x , y=pos.y , z=pos.z+1 })
if (string.find(nxm.name, "pipeworks:pipe_") ~= nil) then pxm=1 end
if (string.find(nxp.name, "pipeworks:pipe_") ~= nil) then pxp=1 end
@ -434,11 +434,11 @@ function pipes_scansurroundings(pos)
end
function pipe_look_for_stackable_tanks(pos)
local tym = minetest.env:get_node({ x=pos.x , y=pos.y-1, z=pos.z })
local tym = minetest.get_node({ x=pos.x , y=pos.y-1, z=pos.z })
if string.find(tym.name, "pipeworks:storage_tank_") ~= nil or
string.find(tym.name, "pipeworks:expansion_tank_") ~= nil then
minetest.env:add_node(pos, { name = "pipeworks:expansion_tank_0", param2 = tym.param2})
minetest.add_node(pos, { name = "pipeworks:expansion_tank_0", param2 = tym.param2})
end
end

View File

@ -13,7 +13,7 @@ furnace=clone_node("default:furnace")
furnace.groups.tubedevice=1
furnace.groups.tubedevice_receiver=1
furnace.tube={insert_object = function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
if direction.y==1 then
return inv:add_item("fuel",stack)
@ -22,7 +22,7 @@ furnace=clone_node("default:furnace")
end
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
if direction.y==1 then
return inv:room_for_item("fuel",stack)
@ -46,7 +46,7 @@ furnace=clone_node("default:furnace_active")
furnace.groups.tubedevice=1
furnace.groups.tubedevice_receiver=1
furnace.tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
if direction.y==1 then
return inv:add_item("fuel",stack)
@ -55,7 +55,7 @@ furnace=clone_node("default:furnace_active")
end
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
if direction.y==1 then
return inv:room_for_item("fuel",stack)
@ -79,12 +79,12 @@ chest=clone_node("default:chest")
chest.groups.tubedevice=1
chest.groups.tubedevice_receiver=1
chest.tube={insert_object = function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("main",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("main",stack)
end,

View File

@ -19,12 +19,12 @@ minetest.register_craft({
})
function hacky_swap_node(pos,name)
local node=minetest.env:get_node(pos)
local meta=minetest.env:get_meta(pos)
local node=minetest.get_node(pos)
local meta=minetest.get_meta(pos)
local meta0=meta:to_table()
node.name=name
minetest.env:add_node(pos, node)
local meta=minetest.env:get_meta(pos)
minetest.add_node(pos, node)
local meta=minetest.get_meta(pos)
meta:from_table(meta0)
end
@ -48,10 +48,10 @@ deployer_on = function(pos, node)
hacky_swap_node(pos,"pipeworks:deployer_on")
nodeupdate(pos)
local inv = minetest.env:get_meta(pos):get_inventory()
local inv = minetest.get_meta(pos):get_inventory()
local invlist = inv:get_list("main")
for i, stack in ipairs(invlist) do
if stack:get_name() ~= nil and stack:get_name() ~= "" and minetest.env:get_node(pos1).name == "air" then --obtain the first non-empty item slow
if stack:get_name() ~= nil and stack:get_name() ~= "" and minetest.get_node(pos1).name == "air" then --obtain the first non-empty item slow
local placer = {
get_player_name = function() return "deployer" end,
getpos = function() return pos end,
@ -81,12 +81,12 @@ minetest.register_node("pipeworks:deployer_off", {
"pipeworks_deployer_back.png","pipeworks_deployer_front_off.png"},
mesecons = {effector={action_on=deployer_on,action_off=deployer_off}},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("main",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("main",stack)
end,
@ -96,7 +96,7 @@ minetest.register_node("pipeworks:deployer_off", {
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Deployer]"..
@ -107,7 +107,7 @@ minetest.register_node("pipeworks:deployer_off", {
inv:set_size("main", 3*3)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
@ -121,12 +121,12 @@ minetest.register_node("pipeworks:deployer_on", {
"pipeworks_deployer_back.png","pipeworks_deployer_front_on.png"},
mesecons = {effector={action_on=deployer_on,action_off=deployer_off}},
tube={insert_object=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:add_item("main",stack)
end,
can_insert=function(pos,node,stack,direction)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
return inv:room_for_item("main",stack)
end,
@ -137,7 +137,7 @@ minetest.register_node("pipeworks:deployer_on", {
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, tubedevice_receiver=1,not_in_creative_inventory=1},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"invsize[8,9;]"..
"label[0,0;Deployer]"..
@ -148,7 +148,7 @@ minetest.register_node("pipeworks:deployer_on", {
inv:set_size("main", 3*3)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,

View File

@ -118,7 +118,7 @@ for s in ipairs(states) do
walkable = true,
pipelike = 1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
@ -130,10 +130,10 @@ for s in ipairs(states) do
drop = "pipeworks:pump_off",
mesecons = {effector = {
action_on = function (pos, node)
minetest.env:add_node(pos,{name="pipeworks:pump_on", param2 = node.param2})
minetest.add_node(pos,{name="pipeworks:pump_on", param2 = node.param2})
end,
action_off = function (pos, node)
minetest.env:add_node(pos,{name="pipeworks:pump_off", param2 = node.param2})
minetest.add_node(pos,{name="pipeworks:pump_off", param2 = node.param2})
end
}}
})
@ -177,7 +177,7 @@ for s in ipairs(states) do
walkable = true,
pipelike = 1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
@ -190,10 +190,10 @@ for s in ipairs(states) do
pipelike=1,
mesecons = {effector = {
action_on = function (pos, node)
minetest.env:add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
end,
action_off = function (pos, node)
minetest.env:add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
minetest.add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
end
}}
})
@ -232,7 +232,7 @@ minetest.register_node("pipeworks:valve_on_loaded", {
walkable = true,
pipelike = 1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
@ -245,10 +245,10 @@ minetest.register_node("pipeworks:valve_on_loaded", {
pipelike=1,
mesecons = {effector = {
action_on = function (pos, node)
minetest.env:add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
minetest.add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
end,
action_off = function (pos, node)
minetest.env:add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
minetest.add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
end
}}
})
@ -278,7 +278,7 @@ minetest.register_node("pipeworks:grating", {
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
})
@ -315,7 +315,7 @@ minetest.register_node("pipeworks:spigot", {
walkable = true,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
@ -381,7 +381,7 @@ minetest.register_node("pipeworks:spigot_pouring", {
walkable = true,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
@ -433,7 +433,7 @@ minetest.register_node("pipeworks:entry_panel_empty", {
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
node_box = {
@ -450,7 +450,7 @@ minetest.register_node("pipeworks:entry_panel_empty", {
on_place = function(itemstack, placer, pointed_thing)
if not pipeworks_node_is_owned(pointed_thing.under, placer)
and not pipeworks_node_is_owned(pointed_thing.above, placer) then
local node = minetest.env:get_node(pointed_thing.under)
local node = minetest.get_node(pointed_thing.under)
if not minetest.registered_nodes[node.name]
or not minetest.registered_nodes[node.name].on_rightclick then
@ -458,8 +458,8 @@ minetest.register_node("pipeworks:entry_panel_empty", {
local above = pointed_thing.above
local under = pointed_thing.under
local fdir = minetest.dir_to_facedir(placer:get_look_dir())
local undernode = minetest.env:get_node(under)
local abovenode = minetest.env:get_node(above)
local undernode = minetest.get_node(under)
local abovenode = minetest.get_node(above)
local uname = undernode.name
local aname = abovenode.name
local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0)
@ -483,9 +483,9 @@ minetest.register_node("pipeworks:entry_panel_empty", {
pos1 = under
end
if not minetest.registered_nodes[minetest.env:get_node(pos1).name]["buildable_to"] then return end
if not minetest.registered_nodes[minetest.get_node(pos1).name]["buildable_to"] then return end
minetest.env:add_node(pos1, {name = "pipeworks:entry_panel_empty", param2 = fdir })
minetest.add_node(pos1, {name = "pipeworks:entry_panel_empty", param2 = fdir })
pipe_scanforobjects(pos1)
if not pipeworks_expect_infinite_stacks then
@ -524,7 +524,7 @@ minetest.register_node("pipeworks:entry_panel_loaded", {
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
node_box = {
@ -571,7 +571,7 @@ minetest.register_node("pipeworks:flow_sensor_empty", {
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
if mesecon then
mesecon:receptor_off(pos, rules)
@ -615,7 +615,7 @@ minetest.register_node("pipeworks:flow_sensor_loaded", {
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
if mesecon then
mesecon:receptor_on(pos, rules)
@ -674,7 +674,7 @@ for fill = 0, 10 do
end,
pipelike=0,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",0)
end,
})
@ -704,7 +704,7 @@ for fill = 0, 10 do
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
})
@ -714,42 +714,42 @@ end
minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:valve_on_empty" then
fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos)
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",0)
end
end)
minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:valve_on_loaded" then
fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos)
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",0)
end
end)
minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:valve_off_empty" then
fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:valve_on_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos)
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, { name = "pipeworks:valve_on_empty", param2 = fdir })
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end
end)
minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:pump_on" then
fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:pump_off", param2 = fdir })
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, { name = "pipeworks:pump_off", param2 = fdir })
end
end)
minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:pump_off" then
fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:pump_on", param2 = fdir })
fdir = minetest.get_node(pos).param2
minetest.add_node(pos, { name = "pipeworks:pump_on", param2 = fdir })
end
end)

View File

@ -13,9 +13,9 @@ local check4liquids = function(pos)
{x=pos.x,y=pos.y,z=pos.z-1},
{x=pos.x,y=pos.y,z=pos.z+1}, }
for i =1,6 do
local name = minetest.env:get_node(coords[i]).name
local name = minetest.get_node(coords[i]).name
if string.find(name,'water') then
minetest.env:remove_node(coords[i])
minetest.remove_node(coords[i])
return true
end
end
@ -34,10 +34,10 @@ local check4inflows = function(pos,node)
local source = false
for i =1,6 do
if newnode then break end
local name = minetest.env:get_node(coords[i]).name
local name = minetest.get_node(coords[i]).name
if (name == 'pipeworks:pump_on' and check4liquids(coords[i])) or string.find(name,'_loaded') then
if string.find(name,'_loaded') then
local source = minetest.env:get_meta(coords[i]):get_string('source')
local source = minetest.get_meta(coords[i]):get_string('source')
if source == minetest.pos_to_string(pos) then break end
end
newnode = string.gsub(node.name,'empty','loaded')
@ -47,15 +47,15 @@ local check4inflows = function(pos,node)
end
if newnode then
dbg(newnode..' to replace '..node.name)
minetest.env:add_node(pos,{name=newnode, param2 = node.param2})
minetest.env:get_meta(pos):set_string('source',minetest.pos_to_string(source))
minetest.add_node(pos,{name=newnode, param2 = node.param2})
minetest.get_meta(pos):set_string('source',minetest.pos_to_string(source))
end
end
local checksources = function(pos,node)
local sourcepos = minetest.string_to_pos(minetest.env:get_meta(pos):get_string('source'))
local sourcepos = minetest.string_to_pos(minetest.get_meta(pos):get_string('source'))
if not sourcepos then return end
local source = minetest.env:get_node(sourcepos).name
local source = minetest.get_node(sourcepos).name
local newnode = false
if not ((source == 'pipeworks:pump_on' and check4liquids(sourcepos)) or string.find(source,'_loaded') or source == 'ignore' ) then
newnode = string.gsub(node.name,'loaded','empty')
@ -63,20 +63,20 @@ local checksources = function(pos,node)
if newnode then dbg(newnode..' to replace '..node.name) end
if newnode then
minetest.env:add_node(pos,{name=newnode, param2 = node.param2})
minetest.env:get_meta(pos):set_string('source','')
minetest.add_node(pos,{name=newnode, param2 = node.param2})
minetest.get_meta(pos):set_string('source','')
end
end
local update_outlet = function(pos)
local top = minetest.env:get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
local top = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
if string.find(top,'_loaded') then
local name = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
local name = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
if name == 'air' or name == "default:water_source" or name == "default:water_flowing" then
minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
end
elseif minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'default:water_source' then
minetest.env:remove_node({x=pos.x,y=pos.y-1,z=pos.z})
elseif minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'default:water_source' then
minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
end
end
@ -84,17 +84,17 @@ local spigot_check = function(pos,node)
local fdir=node.param2
local check = {{x=pos.x,y=pos.y,z=pos.z+1},{x=pos.x+1,y=pos.y,z=pos.z},{x=pos.x,y=pos.y,z=pos.z-1},{x=pos.x-1,y=pos.y,z=pos.z} }
dbg(fdir..' checking '..minetest.pos_to_string(check[fdir+1])..' for spigot at '..minetest.pos_to_string(pos))
local top = minetest.env:get_node(check[fdir+1]).name
local top = minetest.get_node(check[fdir+1]).name
dbg('found '..top)
local name = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
local name = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
if string.find(top,'_loaded') and (name == 'air' or name == "default:water_source" or name == "default:water_flowing") then
minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
minetest.env:add_node(pos,{name='pipeworks:spigot_pouring', param2 = fdir})
minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
minetest.add_node(pos,{name='pipeworks:spigot_pouring', param2 = fdir})
else
if minetest.env:get_node(pos).name == 'pipeworks:spigot_pouring' then
minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot', param2 = fdir})
if minetest.get_node(pos).name == 'pipeworks:spigot_pouring' then
minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot', param2 = fdir})
if name == 'air' or name == "default:water_source" or name == "default:water_flowing" then
minetest.env:remove_node({x=pos.x,y=pos.y-1,z=pos.z})
minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
end
end
end

View File

@ -316,7 +316,7 @@ for zp = 0, 1 do
drop = "pipeworks:pipe_110000_empty",
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
@ -348,7 +348,7 @@ for zp = 0, 1 do
drop = "pipeworks:pipe_110000_empty",
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)

View File

@ -16,7 +16,7 @@ minetest.register_node("pipeworks:filter", {
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"invsize[8,6.5;]"..
"list[current_name;main;0,0;8,2;]"..
@ -26,7 +26,7 @@ minetest.register_node("pipeworks:filter", {
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
@ -40,7 +40,7 @@ minetest.register_node("pipeworks:filter", {
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
end}},
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
local frompos
local dir
@ -57,13 +57,13 @@ minetest.register_node("pipeworks:filter", {
frompos={x=pos.x,y=pos.y,z=pos.z-1}
dir={x=0,y=0,z=1}
end
local fromnode=minetest.env:get_node(frompos)
local fromnode=minetest.get_node(frompos)
local frominv
if not (minetest.registered_nodes[fromnode.name].tube and
minetest.registered_nodes[fromnode.name].tube.input_inventory) then
return
end
local frommeta=minetest.env:get_meta(frompos)
local frommeta=minetest.get_meta(frompos)
local frominvname=minetest.registered_nodes[fromnode.name].tube.input_inventory
local frominv=frommeta:get_inventory()
for _,filter in ipairs(inv:get_list("main")) do
@ -114,7 +114,7 @@ minetest.register_node("pipeworks:mese_filter", {
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"invsize[8,6.5;]"..
"list[current_name;main;0,0;8,2;]"..
@ -124,7 +124,7 @@ minetest.register_node("pipeworks:mese_filter", {
inv:set_size("main", 8*4)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return inv:is_empty("main")
end,
@ -138,7 +138,7 @@ minetest.register_node("pipeworks:mese_filter", {
minetest.registered_nodes[node.name].on_punch(pos,node,nil)
end}},
on_punch = function (pos, node, puncher)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
local frompos
local dir
@ -155,13 +155,13 @@ minetest.register_node("pipeworks:mese_filter", {
frompos={x=pos.x,y=pos.y,z=pos.z-1}
dir={x=0,y=0,z=1}
end
local fromnode=minetest.env:get_node(frompos)
local fromnode=minetest.get_node(frompos)
local frominv
if not (minetest.registered_nodes[fromnode.name].tube and
minetest.registered_nodes[fromnode.name].tube.input_inventory) then
return
end
local frommeta=minetest.env:get_meta(frompos)
local frommeta=minetest.get_meta(frompos)
local frominvname=minetest.registered_nodes[fromnode.name].tube.input_inventory
local frominv=frommeta:get_inventory()
for _,filter in ipairs(inv:get_list("main")) do
@ -201,7 +201,7 @@ end,
function tube_item(pos, item)
-- Take item in any format
local stack = ItemStack(item)
local obj = minetest.env:add_entity(pos, "pipeworks:tubed_item")
local obj = minetest.add_entity(pos, "pipeworks:tubed_item")
obj:get_luaentity():set_item(stack:to_string())
return obj
end
@ -297,8 +297,8 @@ minetest.register_entity("pipeworks:tubed_item", {
self.start_pos=roundpos(pos)
end
local pos = self.object:getpos()
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos)
local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos)
tubelike=meta:get_int("tubelike")
local stack = ItemStack(self.itemstring)
local drop_pos=nil
@ -335,14 +335,14 @@ minetest.register_entity("pipeworks:tubed_item", {
local sposcopy={x=self.start_pos.x,y=self.start_pos.y,z=self.start_pos.z}
node = minetest.env:get_node(self.start_pos)
node = minetest.get_node(self.start_pos)
if moved and minetest.get_item_group(node.name,"tubedevice_receiver")==1 then
if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos,node,stack,vel)
else
leftover = stack
end
--drop_pos=minetest.env:find_node_near(self.start_pos,1,"air")
--drop_pos=minetest.find_node_near(self.start_pos,1,"air")
--if drop_pos and not leftover:is_empty() then minetest.item_drop(leftover,"",drop_pos) end
--self.object:remove()
if leftover:is_empty() then
@ -359,7 +359,7 @@ minetest.register_entity("pipeworks:tubed_item", {
if moved then
if go_next (self.start_pos, velocity, stack)==0 then
drop_pos=minetest.env:find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
drop_pos=minetest.find_node_near({x=self.start_pos.x+velocity.x,y=self.start_pos.y+velocity.y,z=self.start_pos.z+velocity.z}, 1, "air")
if drop_pos then
minetest.item_drop(stack, "", drop_pos)
self.object:remove()
@ -394,8 +394,8 @@ end
function go_next(pos,velocity,stack)
local chests={}
local tubes={}
local cnode=minetest.env:get_node(pos)
local cmeta=minetest.env:get_meta(pos)
local cnode=minetest.get_node(pos)
local cmeta=minetest.get_meta(pos)
local node
local meta
local tubelike
@ -420,9 +420,9 @@ function go_next(pos,velocity,stack)
end
for _,vect in ipairs(can_go) do
npos=addVect(pos,vect)
node=minetest.env:get_node(npos)
node=minetest.get_node(npos)
tube_receiver=minetest.get_item_group(node.name,"tubedevice_receiver")
meta=minetest.env:get_meta(npos)
meta=minetest.get_meta(npos)
tubelike=meta:get_int("tubelike")
if tube_receiver==1 then
if minetest.registered_nodes[node.name].tube and

View File

@ -19,12 +19,12 @@ minetest.register_craft({
})
function hacky_swap_node(pos,name)
local node=minetest.env:get_node(pos)
local meta=minetest.env:get_meta(pos)
local node=minetest.get_node(pos)
local meta=minetest.get_meta(pos)
local meta0=meta:to_table()
node.name=name
minetest.env:add_node(pos, node)
local meta=minetest.env:get_meta(pos)
minetest.add_node(pos, node)
local meta=minetest.get_meta(pos)
meta:from_table(meta0)
end
@ -67,7 +67,7 @@ function break_node (pos, n_param)
z_velocity = 1
end
local node = minetest.env:get_node(pos2)
local node = minetest.get_node(pos2)
if node.name == "air" or name == "ignore" then
return nil
elseif minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].liquidtype ~= "none" then
@ -95,7 +95,7 @@ function break_node (pos, n_param)
item1:setacceleration({x=0, y=0, z=0})
end
minetest.env:remove_node(pos2)
minetest.remove_node(pos2)
--handle post-digging callback
if def.after_dig_node then

View File

@ -43,8 +43,8 @@ function get_tubes_in_file(pos,channel)
newtbl={}
changed=false
for _,val in ipairs(tbl) do
local node = minetest.env:get_node(val)
local meta = minetest.env:get_meta(val)
local node = minetest.get_node(val)
local meta = minetest.get_meta(val)
if node.name~="ignore" and (val.channel~=meta:get_string("channel") or val.cr~=meta:get_int("can_receive")) then
val.channel=meta:get_string("channel")
val.cr=meta:get_int("can_receive")
@ -73,7 +73,7 @@ register_tube("pipeworks:teleport_tube","Teleporter pneumatic tube segment",tele
velocity.x=0
velocity.y=0
velocity.z=0
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
channel=meta:get_string("channel")
local target=get_tubes_in_file(pos,channel)
if target[1]==nil then return {} end
@ -84,7 +84,7 @@ register_tube("pipeworks:teleport_tube","Teleporter pneumatic tube segment",tele
return meseadjlist
end},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_string("channel","")
meta:set_int("can_receive",1)
meta:set_string("formspec","size[9,1;]"..
@ -93,7 +93,7 @@ register_tube("pipeworks:teleport_tube","Teleporter pneumatic tube segment",tele
add_tube_in_file(pos,"")
end,
on_receive_fields = function(pos,formname,fields,sender)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
if fields.channel==nil then fields.channel=meta:get_string("channel") end
meta:set_string("channel",fields.channel)
remove_tube_in_file(pos)

View File

@ -212,7 +212,7 @@ for zp = 0, 1 do
drop = name.."_000000",
tubelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("tubelike",1)
if minetest.registered_nodes[name.."_"..tname].on_construct_ then
minetest.registered_nodes[name.."_"..tname].on_construct_(pos)
@ -294,7 +294,7 @@ register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_tex
mese_end_textures,mese_short_texture,mese_inv_texture,
{tube={can_go=function(pos,node,velocity,stack)
tbl={}
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local found=false
local name=stack:get_name()
@ -320,7 +320,7 @@ register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_tex
return tbl
end},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
for i=1,6 do
meta:set_int("l"..tostring(i).."s",1)
@ -350,7 +350,7 @@ register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_tex
meta:set_string("infotext", "Mese pneumatic tube")
end,
on_receive_fields=function(pos,formname,fields,sender)
local meta=minetest.env:get_meta(pos)
local meta=minetest.get_meta(pos)
local i
for key,_ in pairs(fields) do i=key end
if i==nil then return end
@ -382,7 +382,7 @@ register_tube("pipeworks:mese_tube","Mese pneumatic tube segment",mese_plain_tex
meta:set_string("formspec",frm)
end,
can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos);
local meta = minetest.get_meta(pos);
local inv = meta:get_inventory()
return (inv:is_empty("line1") and inv:is_empty("line2") and inv:is_empty("line3") and
inv:is_empty("line4") and inv:is_empty("line5") and inv:is_empty("line6"))
@ -394,8 +394,8 @@ mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y
register_tube("pipeworks:detector_tube_on","Detector tube segment on (you hacker you)",detector_plain_textures,noctr_textures,
end_textures,short_texture,detector_inv_texture,
{tube={can_go=function(pos,node,velocity,stack)
local meta = minetest.env:get_meta(pos)
local name = minetest.env:get_node(pos).name
local meta = minetest.get_meta(pos)
local name = minetest.get_node(pos).name
local nitems=meta:get_int("nitems")+1
meta:set_int("nitems", nitems)
minetest.after(0.1,minetest.registered_nodes[name].item_exit,pos)
@ -406,28 +406,28 @@ register_tube("pipeworks:detector_tube_on","Detector tube segment on (you hacker
mesecons={receptor={state="on",
rules=mesecons_rules}},
item_exit = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
local nitems=meta:get_int("nitems")-1
local name = minetest.env:get_node(pos).name
local name = minetest.get_node(pos).name
if nitems==0 then
minetest.env:set_node(pos,{name=string.gsub(name,"on","off")})
minetest.set_node(pos,{name=string.gsub(name,"on","off")})
mesecon:receptor_off(pos,mesecons_rules)
else
meta:set_int("nitems", nitems)
end
end,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
local meta = minetest.get_meta(pos)
meta:set_int("nitems", 1)
local name = minetest.env:get_node(pos).name
local name = minetest.get_node(pos).name
minetest.after(0.1,minetest.registered_nodes[name].item_exit,pos)
end})
register_tube("pipeworks:detector_tube_off","Detector tube segment",detector_plain_textures,noctr_textures,
end_textures,short_texture,detector_inv_texture,
{tube={can_go=function(pos,node,velocity,stack)
local name = minetest.env:get_node(pos).name
minetest.env:set_node(pos,{name=string.gsub(name,"off","on")})
local name = minetest.get_node(pos).name
minetest.set_node(pos,{name=string.gsub(name,"off","on")})
mesecon:receptor_on(pos,mesecons_rules)
return notvel(meseadjlist,velocity)
end},
@ -503,7 +503,7 @@ register_tube("pipeworks:sand_tube","Sand pneumatic tube segment",sand_plain_tex
minetest.register_abm({nodenames={"group:sand_tube"},interval=1,chance=1,
action=function(pos, node, active_object_count, active_object_count_wider)
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
for _,object in ipairs(minetest.get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if object:get_luaentity().itemstring ~= "" then
local titem=tube_item(pos,object:get_luaentity().itemstring)