summaryrefslogtreecommitdiff
path: root/mesecons_mvps
diff options
context:
space:
mode:
authorUberi <azhang9@gmail.com>2013-11-30 22:13:00 -0500
committerUberi <azhang9@gmail.com>2013-11-30 22:13:00 -0500
commit16b4b79c51719849588c49d1d47d9bcbc05533e4 (patch)
tree0554bf1fb3c1b293af4396cff9aac172e83bb727 /mesecons_mvps
parentb4654cedb77b435857649e01545bb9e507ff6dae (diff)
downloadmesecons-16b4b79c51719849588c49d1d47d9bcbc05533e4.tar
mesecons-16b4b79c51719849588c49d1d47d9bcbc05533e4.tar.gz
mesecons-16b4b79c51719849588c49d1d47d9bcbc05533e4.tar.bz2
mesecons-16b4b79c51719849588c49d1d47d9bcbc05533e4.tar.xz
mesecons-16b4b79c51719849588c49d1d47d9bcbc05533e4.zip
Update code to standards of Minetest 0.4.8.
Diffstat (limited to 'mesecons_mvps')
-rw-r--r--mesecons_mvps/init.lua40
1 files changed, 20 insertions, 20 deletions
diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua
index c572cb3..246c738 100644
--- a/mesecons_mvps/init.lua
+++ b/mesecons_mvps/init.lua
@@ -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)