Road decoration

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Reactions:
Posts: 3679
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Road decoration

#1

Post by Lobby »

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 :img
Screenshot_20180514-154312.png
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 :img
frames.png
frames.png (535 Bytes) Viewed 12275 times
The usage is supposed to follow this scheme :teach
frames_usage.png
frames_usage.png (3.94 KiB) Viewed 12275 times
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 :json

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}]}
⚠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 :json

Code: Select all

{
  "id":"$roaddeco_sample00",
  "type":"road decoration",
  "title":"Sample deco",
  "text":"I am a road decoration.",
  "price":100,
  ...
}
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 :json

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"}
]
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) :json

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],[]
]
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:
roaddeco_sample.zip
(58.31 KiB) Downloaded 423 times
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

:66:
New attributes are
Show
required flag *
You can now use road flags to specify on which roads the decoration should be buildable. The default is

Code: Select all

"required flag normal":true
which means that it can only be built on regular roads.

E.g. use

Code: Select all

"required flag normal":false,
"required flag train":true
to define a decoration that can only be placed on rails.
See this thread for more information about flags.
Show
min dirs
This is basically a filter to limit where the decoration can be built. It states the minimum required amount of connected neighboring roads that's required for the decoration to be built.
For example:

Code: Select all

"min dirs":1
would mean that the decoration cannot be built on roads that aren't connected to any other roads. The default value is 0 meaning that no lower limit is given.
Show
max dirs
Works like min dir but specifies an upper limit of to how many neighboring roads the targeted road has to be connected.
Example:

Code: Select all

"max dirs":2
would mean that the decoration cannot be built on roads with 3 or 4 neighbors. This effectively excludes all kinds of crossings (T crossings have 3 neighbors, X crossings have 4). The default value is 4 meaning that no upper limit is given.
Show
symmetric dirs
This is another filter for road decoration placement. If set to true the road has to be connected to neighboring roads in a symmetric way. This is only the case for not connected roads, a line of road and X crossings.
For example:

Code: Select all

"min dirs":2,
"max dirs":2,
"symmetric dirs":true
only allows the road decoration to be built on a line of road without crossings (using the "min dirs" and "max dirs" attributes to filter out other symmetric cases).
Show
line tool
By default road decorations are built per road tile, now. However, you can enable the line tool by using

Code: Select all

"line tool":true
Show
enter speed
A float value multiplied to the speed of incoming cars. Default value is 1.0
Show
exit speed
A float value multiplied to the speed of outgoing cars. Default value is 1.0
Show
parcel speeds
Similar to the speed attribute, but works on a per tile basis and per parcel basis. Because of that you provde an array of float numbers that will be used as multiplier. If an insufficient number of factors was supplied then numbers will be reused. For example by only defining for factors you could control the speeds for the parcels of all tiles simoultaneously. In regard to ordering the first fource entries will be used for the four parcels of the first tile and so on. So the following are common amounts of entries for the array:
  • 4 - To set the speeds for the four parcels to the same values for all tiles of the road
  • 64 - To set the parcel speeds of all parcels of all tiles individually
  • 256 - Only needed in case you want to set the speeds of all parcels and all tiles of a one way road individually per one way direction
The ordering of four parcels is as following:
  • 0 - left
  • 1 - bottom
  • 2 - top
  • 3 - right
Example:

Code: Select all

"parcel speeds":[1,2,2,1]


New attributes since version 1.9.96 (which allows you to enable experimental multi road decorations per road tile in the settings):
Show
occupation group
If support for multiple road decorations per road tile is enabled:
Specifying a an occupation group will prevent other road decorations of the same group to be present on a road tile at the same time. This can be useful to ensure that only one variant of a group of decorations can be placed at once. E.g. if you have some variants of bush road decorations and only want that one of them can be placed on a road at the same time.

The id provided to this attribute is not connected to any existing, prior id definitions. The default value is the id of the road decoration draft (so a single decoration can only be placed once on a road tile).

Usage:

Code: Select all

"occupation group":"$somegroupid"
Show
exclusive
If support for multiple road decorations per road tile is enabled:
This flag will prevent other road decorations from existing at the same road tile at the same time. It therefore basically disables the new functionality which can be useful if the road decoration is not compatible with it.

Usage:

Code: Select all

"exclusive":true
=^._.^= ∫

User avatar
Artem_123
Townsman
Reactions:
Posts: 63
Joined: 22 Apr 2018, 15:51
Plugins: Showcase Store
Version: Beta

Platform

Re: Road decoration

#2

Post by Artem_123 »

