Update most deprecated function calls

Using MT-replace-deprecated.sh script
This commit is contained in:
Wuzzy 2020-03-30 22:43:46 +02:00
parent 064fc6a59d
commit e3303fe401
34 changed files with 188 additions and 188 deletions

View File

@ -220,7 +220,7 @@ for _, anvil in ipairs(anvils) do
groups = {oddly_breakable_by_hand=2, falling_node=1, dig_immediate=1}, groups = {oddly_breakable_by_hand=2, falling_node=1, dig_immediate=1},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if inv:is_empty("src1") and inv:is_empty("src2") and inv:is_empty("hammer") if inv:is_empty("src1") and inv:is_empty("src2") and inv:is_empty("hammer")
and inv:is_empty("output") and inv:is_empty("flux") then and inv:is_empty("output") and inv:is_empty("flux") then
@ -229,7 +229,7 @@ for _, anvil in ipairs(anvils) do
return false return false
end, end,
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", "size[8,7]".. meta:set_string("formspec", "size[8,7]"..
-- some (hopefully) helpful buttons -- some (hopefully) helpful buttons
"button[2.0,1.75;1,0.5;guide;Guide]".. "button[2.0,1.75;1,0.5;guide;Guide]"..
@ -266,7 +266,7 @@ for _, anvil in ipairs(anvils) do
realtest.show_craft_guide_anvil( sender, "realtest:craft_guide_anvil", fields); realtest.show_craft_guide_anvil( sender, "realtest:craft_guide_anvil", fields);
return; return;
end end
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local src1, src2 = inv:get_stack("src1", 1), inv:get_stack("src2", 1) local src1, src2 = inv:get_stack("src1", 1), inv:get_stack("src2", 1)

View File

