Replace deprecated object:getxxx()/setxxx() by get_xxx()/set_xxx()

master
orwell96 2021-01-14 11:19:15 +01:00
parent 1b8a3dfaf2
commit 556e0782f7
3 changed files with 19 additions and 19 deletions

View File

@ -47,7 +47,7 @@ minetest.register_entity("advtrains:discouple", {
return
end
--getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not.
if not self.wagon.object:getyaw() then
if not self.wagon.object:get_yaw() then
self.object:remove()
return
end
@ -145,7 +145,7 @@ minetest.register_entity("advtrains:couple", {
end
local pos_median=advtrains.pos_median(tp1, tp2)
if not vector.equals(pos_median, self.object:getpos()) then
self.object:setpos(pos_median)
self.object:set_pos(pos_median)
end
self.position_set=true
end

View File

@ -72,7 +72,7 @@ advtrains.mainloop_trainlogic=function(dtime, stepno)
for _, player in pairs(minetest.get_connected_players()) do
if not advtrains.player_to_train_mapping[player:get_player_name()] then
--players in train are not subject to damage
local ptspos=minetest.pos_to_string(vector.round(player:getpos()))
local ptspos=minetest.pos_to_string(vector.round(player:get_pos()))
advtrains.playersbypts[ptspos]=player
end
end
@ -131,7 +131,7 @@ function advtrains.tp_player_to_train(player)
--set the player to the train position.
--minetest will emerge the area and load the objects, which then will call reattach_all().
--because player is in mapping, it will not be subject to dying.
player:setpos(train.last_pos)
player:set_pos(train.last_pos)
end
end
minetest.register_on_joinplayer(function(player)
@ -976,7 +976,7 @@ function advtrains.spawn_wagons(train_id)
atwarn("Train",train_id,"Wagon #",i,": Saved train ID",data.train_id,"did not match!")
data.train_id = train_id
end
if not advtrains.wagon_objects[w_id] or not advtrains.wagon_objects[w_id]:getyaw() then
if not advtrains.wagon_objects[w_id] or not advtrains.wagon_objects[w_id]:get_yaw() then
-- eventually need to spawn new object. check if position is loaded.
local index = advtrains.path_get_index_by_offset(train, train.index, -data.pos_in_train)
local pos = advtrains.path_get(train, atfloor(index))
@ -1128,7 +1128,7 @@ end
function advtrains.train_check_couples(train)
--atdebug("rechecking couples")
if train.cpl_front then
if not train.cpl_front:getyaw() then
if not train.cpl_front:get_yaw() then
-- objectref is no longer valid. reset.
train.cpl_front = nil
end
@ -1158,7 +1158,7 @@ function advtrains.train_check_couples(train)
end
end
if train.cpl_back then
if not train.cpl_back:getyaw() then
if not train.cpl_back:get_yaw() then
-- objectref is no longer valid. reset.
train.cpl_back = nil
end

View File

@ -156,7 +156,7 @@ function wagon:ensure_init()
atwarn("wagon",self.id,"uninitialized, removing")
self:destroy()
else
self.object:setvelocity({x=0,y=0,z=0})
self.object:set_velocity({x=0,y=0,z=0})
end
return false
end
@ -276,7 +276,7 @@ function wagon:on_step(dtime)
end
local t=os.clock()
local pos = self.object:getpos()
local pos = self.object:get_pos()
local data = advtrains.wagons[self.id]
if not pos then
@ -404,8 +404,8 @@ function wagon:on_step(dtime)
--for path to be available. if not, skip step
if not train.path or train.no_step then
self.object:setvelocity({x=0, y=0, z=0})
self.object:setacceleration({x=0, y=0, z=0})
self.object:set_velocity({x=0, y=0, z=0})
self.object:set_acceleration({x=0, y=0, z=0})
return
end
if not data.pos_in_train then
@ -474,7 +474,7 @@ function wagon:on_step(dtime)
-- FIX: Need to do this after the yaw calculation
if is_in_loaded_area and data.pos_in_trainparts and data.pos_in_trainparts>1 then
if train.velocity==0 then
if not self.discouple or not self.discouple.object:getyaw() then
if not self.discouple or not self.discouple.object:get_yaw() then
atprint(self.id,"trying to spawn discouple")
local dcpl_pos = vector.add(pos, {y=0, x=-math.sin(yaw)*self.wagon_span, z=math.cos(yaw)*self.wagon_span})
local object=minetest.add_entity(dcpl_pos, "advtrains:discouple")
@ -487,7 +487,7 @@ function wagon:on_step(dtime)
end
end
else
if self.discouple and self.discouple.object:getyaw() then
if self.discouple and self.discouple.object:get_yaw() then
self.discouple.object:remove()
atprint(self.id," removing discouple")
end
@ -543,9 +543,9 @@ function wagon:on_step(dtime)
or self.old_yaw~=yaw
or updatepct_timer_elapsed then--only send update packet if something changed
self.object:setpos(pos)
self.object:setvelocity(velocityvec)
self.object:setacceleration(accelerationvec)
self.object:set_pos(pos)
self.object:set_velocity(velocityvec)
self.object:set_acceleration(accelerationvec)
if #self.seats > 0 and self.old_yaw ~= yaw then
if not self.player_yaw then
@ -578,7 +578,7 @@ function wagon:on_step(dtime)
end
self.object:set_rotation({x=pitch, y=yaw, z=0})
else
self.object:setyaw(yaw)
self.object:set_yaw(yaw)
end
if self.update_animation then
@ -771,7 +771,7 @@ function wagon:get_off(seatno)
--atdebug("platpos:", platpos, "offpos:", offpos)
if minetest.get_item_group(minetest.get_node(platpos).name, "platform")>0 then
minetest.after(GETOFF_TP_DELAY, function() clicker:setpos(offpos) end)
minetest.after(GETOFF_TP_DELAY, function() clicker:set_pos(offpos) end)
--atdebug("tp",offpos)
return
end
@ -791,7 +791,7 @@ function wagon:get_off(seatno)
offp=vector.add({x=isx and r*2 or 0, y=1, z=not isx and r*2 or 0}, objpos)
--atdebug("platpos:", p, "offpos:", offp)
if minetest.get_item_group(minetest.get_node(p).name, "platform")>0 then
minetest.after(GETOFF_TP_DELAY, function() clicker:setpos(offp) end)
minetest.after(GETOFF_TP_DELAY, function() clicker:set_pos(offp) end)
--atdebug("tp",offp)
return
end