From ade7a1cbcf7156ebddb12bd2ec2ea60818d72b19 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Tue, 17 Jul 2018 20:17:54 +0200 Subject: [PATCH] Builtin: Replace deprecated function calls (#7561) --- builtin/game/chatcommands.lua | 14 +++++++------- builtin/game/falling.lua | 12 ++++++------ builtin/game/item.lua | 6 +++--- builtin/game/item_entity.lua | 2 +- builtin/game/misc.lua | 2 +- builtin/game/static_spawn.lua | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/builtin/game/chatcommands.lua b/builtin/game/chatcommands.lua index 985670572..b7f228c1b 100644 --- a/builtin/game/chatcommands.lua +++ b/builtin/game/chatcommands.lua @@ -380,7 +380,7 @@ core.register_chatcommand("teleport", { end teleportee = core.get_player_by_name(name) if teleportee then - teleportee:setpos(p) + teleportee:set_pos(p) return true, "Teleporting to "..core.pos_to_string(p) end end @@ -393,12 +393,12 @@ core.register_chatcommand("teleport", { if target_name then local target = core.get_player_by_name(target_name) if target then - p = target:getpos() + p = target:get_pos() end end if teleportee and p then p = find_free_position_near(p) - teleportee:setpos(p) + teleportee:set_pos(p) return true, "Teleporting to " .. target_name .. " at "..core.pos_to_string(p) end @@ -417,7 +417,7 @@ core.register_chatcommand("teleport", { teleportee = core.get_player_by_name(teleportee_name) end if teleportee and p.x and p.y and p.z then - teleportee:setpos(p) + teleportee:set_pos(p) return true, "Teleporting " .. teleportee_name .. " to " .. core.pos_to_string(p) end @@ -433,12 +433,12 @@ core.register_chatcommand("teleport", { if target_name then local target = core.get_player_by_name(target_name) if target then - p = target:getpos() + p = target:get_pos() end end if teleportee and p then p = find_free_position_near(p) - teleportee:setpos(p) + teleportee:set_pos(p) return true, "Teleporting " .. teleportee_name .. " to " .. target_name .. " at " .. core.pos_to_string(p) @@ -664,7 +664,7 @@ core.register_chatcommand("spawnentity", { return false, "Cannot spawn an unknown entity" end if p == "" then - p = player:getpos() + p = player:get_pos() else p = core.string_to_pos(p) if p == nil then diff --git a/builtin/game/falling.lua b/builtin/game/falling.lua index 4806a7427..62b6973a7 100644 --- a/builtin/game/falling.lua +++ b/builtin/game/falling.lua @@ -52,12 +52,12 @@ core.register_entity(":__builtin:falling_node", { on_step = function(self, dtime) -- 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 - self.object:setacceleration({x = 0, y = -10, z = 0}) + self.object:set_acceleration({x = 0, y = -10, z = 0}) end -- 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 local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z} -- 'bcn' is nil for unloaded nodes @@ -124,10 +124,10 @@ core.register_entity(":__builtin:falling_node", { core.check_for_falling(np) return end - local vel = self.object:getvelocity() + local vel = self.object:get_velocity() if vector.equals(vel, {x = 0, y = 0, z = 0}) then - local npos = self.object:getpos() - self.object:setpos(vector.round(npos)) + local npos = self.object:get_pos() + self.object:set_pos(vector.round(npos)) end end }) diff --git a/builtin/game/item.lua b/builtin/game/item.lua index 8fbe5b672..591531db0 100644 --- a/builtin/game/item.lua +++ b/builtin/game/item.lua @@ -33,7 +33,7 @@ function core.get_pointed_thing_position(pointed_thing, above) -- The position where a node would be dug return pointed_thing.under 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 @@ -331,7 +331,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2, -- Calculate the direction for furnaces and chests and stuff elseif (def.paramtype2 == "facedir" or 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 local dir = { 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 inv:add_item("main", replace_with_item) else - local pos = user:getpos() + local pos = user:get_pos() pos.y = math.floor(pos.y + 0.5) core.add_item(pos, replace_with_item) end diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua index 4dca6117d..a330e8723 100644 --- a/builtin/game/item_entity.lua +++ b/builtin/game/item_entity.lua @@ -152,7 +152,7 @@ core.register_entity(":__builtin:item", { return end - local vel = self.object:getvelocity() + local vel = self.object:get_velocity() local def = node and core.registered_nodes[node.name] local is_moving = (def and not def.walkable) or vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0 diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 472cb2107..e6d16dde7 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -113,7 +113,7 @@ function core.get_player_radius_area(player_name, radius) return nil end - local p1 = player:getpos() + local p1 = player:get_pos() local p2 = p1 if radius then diff --git a/builtin/game/static_spawn.lua b/builtin/game/static_spawn.lua index 2a5d9b1fa..fae23eab0 100644 --- a/builtin/game/static_spawn.lua +++ b/builtin/game/static_spawn.lua @@ -15,7 +15,7 @@ local function put_player_in_spawn(player_obj) end core.log("action", "Moving " .. player_obj:get_player_name() .. " to static spawnpoint at " .. core.pos_to_string(static_spawnpoint)) - player_obj:setpos(static_spawnpoint) + player_obj:set_pos(static_spawnpoint) return true end -- 2.25.1