(((:
Aga ugu my site created today https://theoplugins.simdif.com me russian phone!!!!!! :bd

User avatar
CommanderABab
AB
Reactions:
Posts: 10597
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Platform

Plugin Creator

Re: Road decoration

#3

Post by CommanderABab »

:)

User avatar
khadafi laidi
Inhabitant of a Planet
Reactions:
Posts: 1313
Joined: 16 Dec 2016, 13:11
Location: Ternate, Indonesia
Plugins: Showcase Store
Version: Beta

Platform

Re: Road decoration

#4

Post by khadafi laidi »

Lots of mathematical formulas
If you read this, thats mean i'm already quit from this forum. I had bad life right now so pls get off from here

yusuf8a684
Reactions:

Re: Road decoration

#5

Post by yusuf8a684 »

Woah thats beatufull but hard

User avatar
-LeoLeo-
Inhabitant of a Solar System
Reactions:
Posts: 1624
Joined: 08 Jul 2017, 12:46
Location: Planet Fastoon, Polaris Galaxy // Th
Plugins: Showcase Store
Version: Beta
Contact:

Platform

Plugin Creator

Re: Road decoration

#6

Post by -LeoLeo- »

Excuse me, but how do you make animation fg go under vehicles???

Like the crosswalks and the bumps??
• The KING of procrastination! •

¤ The P.M. of Attobaxia.
¤ The CEO of Leopolis Corp.
¤ Love Ratchet&Clank

;) :space

User avatar
CommanderABab
AB
Reactions:
Posts: 10597
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Platform

Plugin Creator

Re: Road decoration

#7

Post by CommanderABab »

-LeoLeo- wrote:
30 May 2018, 10:54
Excuse me, but how do you make animation fg go under vehicles???

Like the crosswalks and the bumps??
You don't use it. :)

You would use

Code: Select all

"animation indices" 
for that.

User avatar
-LeoLeo-
Inhabitant of a Solar System
Reactions:
Posts: 1624
Joined: 08 Jul 2017, 12:46
Location: Planet Fastoon, Polaris Galaxy // Th
Plugins: Showcase Store
Version: Beta
Contact:

Platform

Plugin Creator

Re: Road decoration

#8

Post by -LeoLeo- »

former member wrote:
06 Jun 2018, 08:03
OK, if it's not supported, is there a possibility to add it into a game? @Lobby
He's probably busy...(?)
Last edited by -LeoLeo- on 07 Jun 2018, 06:30, edited 1 time in total.
• The KING of procrastination! •

¤ The P.M. of Attobaxia.
¤ The CEO of Leopolis Corp.
¤ Love Ratchet&Clank

;) :space

User avatar
CommanderABab
AB
Reactions:
Posts: 10597
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Platform

Plugin Creator

Re: Road decoration

#9

Post by CommanderABab »

Using the fun from the road decoration, you could build a different road that would allow the busses in the same spot.

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5439
Joined: 10 Feb 2017, 14:53
Plugins: Showcase Store
Version: Beta

Platform

Plugin Creator

Re: Road decoration

#10

Post by Bearbear76 »

Just if you wanted to know the difference between animation & animation fg.
In animation the cars will overlay the frame. Simply think that it will be behind the cars like a background.
On the other hand animation fg is the opposite of animation, it will be in front of the car.
So the frame will overlay the cars.


Correct me if I'm wrong with any of this information. :json
Just my opinion
I'm probably recompiling my kernel... :o

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2192
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Platform

Plugin Creator

Re: Road decoration

#11

Post by KINGTUT10101 »

Would it be possible to spawn vehicles using these decorations?

yusuf8a684
Reactions:

Re: Road decoration

#12

Post by yusuf8a684 »

KINGTUT10101 wrote:
09 Jun 2018, 19:46
Would it be possible to spawn vehicles using these decorations?
I hope.it is possible

User avatar
Pounkiller
Inhabitant of a Megalopolis
Reactions:
Posts: 600
Joined: 15 Jan 2018, 15:53
Location: Turkey
Plugins: Showcase Store

Platform

Re: Road decoration

#13

Post by Pounkiller »

Mann,these are so complicated.
¡Probably not actively sustaining following the forum nor its alternative side-platforms!
≈Out of Place, Out of Time≈

User avatar
CommanderABab
AB
Reactions:
Posts: 10597
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Platform

Plugin Creator

Re: Road decoration

#14

Post by CommanderABab »

KINGTUT10101 wrote:
09 Jun 2018, 19:46
Would it be possible to spawn vehicles using these decorations?
No, or not yet. You choose. It doesn't really make sense for a road to spawn vehicles.

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 2192
Joined: 07 Jul 2016, 22:50
Location: 'Merica
Plugins: Showcase Store
Version: Beta
Contact:

Platform

Plugin Creator

Re: Road decoration

#15

Post by KINGTUT10101 »

There's a lot of things in this game that don't make sense...

User avatar
-LeoLeo-
Inhabitant of a Solar System
Reactions:
Posts: 1624
Joined: 08 Jul 2017, 12:46
Location: Planet Fastoon, Polaris Galaxy // Th
Plugins: Showcase Store
Version: Beta
Contact:

Platform

Plugin Creator

Re: Road decoration

#16

Post by -LeoLeo- »

