Builtin: Replace deprecated function calls (#7561)
This commit is contained in:
parent
7e76781495
commit
c08b05bb36
|
@ -380,7 +380,7 @@ core.register_chatcommand("teleport", {
|
||||||
end
|
end
|
||||||
teleportee = core.get_player_by_name(name)
|
teleportee = core.get_player_by_name(name)
|
||||||
if teleportee then
|
if teleportee then
|
||||||
teleportee:setpos(p)
|
teleportee:set_pos(p)
|
||||||
return true, "Teleporting to "..core.pos_to_string(p)
|
return true, "Teleporting to "..core.pos_to_string(p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -393,12 +393,12 @@ core.register_chatcommand("teleport", {
|
||||||
if target_name then
|
if target_name then
|
||||||
local target = core.get_player_by_name(target_name)
|
local target = core.get_player_by_name(target_name)
|
||||||
if target then
|
if target then
|
||||||
p = target:getpos()
|
p = target:get_pos()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if teleportee and p then
|
if teleportee and p then
|
||||||
p = find_free_position_near(p)
|
p = find_free_position_near(p)
|
||||||
teleportee:setpos(p)
|
teleportee:set_pos(p)
|
||||||
return true, "Teleporting to " .. target_name
|
return true, "Teleporting to " .. target_name
|
||||||
.. " at "..core.pos_to_string(p)
|
.. " at "..core.pos_to_string(p)
|
||||||
end
|
end
|
||||||
|
@ -417,7 +417,7 @@ core.register_chatcommand("teleport", {
|
||||||
teleportee = core.get_player_by_name(teleportee_name)
|
teleportee = core.get_player_by_name(teleportee_name)
|
||||||
end
|
end
|
||||||
if teleportee and p.x and p.y and p.z then
|
if teleportee and p.x and p.y and p.z then
|
||||||
teleportee:setpos(p)
|
teleportee:set_pos(p)
|
||||||
return true, "Teleporting " .. teleportee_name
|
return true, "Teleporting " .. teleportee_name
|
||||||
.. " to " .. core.pos_to_string(p)
|
.. " to " .. core.pos_to_string(p)
|
||||||
end
|
end
|
||||||
|
@ -433,12 +433,12 @@ core.register_chatcommand("teleport", {
|
||||||
if target_name then
|
if target_name then
|
||||||
local target = core.get_player_by_name(target_name)
|
local target = core.get_player_by_name(target_name)
|
||||||
if target then
|
if target then
|
||||||
p = target:getpos()
|
p = target:get_pos()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if teleportee and p then
|
if teleportee and p then
|
||||||
p = find_free_position_near(p)
|
p = find_free_position_near(p)
|
||||||
teleportee:setpos(p)
|
teleportee:set_pos(p)
|
||||||
return true, "Teleporting " .. teleportee_name
|
return true, "Teleporting " .. teleportee_name
|
||||||
.. " to " .. target_name
|
.. " to " .. target_name
|
||||||
.. " at " .. core.pos_to_string(p)
|
.. " at " .. core.pos_to_string(p)
|
||||||
|
@ -664,7 +664,7 @@ core.register_chatcommand("spawnentity", {
|
||||||
return false, "Cannot spawn an unknown entity"
|
return false, "Cannot spawn an unknown entity"
|
||||||
end
|
end
|
||||||
if p == "" then
|
if p == "" then
|
||||||
p = player:getpos()
|
p = player:get_pos()
|
||||||
else
|
else
|
||||||
p = core.string_to_pos(p)
|
p = core.string_to_pos(p)
|
||||||
if p == nil then
|
if p == nil then
|
||||||
|
|
|
@ -52,12 +52,12 @@ core.register_entity(":__builtin:falling_node", {
|
||||||
|
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
-- Set gravity
|
-- Set gravity
|
||||||
local acceleration = self.object:getacceleration()
|
local acceleration = self.object:get_acceleration()
|
||||||
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
|
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
|
||||||
self.object:setacceleration({x = 0, y = -10, z = 0})
|
self.object:set_acceleration({x = 0, y = -10, z = 0})
|
||||||
end
|
end
|
||||||
-- Turn to actual node when colliding with ground, or continue to move
|
-- Turn to actual node when colliding with ground, or continue to move
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:get_pos()
|
||||||
-- Position of bottom center point
|
-- Position of bottom center point
|
||||||
local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
|
local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
|
||||||
-- 'bcn' is nil for unloaded nodes
|
-- 'bcn' is nil for unloaded nodes
|
||||||
|
@ -124,10 +124,10 @@ core.register_entity(":__builtin:falling_node", {
|
||||||
core.check_for_falling(np)
|
core.check_for_falling(np)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local vel = self.object:getvelocity()
|
local vel = self.object:get_velocity()
|
||||||
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
|
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
|
||||||
local npos = self.object:getpos()
|
local npos = self.object:get_pos()
|
||||||
self.object:setpos(vector.round(npos))
|
self.object:set_pos(vector.round(npos))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,7 +33,7 @@ function core.get_pointed_thing_position(pointed_thing, above)
|
||||||
-- The position where a node would be dug
|
-- The position where a node would be dug
|
||||||
return pointed_thing.under
|
return pointed_thing.under
|
||||||
elseif pointed_thing.type == "object" then
|
elseif pointed_thing.type == "object" then
|
||||||
return pointed_thing.ref and pointed_thing.ref:getpos()
|
return pointed_thing.ref and pointed_thing.ref:get_pos()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
|
||||||
-- Calculate the direction for furnaces and chests and stuff
|
-- Calculate the direction for furnaces and chests and stuff
|
||||||
elseif (def.paramtype2 == "facedir" or
|
elseif (def.paramtype2 == "facedir" or
|
||||||
def.paramtype2 == "colorfacedir") and not param2 then
|
def.paramtype2 == "colorfacedir") and not param2 then
|
||||||
local placer_pos = placer and placer:getpos()
|
local placer_pos = placer and 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,
|
||||||
|
@ -478,7 +478,7 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
|
||||||
if inv and inv:room_for_item("main", {name=replace_with_item}) then
|
if inv and inv:room_for_item("main", {name=replace_with_item}) then
|
||||||
inv:add_item("main", replace_with_item)
|
inv:add_item("main", replace_with_item)
|
||||||
else
|
else
|
||||||
local pos = user:getpos()
|
local pos = user:get_pos()
|
||||||
pos.y = math.floor(pos.y + 0.5)
|
pos.y = math.floor(pos.y + 0.5)
|
||||||
core.add_item(pos, replace_with_item)
|
core.add_item(pos, replace_with_item)
|
||||||
end
|
end
|
||||||
|
|
|
@ -152,7 +152,7 @@ core.register_entity(":__builtin:item", {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local vel = self.object:getvelocity()
|
local vel = self.object:get_velocity()
|
||||||
local def = node and core.registered_nodes[node.name]
|
local def = node and core.registered_nodes[node.name]
|
||||||
local is_moving = (def and not def.walkable) or
|
local is_moving = (def and not def.walkable) or
|
||||||
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0
|
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0
|
||||||
|
|
|
@ -113,7 +113,7 @@ function core.get_player_radius_area(player_name, radius)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local p1 = player:getpos()
|
local p1 = player:get_pos()
|
||||||
local p2 = p1
|
local p2 = p1
|
||||||
|
|
||||||
if radius then
|
if radius then
|
||||||
|
|
|
@ -15,7 +15,7 @@ local function put_player_in_spawn(player_obj)
|
||||||
end
|
end
|
||||||
core.log("action", "Moving " .. player_obj:get_player_name() ..
|
core.log("action", "Moving " .. player_obj:get_player_name() ..
|
||||||
" to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
|
" to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
|
||||||
player_obj:setpos(static_spawnpoint)
|
player_obj:set_pos(static_spawnpoint)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue