Skip to content

Commit ade7a1c

Browse files
authoredJul 17, 2018
Builtin: Replace deprecated function calls (#7561)
1 parent a0635f6 commit ade7a1c

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed
 

Diff for: ‎builtin/game/chatcommands.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ core.register_chatcommand("teleport", {
380380
end
381381
teleportee = core.get_player_by_name(name)
382382
if teleportee then
383-
teleportee:setpos(p)
383+
teleportee:set_pos(p)
384384
return true, "Teleporting to "..core.pos_to_string(p)
385385
end
386386
end
@@ -393,12 +393,12 @@ core.register_chatcommand("teleport", {
393393
if target_name then
394394
local target = core.get_player_by_name(target_name)
395395
if target then
396-
p = target:getpos()
396+
p = target:get_pos()
397397
end
398398
end
399399
if teleportee and p then
400400
p = find_free_position_near(p)
401-
teleportee:setpos(p)
401+
teleportee:set_pos(p)
402402
return true, "Teleporting to " .. target_name
403403
.. " at "..core.pos_to_string(p)
404404
end
@@ -417,7 +417,7 @@ core.register_chatcommand("teleport", {
417417
teleportee = core.get_player_by_name(teleportee_name)
418418
end
419419
if teleportee and p.x and p.y and p.z then
420-
teleportee:setpos(p)
420+
teleportee:set_pos(p)
421421
return true, "Teleporting " .. teleportee_name
422422
.. " to " .. core.pos_to_string(p)
423423
end
@@ -433,12 +433,12 @@ core.register_chatcommand("teleport", {
433433
if target_name then
434434
local target = core.get_player_by_name(target_name)
435435
if target then
436-
p = target:getpos()
436+
p = target:get_pos()
437437
end
438438
end
439439
if teleportee and p then
440440
p = find_free_position_near(p)
441-
teleportee:setpos(p)
441+
teleportee:set_pos(p)
442442
return true, "Teleporting " .. teleportee_name
443443
.. " to " .. target_name
444444
.. " at " .. core.pos_to_string(p)
@@ -664,7 +664,7 @@ core.register_chatcommand("spawnentity", {
664664
return false, "Cannot spawn an unknown entity"
665665
end
666666
if p == "" then
667-
p = player:getpos()
667+
p = player:get_pos()
668668
else
669669
p = core.string_to_pos(p)
670670
if p == nil then

Diff for: ‎builtin/game/falling.lua

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ core.register_entity(":__builtin:falling_node", {
5252

5353
on_step = function(self, dtime)
5454
-- Set gravity
55-
local acceleration = self.object:getacceleration()
55+
local acceleration = self.object:get_acceleration()
5656
if not vector.equals(acceleration, {x = 0, y = -10, z = 0}) then
57-
self.object:setacceleration({x = 0, y = -10, z = 0})
57+
self.object:set_acceleration({x = 0, y = -10, z = 0})
5858
end
5959
-- Turn to actual node when colliding with ground, or continue to move
60-
local pos = self.object:getpos()
60+
local pos = self.object:get_pos()
6161
-- Position of bottom center point
6262
local bcp = {x = pos.x, y = pos.y - 0.7, z = pos.z}
6363
-- 'bcn' is nil for unloaded nodes
@@ -124,10 +124,10 @@ core.register_entity(":__builtin:falling_node", {
124124
core.check_for_falling(np)
125125
return
126126
end
127-
local vel = self.object:getvelocity()
127+
local vel = self.object:get_velocity()
128128
if vector.equals(vel, {x = 0, y = 0, z = 0}) then
129-
local npos = self.object:getpos()
130-
self.object:setpos(vector.round(npos))
129+
local npos = self.object:get_pos()
130+
self.object:set_pos(vector.round(npos))
131131
end
132132
end
133133
})

Diff for: ‎builtin/game/item.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function core.get_pointed_thing_position(pointed_thing, above)
3333
-- The position where a node would be dug
3434
return pointed_thing.under
3535
elseif pointed_thing.type == "object" then
36-
return pointed_thing.ref and pointed_thing.ref:getpos()
36+
return pointed_thing.ref and pointed_thing.ref:get_pos()
3737
end
3838
end
3939

@@ -331,7 +331,7 @@ function core.item_place_node(itemstack, placer, pointed_thing, param2,
331331
-- Calculate the direction for furnaces and chests and stuff
332332
elseif (def.paramtype2 == "facedir" or
333333
def.paramtype2 == "colorfacedir") and not param2 then
334-
local placer_pos = placer and placer:getpos()
334+
local placer_pos = placer and placer:get_pos()
335335
if placer_pos then
336336
local dir = {
337337
x = above.x - placer_pos.x,
@@ -478,7 +478,7 @@ function core.do_item_eat(hp_change, replace_with_item, itemstack, user, pointed
478478
if inv and inv:room_for_item("main", {name=replace_with_item}) then
479479
inv:add_item("main", replace_with_item)
480480
else
481-
local pos = user:getpos()
481+
local pos = user:get_pos()
482482
pos.y = math.floor(pos.y + 0.5)
483483
core.add_item(pos, replace_with_item)
484484
end

Diff for: ‎builtin/game/item_entity.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ core.register_entity(":__builtin:item", {
152152
return
153153
end
154154

155-
local vel = self.object:getvelocity()
155+
local vel = self.object:get_velocity()
156156
local def = node and core.registered_nodes[node.name]
157157
local is_moving = (def and not def.walkable) or
158158
vel.x ~= 0 or vel.y ~= 0 or vel.z ~= 0

Diff for: ‎builtin/game/misc.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function core.get_player_radius_area(player_name, radius)
113113
return nil
114114
end
115115

116-
local p1 = player:getpos()
116+
local p1 = player:get_pos()
117117
local p2 = p1
118118

119119
if radius then

Diff for: ‎builtin/game/static_spawn.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local function put_player_in_spawn(player_obj)
1515
end
1616
core.log("action", "Moving " .. player_obj:get_player_name() ..
1717
" to static spawnpoint at " .. core.pos_to_string(static_spawnpoint))
18-
player_obj:setpos(static_spawnpoint)
18+
player_obj:set_pos(static_spawnpoint)
1919
return true
2020
end
2121

0 commit comments

Comments
 (0)
Please sign in to comment.