Excuse me, @Lobby.
I know tagging is very annoying, sorry.

The new updates added the "Traffic lights crossing" and they actually stop cars!

I mean.... How did you code that????
Can i have some documentation on that?

Also, the ability to place decorations on a 4-way intersections (crosswalks) and the texture changed completely, is beyond me... Can you also tell me about that?
• The KING of procrastination! •

¤ The P.M. of Attobaxia.
¤ The CEO of Leopolis Corp.
¤ Love Ratchet&Clank

;) :space

User avatar
Lobby
Developer
Reactions:
Posts: 3679
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Road decoration

#17

Post by Lobby »

Maybe the code can help you :json

Code: Select all

  {"id":"$anim_roaddeco_trafficlights00_00","type":"animation","frames":[{"x":0,"y":469,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {"id":"$anim_roaddeco_trafficlights00_01","type":"animation","frames":[{"x":32,"y":469,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {"id":"$anim_roaddeco_trafficlights00_02","type":"animation","frames":[{"x":64,"y":469,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {"id":"$anim_roaddeco_trafficlights00_03","type":"animation","frames":[{"x":92,"y":469,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {
    "id":"$roaddeco_trafficlights00",
    "type":"road decoration",
    "price":100,
    "animation":[
      {"id":"$anim_roaddeco_trafficlights00_00"},
      {"id":"$anim_roaddeco_trafficlights00_02"}
    ],
    "frame animation indices":[
      [0,1],[0,1],[1],[1],
      [0],[0],[],[],
      [0,1],[0,1],[1],[1],
      [0],[0],[],[]
    ],
    "animation fg":[
      {"id":"$anim_roaddeco_trafficlights00_01"},
      {"id":"$anim_roaddeco_trafficlights00_03"}
    ],
    "frame animation fg indices":[
      [0,1],[0],[0,1],[0],
      [0,1],[0],[0,1],[0],
      [1],[],[1],[],
      [1],[],[1],[]
    ],
    "fun":{
      "condition":"day%10>=8",
      "action":{"type":"build","id":"$roaddeco_trafficlights01"}
    }
  },

  {"id":"$anim_roaddeco_trafficlights01_00","type":"animation","frames":[{"x":0,"y":368,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {"id":"$anim_roaddeco_trafficlights01_01","type":"animation","frames":[{"x":32,"y":368,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {"id":"$anim_roaddeco_trafficlights01_02","type":"animation","frames":[{"x":64,"y":368,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {"id":"$anim_roaddeco_trafficlights01_03","type":"animation","frames":[{"x":92,"y":368,"w":32,"h":16,"handle y":8,"offset y":3072}]},
  {
    "hidden":true,
    "id":"$roaddeco_trafficlights01",
    "type":"road decoration",
    "title id":"draft_roaddeco_trafficlights00_title",
    "text id":"draft_roaddeco_trafficlights00_text",
    "price":100,
    "enter speed":0,
    "animation":[
      {"id":"$anim_roaddeco_trafficlights01_00"},
      {"id":"$anim_roaddeco_trafficlights01_02"}
    ],
    "frame animation indices":[
      [0,1],[0,1],[1],[1],
      [0],[0],[],[],
      [0,1],[0,1],[1],[1],
      [0],[0],[],[]
    ],
    "animation fg":[
      {"id":"$anim_roaddeco_trafficlights01_01"},
      {"id":"$anim_roaddeco_trafficlights01_03"}
    ],
    "frame animation fg indices":[
      [0,1],[0],[0,1],[0],
      [0,1],[0],[0,1],[0],
      [1],[],[1],[],
      [1],[],[1],[]
    ],
    "fun":{
      "condition":"day%10<8",
      "action":{"type":"build","id":"$roaddeco_trafficlights00"}
    }
  }
There are actually two decorations that use different frames. One of them stops incoming cars by using "enter speed":0. They replace themself with the other variant at specific days (namely when the remainder of absolute day divided by 10 is <8 or >=8).
=^._.^= ∫

User avatar
Kulche
Pluche
Reactions:
Posts: 1048
Joined: 07 Jun 2017, 20:28
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Road decoration

#18

Post by Kulche »

How can I place specific decos only on straight roads? Could you please mark frame animation indices indexes? Like "1st is for curve" :v
I'm not lazy, I'm motivated to do nothing!
...blame lobby for that

User avatar
CommanderABab
AB
Reactions:
Posts: 10597
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Platform

Plugin Creator

Re: Road decoration

#19

Post by CommanderABab »

wgreyroadrd.png
wgreyroadrd.png (3.22 KiB) Viewed 7327 times
Counting from 0, you can see that the straight sections are at 5 and 10.

User avatar
Kulche
Pluche
Reactions:
Posts: 1048
Joined: 07 Jun 2017, 20:28
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Road decoration

#20

Post by Kulche »

Thanks! :json
I'm not lazy, I'm motivated to do nothing!
...blame lobby for that

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”