Fix depercated functions

This commit is contained in:
1F616EMO 2024-09-29 06:37:40 +08:00 committed by orwell
parent b075d8e333
commit e536709041
3 changed files with 15 additions and 13 deletions

View File

@ -453,7 +453,7 @@ minetest.register_entity("advtrains:discouple", {
self.object:remove() self.object:remove()
return return
end end
--getyaw seems to be a reliable method to check if an object is loaded...if it returns nil, it is not. --get_yaw 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:get_yaw() then if not self.wagon.object:get_yaw() then
self.object:remove() self.object:remove()
return return
@ -500,7 +500,7 @@ minetest.register_entity("advtrains:couple", {
self.object:remove() self.object:remove()
end, end,
on_step=function(self, dtime) on_step=function(self, dtime)
if advtrains.wagon_outside_range(self.object:getpos()) then if advtrains.wagon_outside_range(self.object:get_pos()) then
--atdebug("Couple Removing outside range") --atdebug("Couple Removing outside range")
self.object:remove() self.object:remove()
return return
@ -539,7 +539,7 @@ minetest.register_entity("advtrains:couple", {
tp2=advtrains.path_get_interpolated(train2, train2.end_index) tp2=advtrains.path_get_interpolated(train2, train2.end_index)
end end
local pos_median=advtrains.pos_median(tp1, tp2) local pos_median=advtrains.pos_median(tp1, tp2)
if not vector.equals(pos_median, self.object:getpos()) then if not vector.equals(pos_median, self.object:get_pos()) then
self.object:set_pos(pos_median) self.object:set_pos(pos_median)
end end
self.position_set=true self.position_set=true

View File

@ -10,6 +10,8 @@ advtrains.hud[player:get_player_name()] = nil
advtrains.hhud[player:get_player_name()] = nil advtrains.hhud[player:get_player_name()] = nil
end) end)
local hud_type_key = minetest.features.hud_def_type_field and "type" or "hud_elem_type"
local mletter={[1]="F", [-1]="R", [0]="N"} local mletter={[1]="F", [-1]="R", [0]="N"}
function advtrains.on_control_change(pc, train, flip) function advtrains.on_control_change(pc, train, flip)
@ -105,7 +107,7 @@ function advtrains.set_trainhud(name, text, driver)
end end
local drivertext = driver or "" local drivertext = driver or ""
local driverhud = { local driverhud = {
hud_elem_type = "image", [hud_type_key] = "image",
name = "ADVTRAINS_DRIVER", name = "ADVTRAINS_DRIVER",
position = {x=0.5, y=1}, position = {x=0.5, y=1},
offset = {x=0,y=-170}, offset = {x=0,y=-170},
@ -116,8 +118,8 @@ function advtrains.set_trainhud(name, text, driver)
if not hud then if not hud then
hud = {} hud = {}
advtrains.hud[name] = hud advtrains.hud[name] = hud
hud.id = player:hud_add { hud.id = player:hud_add({
hud_elem_type = "text", [hud_type_key] = "text",
name = "ADVTRAINS", name = "ADVTRAINS",
number = 0xFFFFFF, number = 0xFFFFFF,
position = {x=0.5, y=1}, position = {x=0.5, y=1},
@ -125,7 +127,7 @@ function advtrains.set_trainhud(name, text, driver)
text = text, text = text,
scale = {x=200, y=60}, scale = {x=200, y=60},
alignment = {x=0, y=-1}, alignment = {x=0, y=-1},
} })
hud.driver = player:hud_add(driverhud) hud.driver = player:hud_add(driverhud)
hud.oldText = text hud.oldText = text
hud.oldDriver = drivertext hud.oldDriver = drivertext
@ -156,7 +158,7 @@ function advtrains.set_help_hud(name, text)
hud = {} hud = {}
advtrains.hhud[name] = hud advtrains.hhud[name] = hud
hud.id = player:hud_add({ hud.id = player:hud_add({
hud_elem_type = "text", [hud_type_key] = "text",
name = "ADVTRAINS_HELP", name = "ADVTRAINS_HELP",
number = 0xFFFFFF, number = 0xFFFFFF,
position = {x=1, y=0.3}, position = {x=1, y=0.3},

View File

@ -286,7 +286,7 @@ function wagon:on_step(dtime)
local data = advtrains.wagons[self.id] local data = advtrains.wagons[self.id]
if not pos then if not pos then
--atdebug("["..self.id.."][fatal] missing position (object:getpos() returned nil)") --atdebug("["..self.id.."][fatal] missing position (object:get_pos() returned nil)")
return return
end end
@ -820,8 +820,8 @@ function wagon:get_off(seatno)
end end
--if not door_entry, or paths missing, fall back to old method --if not door_entry, or paths missing, fall back to old method
--atdebug("using fallback") --atdebug("using fallback")
local objpos=advtrains.round_vector_floor_y(self.object:getpos()) local objpos=advtrains.round_vector_floor_y(self.object:get_pos())
local yaw=self.object:getyaw() local yaw=self.object:get_yaw()
local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4) local isx=(yaw < math.pi/4) or (yaw > 3*math.pi/4 and yaw < 5*math.pi/4) or (yaw > 7*math.pi/4)
local offp local offp
--abuse helper function --abuse helper function
@ -899,7 +899,7 @@ end
--BordCom --BordCom
local function checkcouple(ent) local function checkcouple(ent)
if not ent or not ent:getyaw() then if not ent or not ent:get_yaw() then
return nil return nil
end end
local le = ent:get_luaentity() local le = ent:get_luaentity()
@ -1273,7 +1273,7 @@ function wagon:check_seat_group_access(pname, sgr)
return false, attrans("You are not allowed to access the driver stand.") return false, attrans("You are not allowed to access the driver stand.")
end end
if self.seat_groups[sgr].driving_ctrl_access then if self.seat_groups[sgr].driving_ctrl_access then
advtrains.log("Drive", pname, self.object:getpos(), self:train().text_outside) advtrains.log("Drive", pname, self.object:get_pos(), self:train().text_outside)
end end
return true return true
end end