aboutsummaryrefslogtreecommitdiff
path: root/advtrains/wagons.lua
diff options
context:
space:
mode:
authororwell96 <mono96.mml@gmail.com>2017-10-23 13:56:59 +0200
committerGitHub <noreply@github.com>2017-10-23 13:56:59 +0200
commit850d8ac570d6db3b02970fa57116a5fd818f19ae (patch)
treefa3c3d36326fb8d908d0ee9d7aca2b6c06e1ce91 /advtrains/wagons.lua
parent11d6a12ce7752c7640c3cb85e76814ebeb3f94ef (diff)
downloadadvtrains-850d8ac570d6db3b02970fa57116a5fd818f19ae.tar.gz
advtrains-850d8ac570d6db3b02970fa57116a5fd818f19ae.tar.bz2
advtrains-850d8ac570d6db3b02970fa57116a5fd818f19ae.zip
Fix continous object_property modification
This problem caused flickering of door animations on subways.
Diffstat (limited to 'advtrains/wagons.lua')
-rw-r--r--advtrains/wagons.lua22
1 files changed, 16 insertions, 6 deletions
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 715f501..d020734 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -131,6 +131,9 @@ function wagon:init_shared()
if self.custom_on_activate then
self:custom_on_activate(dtime_s)
end
+ -- reset line and infotext cache to update object properties on first call
+ self.line_cache=nil
+ self.infotext_cache=nil
end
function wagon:ensure_init()
if self.initialized then
@@ -285,18 +288,25 @@ function wagon:on_step(dtime)
--check infotext
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.infotext_cache=outside
end
local gp=self:train()
local fct=self.wagon_flipped and -1 or 1
--set line number
- if self.name == "advtrains:subway_wagon" and gp.line then
- self.object:set_properties({
- textures={"advtrains_subway_wagon.png^advtrains_subway_wagon_line"..gp.line..".png"},
- visual_size = text_scale,
- })
+ 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({
+ textures={new_line_tex},
+ })
+ self.line_cache=gp.line
+ elseif self.line_cache~=nil then
+ self.object:set_properties({
+ textures=self.textures,
+ })
+ self.line_cache=nil
end
--door animation
if self.doors then