Fix continous object_property modification
This problem caused flickering of door animations on subways.master
parent
11d6a12ce7
commit
850d8ac570
|
@ -131,6 +131,9 @@ function wagon:init_shared()
|
||||||
if self.custom_on_activate then
|
if self.custom_on_activate then
|
||||||
self:custom_on_activate(dtime_s)
|
self:custom_on_activate(dtime_s)
|
||||||
end
|
end
|
||||||
|
-- reset line and infotext cache to update object properties on first call
|
||||||
|
self.line_cache=nil
|
||||||
|
self.infotext_cache=nil
|
||||||
end
|
end
|
||||||
function wagon:ensure_init()
|
function wagon:ensure_init()
|
||||||
if self.initialized then
|
if self.initialized then
|
||||||
|
@ -285,18 +288,25 @@ function wagon:on_step(dtime)
|
||||||
|
|
||||||
--check infotext
|
--check infotext
|
||||||
local outside=self:train().text_outside or ""
|
local outside=self:train().text_outside or ""
|
||||||
if self.object:get_properties().infotext~=outside then
|
if self.infotext_cache~=outside then
|
||||||
self.object:set_properties({infotext=outside})
|
self.object:set_properties({infotext=outside})
|
||||||
|
self.infotext_cache=outside
|
||||||
end
|
end
|
||||||
|
|
||||||
local gp=self:train()
|
local gp=self:train()
|
||||||
local fct=self.wagon_flipped and -1 or 1
|
local fct=self.wagon_flipped and -1 or 1
|
||||||
--set line number
|
--set line number
|
||||||
if self.name == "advtrains:subway_wagon" and gp.line then
|
if self.name == "advtrains:subway_wagon" and gp.line and gp.line~=self.line_cache then
|
||||||
|
local new_line_tex="advtrains_subway_wagon.png^advtrains_subway_wagon_line"..gp.line..".png"
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
textures={"advtrains_subway_wagon.png^advtrains_subway_wagon_line"..gp.line..".png"},
|
textures={new_line_tex},
|
||||||
visual_size = text_scale,
|
|
||||||
})
|
})
|
||||||
|
self.line_cache=gp.line
|
||||||
|
elseif self.line_cache~=nil then
|
||||||
|
self.object:set_properties({
|
||||||
|
textures=self.textures,
|
||||||
|
})
|
||||||
|
self.line_cache=nil
|
||||||
end
|
end
|
||||||
--door animation
|
--door animation
|
||||||
if self.doors then
|
if self.doors then
|
||||||
|
|
Loading…
Reference in New Issue