Lars Mueller: 1 Fix texture modifiers relying on undocumented behavior 1 files changed, 28 insertions(+), 28 deletions(-)
Copy & paste the following snippet into your terminal to import this patchset into git:
curl -s https://lists.sr.ht/~gpcf/advtrains-devel/patches/41557/mbox | git am -3Learn more about email & git
--- advtrains/trainhud.lua | 56 +++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua index 22aa6cf..6680287 100644 --- a/advtrains/trainhud.lua +++ b/advtrains/trainhud.lua @@ -190,7 +190,7 @@ function advtrains.hud_train_format(train, flip) tlev=1 end - local ht = {"[combine:440x110:0,0=(advtrains_hud_bg.png^[resize\\:440x110)"} + local ht = {"[combine:440x110:0,0=advtrains_hud_bg.png\\^[resize\\:440x110"} local st = {} if train.debug then st = {train.debug} end @@ -227,54 +227,54 @@ function advtrains.hud_train_format(train, flip) for i = 1, 7, 1 do if ent[i] then local s = segs[i] - ht[#ht+1] = sformat("%d,%d=(advtrains_hud_bg.png^[resize\\:%dx%d^%s)",x+s[1], y+s[2], s[3], s[4], m) + ht[#ht+1] = sformat("%d,%d=advtrains_hud_bg.png\\^[resize\\:%dx%d\\^%s",x+s[1], y+s[2], s[3], s[4], m) end end end -- lever - ht[#ht+1] = "275,10=(advtrains_hud_bg.png^[colorize\\:cyan^[resize\\:5x18)" - ht[#ht+1] = "275,28=(advtrains_hud_bg.png^[colorize\\:white^[resize\\:5x18)" - ht[#ht+1] = "275,46=(advtrains_hud_bg.png^[colorize\\:orange^[resize\\:5x36)" - ht[#ht+1] = "275,82=(advtrains_hud_bg.png^[colorize\\:red^[resize\\:5x18)" - ht[#ht+1] = "292,16=(advtrains_hud_bg.png^[colorize\\:darkslategray^[resize\\:6x78)" - ht[#ht+1] = sformat("280,%s=(advtrains_hud_bg.png^[colorize\\:gray^[resize\\:30x18)",18*(4-tlev)+10) + ht[#ht+1] = "275,10=advtrains_hud_bg.png\\^[colorize\\:cyan\\^[resize\\:5x18" + ht[#ht+1] = "275,28=advtrains_hud_bg.png\\^[colorize\\:white\\^[resize\\:5x18" + ht[#ht+1] = "275,46=advtrains_hud_bg.png\\^[colorize\\:orange\\^[resize\\:5x36" + ht[#ht+1] = "275,82=advtrains_hud_bg.png\\^[colorize\\:red\\^[resize\\:5x18" + ht[#ht+1] = "292,16=advtrains_hud_bg.png\\^[colorize\\:darkslategray\\^[resize\\:6x78" + ht[#ht+1] = sformat("280,%s=advtrains_hud_bg.png\\^[colorize\\:gray\\^[resize\\:30x18",18*(4-tlev)+10) -- reverser - ht[#ht+1] = sformat("245,10=(advtrains_hud_arrow.png^[transformFY%s)", flip and "" or "^[multiply\\:cyan") - ht[#ht+1] = sformat("245,85=(advtrains_hud_arrow.png%s)", flip and "^[multiply\\:orange" or "") - ht[#ht+1] = "250,35=(advtrains_hud_bg.png^[colorize\\:darkslategray^[resize\\:5x40)" - ht[#ht+1] = sformat("240,%s=(advtrains_hud_bg.png^[resize\\:25x15^[colorize\\:gray)", flip and 65 or 30) + ht[#ht+1] = sformat("245,10=advtrains_hud_arrow.png\\^[transformFY%s", flip and "" or "\\^[multiply\\:cyan") + ht[#ht+1] = sformat("245,85=advtrains_hud_arrow.png%s", flip and "\\^[multiply\\:orange" or "") + ht[#ht+1] = "250,35=advtrains_hud_bg.png\\^[colorize\\:darkslategray\\^[resize\\:5x40)" + ht[#ht+1] = sformat("240,%s=advtrains_hud_bg.png\\^[resize\\:25x15\\^[colorize\\:gray)", flip and 65 or 30) -- train control/safety indication if train.tarvelocity or train.atc_command then - ht[#ht+1] = "10,10=(advtrains_hud_atc.png^[resize\\:30x30^[multiply\\:cyan)" + ht[#ht+1] = "10,10=advtrains_hud_atc.png\\^[resize\\:30x30\\^[multiply\\:cyan" end if train.hud_lzb_effect_tmr then - ht[#ht+1] = "50,10=(advtrains_hud_lzb.png^[resize\\:30x30^[multiply\\:red)" + ht[#ht+1] = "50,10=advtrains_hud_lzb.png\\^[resize\\:30x30\\^[multiply\\:red" end if train.is_shunt then - ht[#ht+1] = "90,10=(advtrains_hud_shunt.png^[resize\\:30x30^[multiply\\:orange)" + ht[#ht+1] = "90,10=advtrains_hud_shunt.png\\^[resize\\:30x30\\^[multiply\\:orange" end -- door - ht[#ht+1] = "187,10=(advtrains_hud_bg.png^[resize\\:26x30^[colorize\\:white)" - ht[#ht+1] = "189,12=(advtrains_hud_bg.png^[resize\\:22x11)" - ht[#ht+1] = sformat("170,10=(advtrains_hud_bg.png^[resize\\:15x30^[colorize\\:%s)", train.door_open==-1 and "white" or "darkslategray") - ht[#ht+1] = "172,12=(advtrains_hud_bg.png^[resize\\:11x11)" - ht[#ht+1] = sformat("215,10=(advtrains_hud_bg.png^[resize\\:15x30^[colorize\\:%s)", train.door_open==1 and "white" or "darkslategray") - ht[#ht+1] = "217,12=(advtrains_hud_bg.png^[resize\\:11x11)" + ht[#ht+1] = "187,10=advtrains_hud_bg.png\\^[resize\\:26x30\\^[colorize\\:white" + ht[#ht+1] = "189,12=advtrains_hud_bg.png\\^[resize\\:22x11" + ht[#ht+1] = sformat("170,10=advtrains_hud_bg.png\\^[resize\\:15x30\\^[colorize\\:%s", train.door_open==-1 and "white" or "darkslategray") + ht[#ht+1] = "172,12=advtrains_hud_bg.png\\^[resize\\:11x11" + ht[#ht+1] = sformat("215,10=advtrains_hud_bg.png\\^[resize\\:15x30\\^[colorize\\:%s", train.door_open==1 and "white" or "darkslategray") + ht[#ht+1] = "217,12=advtrains_hud_bg.png\\^[resize\\:11x11" -- speed indication(s) sevenseg(math.floor(vel/10), 320, 10, 30, 10, "[colorize\\:red\\:255") sevenseg(vel%10, 380, 10, 30, 10, "[colorize\\:red\\:255") for i = 1, vel, 1 do - ht[#ht+1] = sformat("%d,65=(advtrains_hud_bg.png^[resize\\:8x20^[colorize\\:white)", i*11-1) + ht[#ht+1] = sformat("%d,65=advtrains_hud_bg.png\\^[resize\\:8x20\\^[colorize\\:white", i*11-1) end for i = max+1, 20, 1 do - ht[#ht+1] = sformat("%d,65=(advtrains_hud_bg.png^[resize\\:8x20^[colorize\\:darkslategray)", i*11-1) + ht[#ht+1] = sformat("%d,65=advtrains_hud_bg.png\\^[resize\\:8x20\\^[colorize\\:darkslategray", i*11-1) end if res and res > 0 then - ht[#ht+1] = sformat("%d,60=(advtrains_hud_bg.png^[resize\\:3x30^[colorize\\:red\\:255)", 7+res*11) + ht[#ht+1] = sformat("%d,60=advtrains_hud_bg.png\\^[resize\\:3x30\\^[colorize\\:red\\:255", 7+res*11) end if train.tarvelocity then - ht[#ht+1] = sformat("%d,85=(advtrains_hud_arrow.png^[multiply\\:cyan^[transformFY^[makealpha\\:#000000)", 1+train.tarvelocity*11) + ht[#ht+1] = sformat("%d,85=advtrains_hud_arrow.png\\^[multiply\\:cyan\\^[transformFY\\^[makealpha\\:#000000", 1+train.tarvelocity*11) end local lzb = train.lzb if lzb and lzb.checkpoints then @@ -285,10 +285,10 @@ function advtrains.hud_train_format(train, flip) if spd == -1 then spd = nil end local c = not spd and "lime" or (type(spd) == "number" and (spd == 0) and "red" or "orange") or nil if c then - ht[#ht+1] = sformat("130,10=(advtrains_hud_bg.png^[resize\\:30x5^[colorize\\:%s)",c) - ht[#ht+1] = sformat("130,35=(advtrains_hud_bg.png^[resize\\:30x5^[colorize\\:%s)",c) + ht[#ht+1] = sformat("130,10=advtrains_hud_bg.png\\^[resize\\:30x5\\^[colorize\\:%s",c) + ht[#ht+1] = sformat("130,35=advtrains_hud_bg.png\\^[resize\\:30x5\\^[colorize\\:%s",c) if spd and spd~=0 then - ht[#ht+1] = sformat("%d,50=(advtrains_hud_arrow.png^[multiply\\:red^[makealpha\\:#000000)", 1+spd*11) + ht[#ht+1] = sformat("%d,50=advtrains_hud_arrow.png\\^[multiply\\:red\\^[makealpha\\:#000000", 1+spd*11) end local floor = math.floor local dist = floor(((oc[i].index or train.index)-train.index)) -- 2.34.1
I would like a bit of clarification here, as I do not see how the use of (x^y) is undocumented ("texture grouping"); the documentation for the [combine modifier also does not state that () can not be used in the texture string(s) to combine. That said, the changes do make the texture strings look cleaner. Regardless of the texture strings, I have to admit that the code was put together in a relatively short amount of time, so I (or someone else) would need to rework the code anyway.