@ -197,9 +197,9 @@ awards.register_achievement("award_burn",{
awards.register_onDeath(function(player,data) awards.register_onDeath(function(player,data)
print ("running on death function") print ("running on death function")
local pos=player:getpos() local pos=player:get_pos()
if pos and minetest.env:find_node_near(pos, 1, "fire:basic_flame")~=nil then if pos and minetest.find_node_near(pos, 1, "fire:basic_flame")~=nil then
return "award_burn" return "award_burn"
end end

View File

@ -4,7 +4,7 @@
-- --
local function is_water(pos) local function is_water(pos)
local nn = minetest.env:get_node(pos).name local nn = minetest.get_node(pos).name
return minetest.get_item_group(nn, "water") ~= 0 return minetest.get_item_group(nn, "water") ~= 0
end end
@ -51,7 +51,7 @@ function boat:on_rightclick(clicker)
elseif not self.driver then elseif not self.driver then
self.driver = clicker self.driver = clicker
clicker:set_attach(self.object, "", {x=0,y=5,z=0}, {x=0,y=0,z=0}) clicker:set_attach(self.object, "", {x=0,y=5,z=0}, {x=0,y=0,z=0})
self.object:setyaw(clicker:get_look_yaw()) self.object:set_yaw(clicker:get_look_yaw())
end end
end end
@ -74,7 +74,7 @@ function boat:on_punch(puncher, time_from_last_punch, tool_capabilities, directi
end end
function boat:on_step(dtime) function boat:on_step(dtime)
self.v = get_v(self.object:getvelocity())*get_sign(self.v) self.v = get_v(self.object:get_velocity())*get_sign(self.v)
if self.driver then if self.driver then
local ctrl = self.driver:get_player_control() local ctrl = self.driver:get_player_control()
if ctrl.up then if ctrl.up then
@ -84,16 +84,16 @@ function boat:on_step(dtime)
self.v = self.v-0.08 self.v = self.v-0.08
end end
if ctrl.left then if ctrl.left then
self.object:setyaw(self.object:getyaw()+math.pi/120+dtime*math.pi/120) self.object:set_yaw(self.object:get_yaw()+math.pi/120+dtime*math.pi/120)
end end
if ctrl.right then if ctrl.right then
self.object:setyaw(self.object:getyaw()-math.pi/120-dtime*math.pi/120) self.object:set_yaw(self.object:get_yaw()-math.pi/120-dtime*math.pi/120)
end end
end end
local s = get_sign(self.v) local s = get_sign(self.v)
self.v = self.v - 0.02*s self.v = self.v - 0.02*s
if s ~= get_sign(self.v) then if s ~= get_sign(self.v) then
self.object:setvelocity({x=0, y=0, z=0}) self.object:set_velocity({x=0, y=0, z=0})
self.v = 0 self.v = 0
return return
end end
@ -101,35 +101,35 @@ function boat:on_step(dtime)
self.v = 4.5*get_sign(self.v) self.v = 4.5*get_sign(self.v)
end end
local p = self.object:getpos() local p = self.object:get_pos()
p.y = p.y-0.5 p.y = p.y-0.5
if not is_water(p) then if not is_water(p) then
if minetest.registered_nodes[minetest.env:get_node(p).name].walkable then if minetest.registered_nodes[minetest.get_node(p).name].walkable then
self.v = 0 self.v = 0
end end
self.object:setacceleration({x=0, y=-10, z=0}) self.object:set_acceleration({x=0, y=-10, z=0})
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)) self.object:set_velocity(get_velocity(self.v, self.object:get_yaw(), self.object:get_velocity().y))
else else
p.y = p.y+1 p.y = p.y+1
if is_water(p) then if is_water(p) then
self.object:setacceleration({x=0, y=3, z=0}) self.object:set_acceleration({x=0, y=3, z=0})
local y = self.object:getvelocity().y local y = self.object:get_velocity().y
if y > 2 then if y > 2 then
y = 2 y = 2
end end
if y < 0 then if y < 0 then
self.object:setacceleration({x=0, y=10, z=0}) self.object:set_acceleration({x=0, y=10, z=0})
end end
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), y)) self.object:set_velocity(get_velocity(self.v, self.object:get_yaw(), y))
else else
self.object:setacceleration({x=0, y=0, z=0}) self.object:set_acceleration({x=0, y=0, z=0})
if math.abs(self.object:getvelocity().y) < 1 then if math.abs(self.object:get_velocity().y) < 1 then
local pos = self.object:getpos() local pos = self.object:get_pos()
pos.y = math.floor(pos.y)+0.5 pos.y = math.floor(pos.y)+0.5
self.object:setpos(pos) self.object:set_pos(pos)
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), 0)) self.object:set_velocity(get_velocity(self.v, self.object:get_yaw(), 0))
else else
self.object:setvelocity(get_velocity(self.v, self.object:getyaw(), self.object:getvelocity().y)) self.object:set_velocity(get_velocity(self.v, self.object:get_yaw(), self.object:get_velocity().y))
end end
end end
end end
@ -153,7 +153,7 @@ minetest.register_craftitem("boats:boat", {
return return
end end
pointed_thing.under.y = pointed_thing.under.y+0.5 pointed_thing.under.y = pointed_thing.under.y+0.5
minetest.env:add_entity(pointed_thing.under, "boats:boat") minetest.add_entity(pointed_thing.under, "boats:boat")
itemstack:take_item() itemstack:take_item()
return itemstack return itemstack
end, end,

View File

@ -72,13 +72,13 @@ minetest.register_entity(":__builtin:item", {
self.itemstring = staticdata self.itemstring = staticdata
end end
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({immortal=1})
self.object:setvelocity({x=0, y=2, z=0}) self.object:set_velocity({x=0, y=2, z=0})
self.object:setacceleration({x=0, y=-10, z=0}) self.object:set_acceleration({x=0, y=-10, z=0})
self:set_item(self.itemstring) self:set_item(self.itemstring)
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
local time = tonumber(minetest.setting_get("remove_items")) local time = tonumber(minetest.settings:get("remove_items"))
if not time then if not time then
time = 300 time = 300
end end
@ -90,19 +90,19 @@ minetest.register_entity(":__builtin:item", {
self.object:remove() self.object:remove()
end end
local p = self.object:getpos() local p = self.object:get_pos()
local name = minetest.env:get_node(p).name local name = minetest.get_node(p).name
if name == "default:lava_flowing" or name == "default:lava_source" then if name == "default:lava_flowing" or name == "default:lava_source" then
minetest.sound_play("builtin_item_lava", {pos=self.object:getpos()}) minetest.sound_play("builtin_item_lava", {pos=self.object:get_pos()})
self.object:remove() self.object:remove()
return return
end end
if minetest.registered_nodes[name].liquidtype == "flowing" then if minetest.registered_nodes[name].liquidtype == "flowing" then
get_flowing_dir = function(self) get_flowing_dir = function(self)
local pos = self.object:getpos() local pos = self.object:get_pos()
local param2 = minetest.env:get_node(pos).param2 local param2 = minetest.get_node(pos).param2
for i,d in ipairs({-1, 1, -1, 1}) do for i,d in ipairs({-1, 1, -1, 1}) do
if i<3 then if i<3 then
pos.x = pos.x+d pos.x = pos.x+d
@ -110,8 +110,8 @@ minetest.register_entity(":__builtin:item", {
pos.z = pos.z+d pos.z = pos.z+d
end end
local name = minetest.env:get_node(pos).name local name = minetest.get_node(pos).name
local par2 = minetest.env:get_node(pos).param2 local par2 = minetest.get_node(pos).param2
if name == "default:water_flowing" and par2 < param2 then if name == "default:water_flowing" and par2 < param2 then
return pos return pos
end end
@ -126,17 +126,17 @@ minetest.register_entity(":__builtin:item", {
local vec = get_flowing_dir(self) local vec = get_flowing_dir(self)
if vec then if vec then
local v = self.object:getvelocity() local v = self.object:get_velocity()
if vec and vec.x-p.x > 0 then if vec and vec.x-p.x > 0 then
self.object:setvelocity({x=0.5,y=v.y,z=0}) self.object:set_velocity({x=0.5,y=v.y,z=0})
elseif vec and vec.x-p.x < 0 then elseif vec and vec.x-p.x < 0 then
self.object:setvelocity({x=-0.5,y=v.y,z=0}) self.object:set_velocity({x=-0.5,y=v.y,z=0})
elseif vec and vec.z-p.z > 0 then elseif vec and vec.z-p.z > 0 then
self.object:setvelocity({x=0,y=v.y,z=0.5}) self.object:set_velocity({x=0,y=v.y,z=0.5})
elseif vec and vec.z-p.z < 0 then elseif vec and vec.z-p.z < 0 then
self.object:setvelocity({x=0,y=v.y,z=-0.5}) self.object:set_velocity({x=0,y=v.y,z=-0.5})
end end
self.object:setacceleration({x=0, y=-10, z=0}) self.object:set_acceleration({x=0, y=-10, z=0})
self.physical_state = true self.physical_state = true
self.object:set_properties({ self.object:set_properties({
physical = true physical = true
@ -146,12 +146,12 @@ minetest.register_entity(":__builtin:item", {
end end
p.y = p.y - 0.3 p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name local nn = minetest.get_node(p).name
-- If node is not registered or node is walkably solid -- If node is not registered or node is walkably solid
if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
if self.physical_state then if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0}) self.object:set_velocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0}) self.object:set_acceleration({x=0, y=0, z=0})
self.physical_state = false self.physical_state = false
self.object:set_properties({ self.object:set_properties({
physical = false physical = false
@ -159,8 +159,8 @@ minetest.register_entity(":__builtin:item", {
end end
else else
if not self.physical_state then if not self.physical_state then
self.object:setvelocity({x=0,y=0,z=0}) self.object:set_velocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=-10, z=0}) self.object:set_acceleration({x=0, y=-10, z=0})
self.physical_state = true self.physical_state = true
self.object:set_properties({ self.object:set_properties({
physical = true physical = true
@ -181,6 +181,6 @@ minetest.register_entity(":__builtin:item", {
end, end,
}) })
if minetest.setting_get("log_mods") then if minetest.settings:get("log_mods") then
minetest.log("action", "builtin_item loaded") minetest.log("action", "builtin_item loaded")
end end

View File

@ -7,7 +7,7 @@ creative_inventory.creative_inventory_size = 0
minetest.after(0, function() minetest.after(0, function()
local inv = minetest.create_detached_inventory("creative", { local inv = minetest.create_detached_inventory("creative", {
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player) allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
if minetest.setting_getbool("creative_mode") then if minetest.settings:get_bool("creative_mode") then
return count return count
else else
return 0 return 0
@ -17,7 +17,7 @@ minetest.after(0, function()
return 0 return 0
end, end,
allow_take = function(inv, listname, index, stack, player) allow_take = function(inv, listname, index, stack, player)
if minetest.setting_getbool("creative_mode") then if minetest.settings:get_bool("creative_mode") then
return -1 return -1
else else
return 0 return 0
@ -55,7 +55,7 @@ local trash = minetest.create_detached_inventory("creative_trash", {
-- Allow the stack to be placed and remove it in on_put() -- Allow the stack to be placed and remove it in on_put()
-- This allows the creative inventory to restore the stack -- This allows the creative inventory to restore the stack
allow_put = function(inv, listname, index, stack, player) allow_put = function(inv, listname, index, stack, player)
if minetest.setting_getbool("creative_mode") then if minetest.settings:get_bool("creative_mode") then
return stack:get_count() return stack:get_count()
else else
return 0 return 0
@ -82,14 +82,14 @@ creative_inventory.set_creative_formspec = function(player, start_i, pagenum)
end end
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
-- If in creative mode, modify player's inventory forms -- If in creative mode, modify player's inventory forms
if not minetest.setting_getbool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
return return
end end
creative_inventory.set_creative_formspec(player, 0, 1) creative_inventory.set_creative_formspec(player, 0, 1)
end) end)
minetest.register_on_player_receive_fields(function(player, formname, fields) minetest.register_on_player_receive_fields(function(player, formname, fields)
if not minetest.setting_getbool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
return return
end end
-- Figure out current page from formspec -- Figure out current page from formspec

View File

@ -1,4 +1,4 @@
if minetest.setting_getbool("creative_mode") then if minetest.settings:get_bool("creative_mode") then
function minetest.handle_node_drops(pos, drops, digger) function minetest.handle_node_drops(pos, drops, digger)
if not digger or not digger:is_player() then if not digger or not digger:is_player() then
return return
@ -34,7 +34,7 @@ else
if math.random(1,2) == 1 then if math.random(1,2) == 1 then
z = -z z = -z
end end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z}) obj:set_velocity({x=1/x, y=obj:get_velocity().y, z=1/z})
end end
end end
end end
@ -43,7 +43,7 @@ else
drop(item) drop(item)
end end
end end
if ALWAYS_DROP_NODES_AS_ITEMS and minetest.get_node_group(minetest.get_node(pos).name, "drop_on_dig") == 1 then if ALWAYS_DROP_NODES_AS_ITEMS and minetest.get_item_group(minetest.get_node(pos).name, "drop_on_dig") == 1 then
drop_all() drop_all()
elseif digger and digger:get_inventory() then elseif digger and digger:get_inventory() then
for _, dropped_item in ipairs(drops) do for _, dropped_item in ipairs(drops) do

View File

@ -39,7 +39,7 @@ function nodeupdate_single(pos)
end end
end end
function nodeupdate(pos) function minetest.check_for_falling(pos)
for x = -1,1 do for x = -1,1 do
for y = -1,1 do for y = -1,1 do
for z = -1,1 do for z = -1,1 do
@ -51,7 +51,7 @@ function nodeupdate(pos)
end end
realtest.register_on_updatenode(function(pos, node) realtest.register_on_updatenode(function(pos, node)
if minetest.get_node_group(node.name, "dropping_node") ~= 0 then if minetest.get_item_group(node.name, "dropping_node") ~= 0 then
if minetest.registered_nodes[node.name].cause_drop(pos, node) then if minetest.registered_nodes[node.name].cause_drop(pos, node) then
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
if minetest.registered_nodes[node.name].on_dropping then if minetest.registered_nodes[node.name].on_dropping then
@ -66,20 +66,20 @@ realtest.register_on_updatenode(function(pos, node)
if minetest.registered_nodes[node.name].after_dig_node then if minetest.registered_nodes[node.name].after_dig_node then
minetest.registered_nodes[node.name].after_dig_node(pos, node, meta, nil) minetest.registered_nodes[node.name].after_dig_node(pos, node, meta, nil)
end end
nodeupdate(pos) minetest.check_for_falling(pos)
end end
end end
end) end)
realtest.register_on_updatenode(function(pos, node) realtest.register_on_updatenode(function(pos, node)
local b_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}) local b_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
if minetest.get_node_group(node.name, "dropping_like_stone") ~= 0 and if minetest.get_item_group(node.name, "dropping_like_stone") ~= 0 and
(minetest.registered_nodes[b_node.name].walkable == false or (minetest.registered_nodes[b_node.name].walkable == false or
minetest.registered_nodes[b_node.name].buildable_to) then minetest.registered_nodes[b_node.name].buildable_to) then
local sides = {{x=-1,y=0,z=0}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}} local sides = {{x=-1,y=0,z=0}, {x=1,y=0,z=0}, {x=0,y=0,z=-1}, {x=0,y=0,z=1}, {x=0,y=-1,z=0}, {x=0,y=1,z=0}}
local drop = true local drop = true
for _, s in ipairs(sides) do for _, s in ipairs(sides) do
if minetest.get_node_group(minetest.get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name, "dropping_like_stone") ~= 0 then if minetest.get_item_group(minetest.get_node({x=pos.x+s.x,y=pos.y+s.y,z=pos.z+s.z}).name, "dropping_like_stone") ~= 0 then
drop = false drop = false
break break
end end
@ -87,13 +87,13 @@ realtest.register_on_updatenode(function(pos, node)
if drop then if drop then
minetest.remove_node({x=pos.x,y=pos.y,z=pos.z}) minetest.remove_node({x=pos.x,y=pos.y,z=pos.z})
minetest.handle_node_drops(pos, {node.name}) minetest.handle_node_drops(pos, {node.name})
nodeupdate(pos) minetest.check_for_falling(pos)
end end
end end
end) end)
realtest.register_on_updatenode(function(pos, node) realtest.register_on_updatenode(function(pos, node)
if minetest.get_node_group(node.name, "falling_node") ~= 0 then if minetest.get_item_group(node.name, "falling_node") ~= 0 then
if minetest.registered_nodes[node.name].cause_fall(pos, node) then if minetest.registered_nodes[node.name].cause_fall(pos, node) then
if minetest.registered_nodes[node.name].on_falling then if minetest.registered_nodes[node.name].on_falling then
minetest.registered_nodes[node.name].on_falling(pos, node) minetest.registered_nodes[node.name].on_falling(pos, node)
@ -101,13 +101,13 @@ realtest.register_on_updatenode(function(pos, node)
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.spawn_falling_node(pos, node.name) minetest.spawn_falling_node(pos, node.name)
end end
nodeupdate(pos) minetest.check_for_falling(pos)
end end
end end
end) end)
realtest.register_on_updatenode(function(pos, node) realtest.register_on_updatenode(function(pos, node)
if minetest.get_node_group(node.name, "attached_node") ~= 0 then if minetest.get_item_group(node.name, "attached_node") ~= 0 then
local function check_attached_node(p, n) local function check_attached_node(p, n)
local def = minetest.registered_nodes[n.name] local def = minetest.registered_nodes[n.name]
local d = {x=0, y=0, z=0} local d = {x=0, y=0, z=0}
@ -139,7 +139,7 @@ realtest.register_on_updatenode(function(pos, node)
if not check_attached_node(pos, node) then if not check_attached_node(pos, node) then
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.handle_node_drops(pos, minetest.get_node_drops(node.name, nil)) minetest.handle_node_drops(pos, minetest.get_node_drops(node.name, nil))
nodeupdate(pos) minetest.check_for_falling(pos)
end end
end end
end) end)
@ -183,15 +183,15 @@ minetest.register_entity(":__builtin:falling_node", {
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.nodename = staticdata self.nodename = staticdata
self.object:set_armor_groups({immortal=1}) self.object:set_armor_groups({immortal=1})
--self.object:setacceleration({x=0, y=-10, z=0}) --self.object:set_acceleration({x=0, y=-10, z=0})
self:set_node(self.nodename) self:set_node(self.nodename)
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
-- Set gravity -- Set gravity
self.object:setacceleration({x=0, y=-10, z=0}) self.object:set_acceleration({x=0, y=-10, z=0})
-- Turn to actual sand when collides to ground or just move -- Turn to actual sand when collides to ground or just move
local pos = self.object:getpos() local pos = self.object:get_pos()
local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point local bcp = {x=pos.x, y=pos.y-0.7, z=pos.z} -- Position of bottom center point
local bcn = minetest.get_node(bcp) local bcn = minetest.get_node(bcp)
-- Note: walkable is in the node definition, not in item groups -- Note: walkable is in the node definition, not in item groups
@ -224,7 +224,7 @@ minetest.register_entity(":__builtin:falling_node", {
-- Create node and remove entity -- Create node and remove entity
minetest.add_node(np, {name=self.nodename}) minetest.add_node(np, {name=self.nodename})
self.object:remove() self.object:remove()
nodeupdate(np) minetest.check_for_falling(np)
else else
-- Do nothing -- Do nothing
end end

View File

@ -7,9 +7,9 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
local under = pointed_thing.under local under = pointed_thing.under
local oldnode_under = minetest.env:get_node_or_nil(under) local oldnode_under = minetest.get_node_or_nil(under)
local above = pointed_thing.above local above = pointed_thing.above
local oldnode_above = minetest.env:get_node_or_nil(above) local oldnode_above = minetest.get_node_or_nil(above)
if not oldnode_under or not oldnode_above then if not oldnode_under or not oldnode_above then
minetest.log("info", placer:get_player_name() .. " tried to place" minetest.log("info", placer:get_player_name() .. " tried to place"
@ -55,7 +55,7 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
newnode.param2 = minetest.dir_to_wallmounted(dir) newnode.param2 = minetest.dir_to_wallmounted(dir)
-- Calculate the direction for furnaces and chests and stuff -- Calculate the direction for furnaces and chests and stuff
elseif def.paramtype2 == 'facedir' then elseif def.paramtype2 == 'facedir' then
local placer_pos = placer:getpos() local placer_pos = placer:get_pos()
if placer_pos then if placer_pos then
local dir = { local dir = {
x = above.x - placer_pos.x, x = above.x - placer_pos.x,

View File

@ -177,7 +177,7 @@ minetest.after(0, function()
local delta = 0 local delta = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
delta = delta + dtime delta = delta + dtime
local q = 72/minetest.setting_get("time_speed") local q = 72/minetest.settings:get("time_speed")
while delta >= q do while delta >= q do
delta = delta - q delta = delta - q
seasons.timer = seasons.timer + 1 seasons.timer = seasons.timer + 1

View File

@ -166,7 +166,7 @@ function realtest.register_slab(name, recipeitem, groups, images, description, s
return itemstack return itemstack
end end
if not minetest.setting_getbool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack

View File

@ -17,7 +17,7 @@ dofile(minetest.get_modpath("default").."/mapgen.lua")
-- --
-- Tool definition -- Tool definition
-- --
if minetest.setting_getbool("creative_mode") then if minetest.settings:get_bool("creative_mode") then
minetest.register_item(":", { minetest.register_item(":", {
type = "none", type = "none",
wield_image = "wieldhand.png", wield_image = "wieldhand.png",

View File

@ -49,7 +49,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine papyrus amount from perlin noise -- Determine papyrus amount from perlin noise
local papyrus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 45 - 20) local papyrus_amount = math.floor(perlin1:get_2d({x=x0, y=z0}) * 45 - 20)
-- Find random positions for papyrus based on this random -- Find random positions for papyrus based on this random
local pr = PseudoRandom(seed+1) local pr = PseudoRandom(seed+1)
for i=0,papyrus_amount do for i=0,papyrus_amount do
@ -74,7 +74,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine cactus amount from perlin noise -- Determine cactus amount from perlin noise
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 6 - 3) local cactus_amount = math.floor(perlin1:get_2d({x=x0, y=z0}) * 6 - 3)
-- Find random positions for cactus based on this random -- Find random positions for cactus based on this random
local pr = PseudoRandom(seed+1) local pr = PseudoRandom(seed+1)
for i=0,cactus_amount do for i=0,cactus_amount do
@ -106,7 +106,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local z0 = minp.z + math.floor((divz+0)*divlen) local z0 = minp.z + math.floor((divz+0)*divlen)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
local cobbles_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0) local cobbles_amount = math.floor(perlin1:get_2d({x=x0, y=z0}) * 5 + 0)
local pr = PseudoRandom(seed+1) local pr = PseudoRandom(seed+1)
for i=0,cobbles_amount do for i=0,cobbles_amount do
local x = pr:next(x0, x1) local x = pr:next(x0, x1)
@ -137,7 +137,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine cactus amount from perlin noise -- Determine cactus amount from perlin noise
local cactus_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0) local cactus_amount = math.floor(perlin1:get_2d({x=x0, y=z0}) * 5 + 0)
-- Find random positions for cactus based on this random -- Find random positions for cactus based on this random
local pr = PseudoRandom(seed+1) local pr = PseudoRandom(seed+1)
for i=0,cactus_amount do for i=0,cactus_amount do

View File

@ -83,7 +83,7 @@ function doors:register_door(name, def)
meta:set_string("infotext", "Owned by "..pn) meta:set_string("infotext", "Owned by "..pn)
end end
if not minetest.setting_getbool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
return itemstack return itemstack

View File

@ -291,7 +291,7 @@ minetest.register_node(":default:dirt", {
}), }),
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "farming:hoe" then if puncher:get_wielded_item():get_name() == "farming:hoe" then
minetest.env:set_node(pos, {name="farming:soil"}) minetest.set_node(pos, {name="farming:soil"})
end end
end, end,
}) })
@ -309,7 +309,7 @@ minetest.register_node(":default:dirt_with_grass", {
}), }),
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "farming:hoe" then if puncher:get_wielded_item():get_name() == "farming:hoe" then
minetest.env:set_node(pos, {name="farming:soil"}) minetest.set_node(pos, {name="farming:soil"})
end end
end, end,
}) })

View File

@ -6,7 +6,7 @@ local directions = {
} }
local function update_fence(pos) local function update_fence(pos)
if minetest.get_node_group(minetest.get_node(pos).name, "fence") ~= 1 then if minetest.get_item_group(minetest.get_node(pos).name, "fence") ~= 1 then
return return
end end
local sum = 0 local sum = 0
@ -16,7 +16,7 @@ local function update_fence(pos)
sum = sum + 2 ^ (i - 1) sum = sum + 2 ^ (i - 1)
end end
end end
local material = realtest.registered_trees_list[minetest.get_node_group(minetest.get_node(pos).name, "material")]:remove_modname_prefix() local material = realtest.registered_trees_list[minetest.get_item_group(minetest.get_node(pos).name, "material")]:remove_modname_prefix()
minetest.add_node(pos, {name = "fences:"..material.."_fence_"..sum}) minetest.add_node(pos, {name = "fences:"..material.."_fence_"..sum})
end end

View File

@ -95,7 +95,7 @@ function fire.find_pos_for_flame_around(pos)
end end
function fire.flame_should_extinguish(pos) function fire.flame_should_extinguish(pos)
if minetest.setting_getbool("disable_fire") then return true end if minetest.settings:get_bool("disable_fire") then return true end
--return minetest.find_node_near(pos, 1, {"group:puts_out_fire"}) --return minetest.find_node_near(pos, 1, {"group:puts_out_fire"})
local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2} local p0 = {x=pos.x-2, y=pos.y, z=pos.z-2}
local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2} local p1 = {x=pos.x+2, y=pos.y, z=pos.z+2}
@ -180,7 +180,7 @@ minetest.register_abm({
return return
end end
minetest.remove_node(p) minetest.remove_node(p)
nodeupdate(p) minetest.check_for_falling(p)
end end
else else
-- remove flame -- remove flame

View File

@ -12,7 +12,7 @@ minetest.register_on_generated(function(minp, maxp, seed)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine flowers amount from perlin noise -- Determine flowers amount from perlin noise
local grass_amount = math.floor(perlin1:get2d({x=x0, y=z0}) ^ 3 * 9) local grass_amount = math.floor(perlin1:get_2d({x=x0, y=z0}) ^ 3 * 9)
-- Find random positions for flowers based on this random -- Find random positions for flowers based on this random
local pr = PseudoRandom(seed+456) local pr = PseudoRandom(seed+456)
for i=0,grass_amount do for i=0,grass_amount do

View File

@ -5,7 +5,7 @@ function furnace.check_furnace_blocks(pos)
for n = 1,#furnace_blocks do for n = 1,#furnace_blocks do
local v = furnace_blocks[n] local v = furnace_blocks[n]
if minetest.get_node_or_nil({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}) and if minetest.get_node_or_nil({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}) and
minetest.get_node_group(minetest.get_node({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}).name, "stone") ~= 1 then minetest.get_item_group(minetest.get_node({x=pos.x+v.x,y=pos.y+v.y,z=pos.z+v.z}).name, "stone") ~= 1 then
return false return false
end end
end end

View File

@ -10,7 +10,7 @@ function hatches.register_hatch(name, desc, is_wooden)
minetest.add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2}) minetest.add_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "hatches:"..name.."_hatch_closed", param2 = node.param2})
minetest.remove_node(pos) minetest.remove_node(pos)
elseif node.name == "hatches:"..name.."_hatch_closed" then elseif node.name == "hatches:"..name.."_hatch_closed" then
if (minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "air") and (puncher:getpos().y + 1 >= pos.y) then if (minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name == "air") and (puncher:get_pos().y + 1 >= pos.y) then
minetest.add_node({x = pos.x, y = pos.y - 1, z = pos.z}, {name = "hatches:"..name.."_hatch_opened_bottom", minetest.add_node({x = pos.x, y = pos.y - 1, z = pos.z}, {name = "hatches:"..name.."_hatch_opened_bottom",
param2 = node.param2}) param2 = node.param2})
minetest.remove_node(pos) minetest.remove_node(pos)

View File

@ -83,7 +83,7 @@ instruments.spear.entity = {
instruments.spear.entity.on_step = function(self, dtime) instruments.spear.entity.on_step = function(self, dtime)
self.timer=self.timer+dtime self.timer=self.timer+dtime
local pos = self.object:getpos() local pos = self.object:get_pos()
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
if self.timer > 0.2 and self.lastpos.x then if self.timer > 0.2 and self.lastpos.x then
@ -118,11 +118,11 @@ for i, material in ipairs(instruments.materials) do
description = instruments.desc_list[i].." Spear", description = instruments.desc_list[i].." Spear",
inventory_image = "instruments_spear_"..material..".png", inventory_image = "instruments_spear_"..material..".png",
on_use = function (item, player, pointed_thing) on_use = function (item, player, pointed_thing)
local playerpos=player:getpos() local playerpos=player:get_pos()
local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "instruments:spear_entity") local obj=minetest.add_entity({x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, "instruments:spear_entity")
local dir=player:get_look_dir() local dir=player:get_look_dir()
obj:setvelocity({x=dir.x*instruments.spear.velocity, y=dir.y*instruments.spear.velocity, z=dir.z*instruments.spear.velocity}) obj:set_velocity({x=dir.x*instruments.spear.velocity, y=dir.y*instruments.spear.velocity, z=dir.z*instruments.spear.velocity})
obj:setacceleration({x=dir.x*-3, y=-instruments.spear.gravity, z=dir.z*-3}) obj:set_acceleration({x=dir.x*-3, y=-instruments.spear.gravity, z=dir.z*-3})
obj:get_luaentity().material = material obj:get_luaentity().material = material
return "" return ""
end, end,
@ -140,7 +140,7 @@ for i, material in ipairs(instruments.materials) do
local n = minetest.get_node(pointed_thing.under) local n = minetest.get_node(pointed_thing.under)
if instruments.chisel_pairs[n.name] then if instruments.chisel_pairs[n.name] then
minetest.add_node(pointed_thing.under, {name=instruments.chisel_pairs[n.name], param2=n.param2}) minetest.add_node(pointed_thing.under, {name=instruments.chisel_pairs[n.name], param2=n.param2})
nodeupdate(pointed_thing.under) minetest.check_for_falling(pointed_thing.under)
end end
item:add_wear(65535/instruments.durability[i]/4) item:add_wear(65535/instruments.durability[i]/4)
return item return item

View File

@ -1,11 +1,11 @@
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for _,player in ipairs(minetest.get_connected_players()) do for _,player in ipairs(minetest.get_connected_players()) do
if player:get_hp() > 0 or not minetest.setting_getbool("enable_damage") then if player:get_hp() > 0 or not minetest.settings:get_bool("enable_damage") then
local pos = player:getpos() local pos = player:get_pos()
pos.y = pos.y+0.5 pos.y = pos.y+0.5
local inv = player:get_inventory() local inv = player:get_inventory()
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
@ -21,18 +21,18 @@ minetest.register_globalstep(function(dtime)
end end
end end
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 not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if object:get_luaentity().collect then if object:get_luaentity().collect then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
local pos1 = pos local pos1 = pos
pos1.y = pos1.y+0.2 pos1.y = pos1.y+0.2
local pos2 = object:getpos() local pos2 = object:get_pos()
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z} local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
vec.x = vec.x*3 vec.x = vec.x*3
vec.y = vec.y*3 vec.y = vec.y*3
vec.z = vec.z*3 vec.z = vec.z*3
object:setvelocity(vec) object:set_velocity(vec)
object:get_luaentity().physical_state = false object:get_luaentity().physical_state = false
object:get_luaentity().object:set_properties({ object:get_luaentity().object:set_properties({
physical = false physical = false
@ -54,7 +54,7 @@ minetest.register_globalstep(function(dtime)
object:get_luaentity().itemstring = "" object:get_luaentity().itemstring = ""
object:remove() object:remove()
else else
object:setvelocity({x=0,y=0,z=0}) object:set_velocity({x=0,y=0,z=0})
object:get_luaentity().physical_state = true object:get_luaentity().physical_state = true
object:get_luaentity().object:set_properties({ object:get_luaentity().object:set_properties({
physical = true physical = true
@ -70,6 +70,6 @@ minetest.register_globalstep(function(dtime)
end end
end) end)
if minetest.setting_get("log_mods") then if minetest.settings:get("log_mods") then
minetest.log("action", "item_drop loaded") minetest.log("action", "item_drop loaded")
end end

View File

@ -87,7 +87,7 @@ for _, tree in pairs(realtest.registered_trees) do
local find_instrument = function(instrument) local find_instrument = function(instrument)
for i = 1, 4 do for i = 1, 4 do
local istack = inv:get_stack("instruments", i) local istack = inv:get_stack("instruments", i)
if minetest.get_node_group(istack:get_name(), instrument) == 1 then if minetest.get_item_group(istack:get_name(), instrument) == 1 then
return i return i
end end
end end

View File

@ -53,7 +53,7 @@ end
default.shop.give_inventory = function(inv,list,playername) default.shop.give_inventory = function(inv,list,playername)
player = minetest.env:get_player_by_name(playername) player = minetest.get_player_by_name(playername)
if player then if player then
for k,v in ipairs(inv:get_list(list)) do for k,v in ipairs(inv:get_list(list)) do
player:get_inventory():add_item("main",v) player:get_inventory():add_item("main",v)
@ -101,7 +101,7 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
after_place_node = function(pos, placer, itemstack) after_place_node = function(pos, placer, itemstack)
local owner = placer:get_player_name() local owner = placer:get_player_name()
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("infotext", "Exchange shop (owned by "..owner..")") meta:set_string("infotext", "Exchange shop (owned by "..owner..")")
meta:set_string("owner",owner) meta:set_string("owner",owner)
--[[meta:set_string("pl1","") --[[meta:set_string("pl1","")
@ -116,7 +116,7 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
clicker:get_inventory():set_size("customer_gives", 3*2) clicker:get_inventory():set_size("customer_gives", 3*2)
clicker:get_inventory():set_size("customer_gets", 3*2) clicker:get_inventory():set_size("customer_gets", 3*2)
default.shop.current_shop[clicker:get_player_name()] = pos default.shop.current_shop[clicker:get_player_name()] = pos
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then if clicker:get_player_name() == meta:get_string("owner") and not clicker:get_player_control().aux1 then
minetest.show_formspec(clicker:get_player_name(),"money:shop_formspec",default.shop.formspec.owner(pos)) minetest.show_formspec(clicker:get_player_name(),"money:shop_formspec",default.shop.formspec.owner(pos))
else else
@ -124,22 +124,22 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
end end
end, end,
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then return 0 end if player:get_player_name() ~= meta:get_string("owner") then return 0 end
return count return count
end, end,
allow_metadata_inventory_put = function(pos, listname, index, stack, player) allow_metadata_inventory_put = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then return 0 end if player:get_player_name() ~= meta:get_string("owner") then return 0 end
return stack:get_count() return stack:get_count()
end, end,
allow_metadata_inventory_take = function(pos, listname, index, stack, player) allow_metadata_inventory_take = function(pos, listname, index, stack, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if player:get_player_name() ~= meta:get_string("owner") then return 0 end if player:get_player_name() ~= meta:get_string("owner") then return 0 end
return stack:get_count() return stack:get_count()
end, end,
can_dig = function(pos, player) can_dig = function(pos, player)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives") return inv:is_empty("stock") and inv:is_empty("customers_gave") and inv:is_empty("owner_wants") and inv:is_empty("owner_gives")
end end
@ -161,7 +161,7 @@ minetest.register_on_player_receive_fields(function(sender, formname, fields)
if formname == "money:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then if formname == "money:shop_formspec" and fields.exchange ~= nil and fields.exchange ~= "" then
local name = sender:get_player_name() local name = sender:get_player_name()
local pos = default.shop.current_shop[name] local pos = default.shop.current_shop[name]
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
if meta:get_string("owner") == name then if meta:get_string("owner") == name then
minetest.chat_send_player(name,"This is your own shop, you can't exchange to yourself !") minetest.chat_send_player(name,"This is your own shop, you can't exchange to yourself !")
else else

View File

@ -64,7 +64,7 @@ local humidity_persistence = 0.5
local humidity_scale = 250 local humidity_scale = 250
local time_scale = 1 local time_scale = 1
local time_speed = tonumber(minetest.setting_get("time_speed")) local time_speed = tonumber(minetest.settings:get("time_speed"))
if time_speed and time_speed > 0 then if time_speed and time_speed > 0 then
time_scale = 72 / time_speed time_scale = 72 / time_speed
@ -203,9 +203,9 @@ function plantslib:populate_surfaces(biome, nodes_or_function_or_model, snodes,
for i = 1, #snodes do for i = 1, #snodes do
local pos = snodes[i] local pos = snodes[i]
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z } local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
local noise1 = perlin_fertile_area:get2d({x=pos.x, y=pos.z}) local noise1 = perlin_fertile_area:get_2d({x=pos.x, y=pos.z})
local noise2 = plantslib.perlin_temperature:get2d({x=pos.x, y=pos.z}) local noise2 = plantslib.perlin_temperature:get_2d({x=pos.x, y=pos.z})
local noise3 = plantslib.perlin_humidity:get2d({x=pos.x+150, y=pos.z+50}) local noise3 = plantslib.perlin_humidity:get_2d({x=pos.x+150, y=pos.z+50})
local biome_surfaces_string = dump(biome.surface) local biome_surfaces_string = dump(biome.surface)
local surface_ok = false local surface_ok = false
@ -498,9 +498,9 @@ function plantslib:spawn_on_surfaces(sd,sp,sr,sc,ss,sa)
local p_top = { x = pos.x, y = pos.y + 1, z = pos.z } local p_top = { x = pos.x, y = pos.y + 1, z = pos.z }
local n_top = minetest.get_node(p_top) local n_top = minetest.get_node(p_top)
local perlin_fertile_area = minetest.get_perlin(biome.seed_diff, perlin_octaves, perlin_persistence, perlin_scale) local perlin_fertile_area = minetest.get_perlin(biome.seed_diff, perlin_octaves, perlin_persistence, perlin_scale)
local noise1 = perlin_fertile_area:get2d({x=p_top.x, y=p_top.z}) local noise1 = perlin_fertile_area:get_2d({x=p_top.x, y=p_top.z})
local noise2 = plantslib.perlin_temperature:get2d({x=p_top.x, y=p_top.z}) local noise2 = plantslib.perlin_temperature:get_2d({x=p_top.x, y=p_top.z})
local noise3 = plantslib.perlin_humidity:get2d({x=p_top.x+150, y=p_top.z+50}) local noise3 = plantslib.perlin_humidity:get_2d({x=p_top.x+150, y=p_top.z+50})
if noise1 > biome.plantlife_limit if noise1 > biome.plantlife_limit
and noise2 <= biome.temp_min and noise2 <= biome.temp_min
and noise2 >= biome.temp_max and noise2 >= biome.temp_max
@ -625,14 +625,14 @@ function plantslib:replace_object(pos, replacement, grow_function, walldir, seed
return return
elseif growtype == "function" then elseif growtype == "function" then
local perlin_fertile_area = minetest.get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale) local perlin_fertile_area = minetest.get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale)
local noise1 = perlin_fertile_area:get2d({x=pos.x, y=pos.z}) local noise1 = perlin_fertile_area:get_2d({x=pos.x, y=pos.z})
local noise2 = plantslib.perlin_temperature:get2d({x=pos.x, y=pos.z}) local noise2 = plantslib.perlin_temperature:get_2d({x=pos.x, y=pos.z})
grow_function(pos,noise1,noise2,walldir) grow_function(pos,noise1,noise2,walldir)
return return
elseif growtype == "string" then elseif growtype == "string" then
local perlin_fertile_area = minetest.get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale) local perlin_fertile_area = minetest.get_perlin(seeddiff, perlin_octaves, perlin_persistence, perlin_scale)
local noise1 = perlin_fertile_area:get2d({x=pos.x, y=pos.z}) local noise1 = perlin_fertile_area:get_2d({x=pos.x, y=pos.z})
local noise2 = plantslib.perlin_temperature:get2d({x=pos.x, y=pos.z}) local noise2 = plantslib.perlin_temperature:get_2d({x=pos.x, y=pos.z})
assert(loadstring(grow_function.."(...)"))(pos,noise1,noise2,walldir) assert(loadstring(grow_function.."(...)"))(pos,noise1,noise2,walldir)
return return
elseif growtype == "nil" then elseif growtype == "nil" then
@ -711,7 +711,7 @@ end
-- Check for infinite stacks -- Check for infinite stacks
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
plantslib.expect_infinite_stacks = false plantslib.expect_infinite_stacks = false
else else
plantslib.expect_infinite_stacks = true plantslib.expect_infinite_stacks = true

View File

@ -252,8 +252,8 @@ minetest.register_entity(
self.timer = ENV_CHECK_PERIOD__S self.timer = ENV_CHECK_PERIOD__S
local haveFlame = minetest.registered_nodes["fire:basic_flame"] local haveFlame = minetest.registered_nodes["fire:basic_flame"]
local pos = self.object:getpos() local pos = self.object:get_pos()
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
local nodeType = node and minetest.registered_nodes[node.name] local nodeType = node and minetest.registered_nodes[node.name]
if nodeType and nodeType.walkable and not nodeType.buildable_to then if nodeType and nodeType.walkable and not nodeType.buildable_to then
@ -262,16 +262,16 @@ minetest.register_entity(
if minetest.get_item_group(node.name, "lava") > 0 then if minetest.get_item_group(node.name, "lava") > 0 then
if haveFlame then if haveFlame then
local flamePos = minetest.env:find_node_near(pos, 1.0, "air") local flamePos = minetest.find_node_near(pos, 1.0, "air")
if flamePos then if flamePos then
minetest.env:add_node(flamePos, minetest.add_node(flamePos,
{ name = "fire:basic_flame" }) { name = "fire:basic_flame" })
end end
end end
return self:burn() return self:burn()
end end
if minetest.env:find_node_near(pos, 1.0, "group:puts_out_fire") then if minetest.find_node_near(pos, 1.0, "group:puts_out_fire") then
return return
end end
@ -285,13 +285,13 @@ minetest.register_entity(
local burnLevels = 0.0 local burnLevels = 0.0
local igniterPosList = local igniterPosList =
minetest.env:find_nodes_in_area(minPos, maxPos, "group:igniter") minetest.find_nodes_in_area(minPos, maxPos, "group:igniter")
for i, igniterPos in ipairs(igniterPosList) do for i, igniterPos in ipairs(igniterPosList) do
local distSq = (igniterPos.x - pos.x)^2 + local distSq = (igniterPos.x - pos.x)^2 +
(igniterPos.y - pos.y)^2 + (igniterPos.y - pos.y)^2 +
(igniterPos.z - pos.z)^2 (igniterPos.z - pos.z)^2
if distSq <= MAX_IGNITE_DIST^2 + EPSILON then if distSq <= MAX_IGNITE_DIST^2 + EPSILON then
local igniterNode = minetest.env:get_node(igniterPos) local igniterNode = minetest.get_node(igniterPos)
local igniterLevel = local igniterLevel =
minetest.get_item_group(igniterNode.name, "igniter") minetest.get_item_group(igniterNode.name, "igniter")
- math.max(1.0, math.sqrt(distSq) - EPSILON) - math.max(1.0, math.sqrt(distSq) - EPSILON)
@ -312,9 +312,9 @@ minetest.register_entity(
local flamePos = local flamePos =
(node.name == "air") (node.name == "air")
and pos and pos
or minetest.env:find_node_near(pos, 1.0, "air") or minetest.find_node_near(pos, 1.0, "air")
if flamePos then if flamePos then
minetest.env:add_node(flamePos, minetest.add_node(flamePos,
{ name = "fire:basic_flame" }) { name = "fire:basic_flame" })
end end
end end
@ -347,7 +347,7 @@ local function rezEntity(stack, pos, player)
local z = pos.z local z = pos.z
while true do while true do
local node = minetest.env:get_node({ x = x, y = y-1, z = z}) local node = minetest.get_node({ x = x, y = y-1, z = z})
local nodeType = node and minetest.registered_nodes[node.name] local nodeType = node and minetest.registered_nodes[node.name]
if not nodeType or nodeType.walkable then if not nodeType or nodeType.walkable then
break break
@ -355,7 +355,7 @@ local function rezEntity(stack, pos, player)
y = y - 1 y = y - 1
end end
local obj = minetest.env:add_entity(pos, "prestibags:bag_entity") local obj = minetest.add_entity(pos, "prestibags:bag_entity")
if not obj then return stack end if not obj then return stack end
local contentData = stack:get_metadata() local contentData = stack:get_metadata()
@ -390,14 +390,14 @@ minetest.register_tool(
on_place = function(stack, player, pointedThing) on_place = function(stack, player, pointedThing)
local pos = pointedThing and pointedThing.under local pos = pointedThing and pointedThing.under
local node = pos and minetest.env:get_node(pos) local node = pos and minetest.get_node(pos)
local nodeType = node and minetest.registered_nodes[node.name] local nodeType = node and minetest.registered_nodes[node.name]
if not nodeType or not nodeType.buildable_to then if not nodeType or not nodeType.buildable_to then
pos = pointedThing and pointedThing.above pos = pointedThing and pointedThing.above
node = pos and minetest.env:get_node(pos) node = pos and minetest.get_node(pos)
nodeType = node and minetest.registered_nodes[node.name] nodeType = node and minetest.registered_nodes[node.name]
end end
if not pos then pos = player:getpos() end if not pos then pos = player:get_pos() end
return rezEntity(stack, pos, player) return rezEntity(stack, pos, player)
end, end,

View File

@ -1,11 +1,11 @@
-- Event handlers -- Event handlers
local function scaffolding_update(pos) local function scaffolding_update(pos)
local node_name = minetest.get_node(pos).name local node_name = minetest.get_node(pos).name
if minetest.get_node_group(node_name, "scaffolding") ~= 1 then if minetest.get_item_group(node_name, "scaffolding") ~= 1 then
return return
end end
local material = realtest.registered_trees_list[minetest.get_node_group(node_name, "material")]:remove_modname_prefix() local material = realtest.registered_trees_list[minetest.get_item_group(node_name, "material")]:remove_modname_prefix()
if minetest.get_node_group(minetest.get_node(mod_pos(pos, 0, 1, 0)).name, "scaffolding") == 1 then if minetest.get_item_group(minetest.get_node(mod_pos(pos, 0, 1, 0)).name, "scaffolding") == 1 then
minetest.add_node(pos, {name = "scaffolding:scaffolding_sub_"..material}) minetest.add_node(pos, {name = "scaffolding:scaffolding_sub_"..material})
else else
minetest.add_node(pos, {name = "scaffolding:scaffolding_top_"..material}) minetest.add_node(pos, {name = "scaffolding:scaffolding_top_"..material})
@ -58,7 +58,7 @@ for i, tree_name in ipairs(realtest.registered_trees_list) do
cause_drop = function(pos, node) cause_drop = function(pos, node)
local b_pos = {x=pos.x,y=pos.y-1,z=pos.z} local b_pos = {x=pos.x,y=pos.y-1,z=pos.z}
local b_node = minetest.get_node(b_pos) local b_node = minetest.get_node(b_pos)
if minetest.get_node_group(b_node.name, "scaffolding") ~= 1 and minetest.registered_nodes[b_node.name].walkable == false then if minetest.get_item_group(b_node.name, "scaffolding") ~= 1 and minetest.registered_nodes[b_node.name].walkable == false then
return true return true
end end
end end

View File

@ -18,7 +18,7 @@ minetest.register_node("smelter:smelter", {
legacy_facedir_simple = true, legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", smelter.smelter_formspec) meta:set_string("formspec", smelter.smelter_formspec)
meta:set_string("infotext", "Smelter") meta:set_string("infotext", "Smelter")
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -27,7 +27,7 @@ minetest.register_node("smelter:smelter", {
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then if not inv:is_empty("fuel") then
return false return false
@ -51,7 +51,7 @@ minetest.register_node("smelter:smelter_active", {
legacy_facedir_simple = true, legacy_facedir_simple = true,
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
meta:set_string("formspec", smelter.smelter_formspec) meta:set_string("formspec", smelter.smelter_formspec)
meta:set_string("infotext", "Smelter"); meta:set_string("infotext", "Smelter");
local inv = meta:get_inventory() local inv = meta:get_inventory()
@ -60,7 +60,7 @@ minetest.register_node("smelter:smelter_active", {
inv:set_size("dst", 4) inv:set_size("dst", 4)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("fuel") then if not inv:is_empty("fuel") then
return false return false
@ -80,7 +80,7 @@ minetest.register_abm({
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)
-- Init the values -- Init the values
local meta = minetest.env:get_meta(pos) local meta = minetest.get_meta(pos)
for i, name in ipairs({ for i, name in ipairs({
"fuel_totaltime", "fuel_totaltime",
"fuel_time", "fuel_time",

View File

@ -2,7 +2,7 @@ spikes = {}
spikes.intllib_modpath = minetest.get_modpath("intllib") spikes.intllib_modpath = minetest.get_modpath("intllib")
if minetest.get_modpath("unified_inventory") or not minetest.setting_getbool("creative_mode") then if minetest.get_modpath("unified_inventory") or not minetest.settings:get_bool("creative_mode") then
spikes.expect_infinite_stacks = false spikes.expect_infinite_stacks = false
else else
spikes.expect_infinite_stacks = true spikes.expect_infinite_stacks = true

View File

@ -12,7 +12,7 @@ minetest.register_tool("sticks:sticks", {
end end
pos = pointed_thing.above pos = pointed_thing.above
elseif pointed_thing.type == "object" then elseif pointed_thing.type == "object" then
pos = pointed_thing.ref:getpos() pos = pointed_thing.ref:get_pos()
else else
return return
end end

View File

@ -1,31 +1,31 @@
local destroy = function(pos) local destroy = function(pos)
local nodename = minetest.env:get_node(pos).name local nodename = minetest.get_node(pos).name
if nodename ~= "air" then if nodename ~= "air" then
minetest.env:remove_node(pos) minetest.remove_node(pos)
nodeupdate(pos) minetest.check_for_falling(pos)
if minetest.registered_nodes[nodename].groups.flammable ~= nil then if minetest.registered_nodes[nodename].groups.flammable ~= nil then
minetest.env:set_node(pos, {name="fire:basic_flame"}) minetest.set_node(pos, {name="fire:basic_flame"})
return return
end end
local drop = minetest.get_node_drops(nodename, "") local drop = minetest.get_node_drops(nodename, "")
for _,item in ipairs(drop) do for _,item in ipairs(drop) do
if type(item) == "string" then if type(item) == "string" then
local obj = minetest.env:add_item(pos, item) local obj = minetest.add_item(pos, item)
if obj == nil then if obj == nil then
return return
end end
obj:get_luaentity().collect = true obj:get_luaentity().collect = true
obj:setacceleration({x=0, y=-10, z=0}) obj:set_acceleration({x=0, y=-10, z=0})
obj:setvelocity({x=math.random(0,6)-3, y=10, z=math.random(0,6)-3}) obj:set_velocity({x=math.random(0,6)-3, y=10, z=math.random(0,6)-3})
else else
for i=1,item:get_count() do for i=1,item:get_count() do
local obj = minetest.env:add_item(pos, item:get_name()) local obj = minetest.add_item(pos, item:get_name())
if obj == nil then if obj == nil then
return return
end end
obj:get_luaentity().collect = true obj:get_luaentity().collect = true
obj:setacceleration({x=0, y=-10, z=0}) obj:set_acceleration({x=0, y=-10, z=0})
obj:setvelocity({x=math.random(0,6)-3, y=10, z=math.random(0,6)-3}) obj:set_velocity({x=math.random(0,6)-3, y=10, z=math.random(0,6)-3})
end end
end end
end end
@ -34,19 +34,19 @@ end
boom = function(pos, time) boom = function(pos, time)
minetest.after(time, function(pos) minetest.after(time, function(pos)
if minetest.env:get_node(pos).name ~= "tnt:tnt_burning" then if minetest.get_node(pos).name ~= "tnt:tnt_burning" then
return return
end end
minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64}) minetest.sound_play("tnt_explode", {pos=pos, gain=1.5, max_hear_distance=2*64})
minetest.env:set_node(pos, {name="tnt:boom"}) minetest.set_node(pos, {name="tnt:boom"})
minetest.after(0.5, function(pos) minetest.after(0.5, function(pos)
minetest.env:remove_node(pos) minetest.remove_node(pos)
end, {x=pos.x, y=pos.y, z=pos.z}) end, {x=pos.x, y=pos.y, z=pos.z})
local objects = minetest.env:get_objects_inside_radius(pos, 3) local objects = minetest.get_objects_inside_radius(pos, 3)
for _,obj in ipairs(objects) do for _,obj in ipairs(objects) do
if obj:is_player() or (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item") then if obj:is_player() or (obj:get_luaentity() and obj:get_luaentity().name ~= "__builtin:item") then
local obj_p = obj:getpos() local obj_p = obj:get_pos()
local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z} local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5 local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
local damage = (80*0.5^dist)*2 local damage = (80*0.5^dist)*2
@ -71,20 +71,20 @@ boom = function(pos, time)
pos.y = pos.y+dy pos.y = pos.y+dy
pos.z = pos.z+dz pos.z = pos.z+dz
local node = minetest.env:get_node(pos) local node = minetest.get_node(pos)
if node.name == "tnt:tnt" or node.name == "tnt:tnt_burning" then if node.name == "tnt:tnt" or node.name == "tnt:tnt_burning" then
minetest.env:set_node(pos, {name="tnt:tnt_burning"}) minetest.set_node(pos, {name="tnt:tnt_burning"})
boom({x=pos.x, y=pos.y, z=pos.z}, 0) boom({x=pos.x, y=pos.y, z=pos.z}, 0)
elseif node.name == "fire:basic_flame" or string.find(node.name, "default:water_") or string.find(node.name, "default:lava_") or node.name == "tnt:boom" then elseif node.name == "fire:basic_flame" or string.find(node.name, "default:water_") or string.find(node.name, "default:lava_") or node.name == "tnt:boom" then
else else
if math.abs(dx)<2 and math.abs(dy)<2 and math.abs(dz)<2 then if math.abs(dx)<2 and math.abs(dy)<2 and math.abs(dz)<2 then
if minetest.env:get_node(pos).name ~= "default:obsidian" then if minetest.get_node(pos).name ~= "default:obsidian" then
destroy(pos) destroy(pos)
end end
else else
if math.random(1,5) <= 4 then if math.random(1,5) <= 4 then
if minetest.env:get_node(pos).name ~= "default:obsidian" then if minetest.get_node(pos).name ~= "default:obsidian" then
destroy(pos) destroy(pos)
end end
end end
@ -116,20 +116,20 @@ minetest.register_node("tnt:tnt", {
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "default:torch" then if puncher:get_wielded_item():get_name() == "default:torch" then
minetest.sound_play("tnt_ignite", {pos=pos}) minetest.sound_play("tnt_ignite", {pos=pos})
minetest.env:set_node(pos, {name="tnt:tnt_burning"}) minetest.set_node(pos, {name="tnt:tnt_burning"})
boom(pos, 4) boom(pos, 4)
end end
end, end,
on_timer = function(pos,elapsed) on_timer = function(pos,elapsed)
minetest.env:set_node(pos, {name="tnt:tnt_burning"}) minetest.set_node(pos, {name="tnt:tnt_burning"})
boom(pos, 0) boom(pos, 0)
end, end,
mesecons = { mesecons = {
effector = { effector = {
action_on = function(pos, node) action_on = function(pos, node)
minetest.env:set_node(pos, {name="tnt:tnt_burning"}) minetest.set_node(pos, {name="tnt:tnt_burning"})
boom(pos, 0) boom(pos, 0)
end end
}, },
@ -152,7 +152,7 @@ minetest.register_node("tnt:tnt_burning", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
on_timer = function(pos,elapsed) on_timer = function(pos,elapsed)
minetest.env:set_node(pos, {name="tnt:tnt_burning"}) minetest.set_node(pos, {name="tnt:tnt_burning"})
boom(pos, 0) boom(pos, 0)
end, end,
@ -168,24 +168,24 @@ minetest.register_node("tnt:boom", {
}) })
burn = function(pos) burn = function(pos)
if minetest.env:get_node(pos).name == "tnt:tnt" then if minetest.get_node(pos).name == "tnt:tnt" then
minetest.sound_play("tnt_ignite", {pos=pos}) minetest.sound_play("tnt_ignite", {pos=pos})
minetest.env:set_node(pos, {name="tnt:tnt_burning"}) minetest.set_node(pos, {name="tnt:tnt_burning"})
boom(pos, 1) boom(pos, 1)
return return
end end
if minetest.env:get_node(pos).name ~= "tnt:gunpowder" then if minetest.get_node(pos).name ~= "tnt:gunpowder" then
return return
end end
minetest.sound_play("tnt_gunpowder_burning", {pos=pos, gain=2}) minetest.sound_play("tnt_gunpowder_burning", {pos=pos, gain=2})
minetest.env:set_node(pos, {name="tnt:gunpowder_burning"}) minetest.set_node(pos, {name="tnt:gunpowder_burning"})
minetest.after(1, function(pos) minetest.after(1, function(pos)
if minetest.env:get_node(pos).name ~= "tnt:gunpowder_burning" then if minetest.get_node(pos).name ~= "tnt:gunpowder_burning" then
return return
end end
minetest.after(0.5, function(pos) minetest.after(0.5, function(pos)
minetest.env:remove_node(pos) minetest.remove_node(pos)
end, {x=pos.x, y=pos.y, z=pos.z}) end, {x=pos.x, y=pos.y, z=pos.z})
for dx=-1,1 do for dx=-1,1 do
for dz=-1,1 do for dz=-1,1 do
@ -213,7 +213,7 @@ burn = function(pos)
end, pos) end, pos)
end end
if minetest.setting_get("log_mods") then if minetest.settings:get("log_mods") then
minetest.log("action", "tnt loaded") minetest.log("action", "tnt loaded")
end end
@ -223,7 +223,7 @@ minetest.register_abm({
interval = 4, interval = 4,
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 ntimer = minetest.env:get_node_timer(pos) local ntimer = minetest.get_node_timer(pos)
ntimer:start(1) ntimer:start(1)
end, end,
}) })

View File

@ -37,7 +37,7 @@ local function generate(tree, minp, maxp, seed)
local x1 = minp.x + math.floor((divx+1)*divlen) local x1 = minp.x + math.floor((divx+1)*divlen)
local z1 = minp.z + math.floor((divz+1)*divlen) local z1 = minp.z + math.floor((divz+1)*divlen)
-- Determine trees amount from perlin noise -- Determine trees amount from perlin noise
local trees_amount = math.floor(perlin1:get2d({x=x0, y=z0}) * 5 + 0) local trees_amount = math.floor(perlin1:get_2d({x=x0, y=z0}) * 5 + 0)
-- Find random positions for trees based on this random -- Find random positions for trees based on this random
local pr = PseudoRandom(seed) local pr = PseudoRandom(seed)
for i=0,trees_amount do for i=0,trees_amount do

View File

@ -377,7 +377,7 @@ function realtest.register_tree(name, TreeDef)
end end
if param2 then if param2 then
minetest.set_node(pointed_thing.above,{name = tree.name.."_ladder", param2 = param2}) minetest.set_node(pointed_thing.above,{name = tree.name.."_ladder", param2 = param2})
if not minetest.setting_getbool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
itemstack:take_item() itemstack:take_item()
end end
end end

View File

@ -10,7 +10,7 @@ minetest.register_on_joinplayer(function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
table.insert(players, player_name) table.insert(players, player_name)
last_wielded[player_name] = player:get_wielded_item():get_name() last_wielded[player_name] = player:get_wielded_item():get_name()
local pos = player:getpos() local pos = player:get_pos()
local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
local wielded_item = player:get_wielded_item():get_name() local wielded_item = player:get_wielded_item():get_name()
if wielded_item ~= "default:torch" and wielded_item ~= "light:streetlight" then if wielded_item ~= "default:torch" and wielded_item ~= "light:streetlight" then
@ -30,7 +30,7 @@ minetest.register_on_leaveplayer(function(player)
table.remove(players, i) table.remove(players, i)
last_wielded[player_name] = nil last_wielded[player_name] = nil
-- Neuberechnung des Lichts erzwingen -- Neuberechnung des Lichts erzwingen
local pos = player:getpos() local pos = player:get_pos()
local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
minetest.set_node(rounded_pos,{type="node",name="air"}) minetest.set_node(rounded_pos,{type="node",name="air"})
player_positions[player_name]["x"] = nil player_positions[player_name]["x"] = nil
@ -48,7 +48,7 @@ minetest.register_globalstep(function(dtime)
local wielded_item = player:get_wielded_item():get_name() local wielded_item = player:get_wielded_item():get_name()
if wielded_item == "default:torch" or wielded_item == "light:streetlight" then if wielded_item == "default:torch" or wielded_item == "light:streetlight" then
-- Fackel ist in der Hand -- Fackel ist in der Hand
local pos = player:getpos() local pos = player:get_pos()
local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
if (last_wielded[player_name] ~= "default:torch" and last_wielded[player_name] ~= "light:streetlight") or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then if (last_wielded[player_name] ~= "default:torch" and last_wielded[player_name] ~= "light:streetlight") or (player_positions[player_name]["x"] ~= rounded_pos.x or player_positions[player_name]["y"] ~= rounded_pos.y or player_positions[player_name]["z"] ~= rounded_pos.z) then
-- Fackel gerade in die Hand genommen oder zu neuem Node bewegt -- Fackel gerade in die Hand genommen oder zu neuem Node bewegt
@ -75,7 +75,7 @@ minetest.register_globalstep(function(dtime)
last_wielded[player_name] = wielded_item; last_wielded[player_name] = wielded_item;
elseif last_wielded[player_name] == "default:torch" or last_wielded[player_name] == "light:streetlight" then elseif last_wielded[player_name] == "default:torch" or last_wielded[player_name] == "light:streetlight" then
-- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand -- Fackel nicht in der Hand, aber beim letzten Durchgang war die Fackel noch in der Hand
local pos = player:getpos() local pos = player:get_pos()
local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)} local rounded_pos = {x=round(pos.x),y=round(pos.y)+1,z=round(pos.z)}
repeat repeat
local is_light = minetest.get_node_or_nil(rounded_pos) local is_light = minetest.get_node_or_nil(rounded_pos)

View File

@ -15,7 +15,7 @@
-- You should have received a copy of the GNU Lesser General Public -- You should have received a copy of the GNU Lesser General Public
-- License along with this program. If not, see -- License along with this program. If not, see
-- <http://www.gnu.org/licenses/> -- <http://www.gnu.org/licenses/>
if not minetest.setting_getbool("creative_mode") then if not minetest.settings:get_bool("creative_mode") then
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
-- make the craft guide available -- make the craft guide available
@ -69,7 +69,7 @@ for _, tree in pairs(realtest.registered_trees) do
meta:set_string("formspec", CRAFTING_FORMSPEC) meta:set_string("formspec", CRAFTING_FORMSPEC)
end, end,
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if inv:is_empty("craft") then if inv:is_empty("craft") then
return true return true