Road decoration
Posted: 14 May 2018, 16:21
Since 475 there is a new type of object in the game: Road decorations.
Those are basically road alignment aware frames that can be attached on top of any road, similar to animations that are defined directly by a road.
How it may look like
This one is simple for the purpose of demonstration. I'm confident that you can come up with something that is way better.
The frame we want to use as decoration
The usage is supposed to follow this scheme
The basic structure of road decorations is to define all the needed frames as animation obejcts which can then be referenced in the road decoration object. So here they may look like
⚠Although we're talking about animation objects they aren't animated here because each animation has only one frame.
So now we have 4 animation objects that hold our frames that we want to put on top of roads. The basic road decoration structure looks like
For drawing frames 1 and 3 should be used in the foreground while frames 0 and 2 should be drawn behind cars. We can say so by using animation and animation fg respectively in the road decoration object
The last part is the most important one: We have to tell the game when to show which animation object. By default, all animations are drawn for every frame (so we don't use frame/alignment awareness yet). Normal roads have 16 frames (as defined here), so we have to tell for each frame manually which of the provided animation obejects to use. That can be done by populating the arrays frame animation indices and frame animation fg indices with 16 sub arrays. Each of these sub arrays contains a list of the corresponding animation objects that should be used (indexed by 0 and 1 as we have only two animations for animation and animation fg)
Dependent on your project your can just reuse this code and don't have to worry about the meaning.
Here you can get the whole plugin: Road decoration objects also support the basic fun attributes fun, on click fun and random fun.
Since 476: The attribute "speed" can be used to apply a speed multiplier to the underlaying road. Default value is 1.0
New attributes are
New attributes since version 1.9.96 (which allows you to enable experimental multi road decorations per road tile in the settings):
Those are basically road alignment aware frames that can be attached on top of any road, similar to animations that are defined directly by a road.
How it may look like

The frame we want to use as decoration



Code: Select all
{"id":"$anim_roaddeco_sample00_00","type":"animation","frames":[{"bmp":"frames.png","x":0,"w":32,"handle y":8}]},
{"id":"$anim_roaddeco_sample00_01","type":"animation","frames":[{"bmp":"frames.png","x":32,"w":32,"handle y":8}]},
{"id":"$anim_roaddeco_sample00_02","type":"animation","frames":[{"bmp":"frames.png","x":64,"w":32,"handle y":8}]},
{"id":"$anim_roaddeco_sample00_03","type":"animation","frames":[{"bmp":"frames.png","x":96,"w":32,"handle y":8}]}
So now we have 4 animation objects that hold our frames that we want to put on top of roads. The basic road decoration structure looks like

Code: Select all
{
"id":"$roaddeco_sample00",
"type":"road decoration",
"title":"Sample deco",
"text":"I am a road decoration.",
"price":100,
...
}

Code: Select all
"animation":[
{"id":"$anim_roaddeco_sample00_00"},
{"id":"$anim_roaddeco_sample00_02"}
],
"animation fg":[
{"id":"$anim_roaddeco_sample00_01"},
{"id":"$anim_roaddeco_sample00_03"}
]

Code: Select all
"frame animation indices":[
[0,1],[0,1],[1],[1],
[0],[0],[],[],
[0,1],[0,1],[1],[1],
[0],[0],[],[]
],
"frame animation fg indices":[
[0,1],[0],[0,1],[0],
[0,1],[0],[0,1],[0],
[1],[],[1],[],
[1],[],[1],[]
]
Here you can get the whole plugin: Road decoration objects also support the basic fun attributes fun, on click fun and random fun.
Since 476: The attribute "speed" can be used to apply a speed multiplier to the underlaying road. Default value is 1.0

New attributes are
required flag *
min dirs
max dirs
symmetric dirs
line tool
enter speed
exit speed
parcel speeds
New attributes since version 1.9.96 (which allows you to enable experimental multi road decorations per road tile in the settings):
occupation group
exclusive