Road decoration

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Reactions:
Posts: 3186
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Road decoration

Post by Lobby » Mon May 14, 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 :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 2472 times
The usage is supposed to follow this scheme :teach
frames_usage.png
frames_usage.png (3.94 KiB) Viewed 2472 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":92,"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 106 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
...Have a nice stay

User avatar
Artem_123
Townsman
Reactions:
Posts: 63
Joined: Sun Apr 22, 2018 15:51
Plugins: Show
Version: Beta
Phone model: 89521124584

Re: Road decoration

Post by Artem_123 » Mon May 14, 2018 17:47

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

User avatar
CommanderABab
AB
Reactions:
Posts: 6867
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Road decoration

Post by CommanderABab » Mon May 14, 2018 19:23

:)
587587Currently using beta 587. 587 What's new? :)
bus routes are supposed to be fixed!!
:cry:

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

User avatar
khadafi laidi
Inhabitant of a Planet
Reactions:
Posts: 1300
Joined: Fri Dec 16, 2016 13:11
Location: Ternate, Indonesia
Plugins: Show
Version: Beta
Phone model: Xiaomi note A5

Re: Road decoration

Post by khadafi laidi » Tue May 15, 2018 2:44

Lots of mathematical formulas
Fact about me:
-President of FINDONEZIA
-Im rarely active right now
-Subscribe my channel:
https://www.youtube.com/channel/UCWS1fz ... 4syaxcA74A

User avatar
yusuf8a684
Inhabitant of a Country
Reactions:
Posts: 915
Joined: Sun Dec 10, 2017 22:09
Location: Turkiye
Plugins: Show
Phone model: Discovery One

Re: Road decoration

Post by yusuf8a684 » Fri May 25, 2018 16:30

Woah thats beatufull but hard
Discord=EZGsP3n

User avatar
-LeoLeo-
Inhabitant of a Planet
Reactions:
Posts: 1535
Joined: Sat Jul 08, 2017 12:46
Location: Planet Fastoon, Polaris Galaxy // Th
Plugins: Show
Version: Beta
Phone model: Vivo V7
Contact:

Re: Road decoration

Post by -LeoLeo- » Wed May 30, 2018 10:54

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

Like the crosswalks and the bumps??
• I'm one with the Lombaxes •
-สวัสดี! มีใครอ่านไทยมั๊ยฮะ?-
- #PrayForAizat -


Detroit: Become Human looks cool AS HELL ❤️ |ℹ️|
¤ The P.M. of Attobaxia.
¤ The CEO of Leopolis Corp.
¤ Love Ratchet&Clank

;) :space

User avatar
CommanderABab
AB
Reactions:
Posts: 6867
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Road decoration

Post by CommanderABab » Wed May 30, 2018 20:27

-LeoLeo- wrote:
Wed May 30, 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.
587587Currently using beta 587. 587 What's new? :)
bus routes are supposed to be fixed!!
:cry:

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

User avatar
danekbel
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2744
Joined: Thu May 05, 2016 9:33
Location: in your dreams
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi Note 5

Re: Road decoration

Post by danekbel » Sun Jun 03, 2018 23:59

can i make a road change its flag with the deco?
for example, can i write in deco's json "flag bus:false" and the road on which would be this deco placed would be able to pass buses through itself?
some text.

User avatar
danekbel
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2744
Joined: Thu May 05, 2016 9:33
Location: in your dreams
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi Note 5

Re: Road decoration

Post by danekbel » Mon Jun 04, 2018 15:25

some text.

User avatar
danekbel
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2744
Joined: Thu May 05, 2016 9:33
Location: in your dreams
Plugins: Show
Version: Beta
Phone model: Xiaomi Redmi Note 5

Re: Road decoration

Post by danekbel » Wed Jun 06, 2018 8:03

OK, if it's not supported, is there a possibility to add it into a game? @Lobby
some text.

User avatar
-LeoLeo-
Inhabitant of a Planet
Reactions:
Posts: 1535
Joined: Sat Jul 08, 2017 12:46
Location: Planet Fastoon, Polaris Galaxy // Th
Plugins: Show
Version: Beta
Phone model: Vivo V7
Contact:

Re: Road decoration

Post by -LeoLeo- » Thu Jun 07, 2018 2:57

danékbel wrote:
Wed Jun 06, 2018 8: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 Thu Jun 07, 2018 6:30, edited 1 time in total.
• I'm one with the Lombaxes •
-สวัสดี! มีใครอ่านไทยมั๊ยฮะ?-
- #PrayForAizat -


Detroit: Become Human looks cool AS HELL ❤️ |ℹ️|
¤ The P.M. of Attobaxia.
¤ The CEO of Leopolis Corp.
¤ Love Ratchet&Clank

;) :space

User avatar
CommanderABab
AB
Reactions:
Posts: 6867
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Road decoration

Post by CommanderABab » Thu Jun 07, 2018 3:43

Using the fun from the road decoration, you could build a different road that would allow the busses in the same spot.
587587Currently using beta 587. 587 What's new? :)
bus routes are supposed to be fixed!!
:cry:

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

User avatar
Bearbear65
Inhabitant of a Universe
Reactions:
Posts: 4567
Joined: Fri Feb 10, 2017 14:53
Plugins: Show
Version: Beta
Phone model: Xperia™ XZ1 SO-01K

Re: Road decoration

Post by Bearbear65 » Sat Jun 09, 2018 11:24

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
ImageJust my opinion
Theotown forum authoritarian

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 1837
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Phone model: Moto Z Force Droid

Re: Road decoration

Post by KINGTUT10101 » Sat Jun 09, 2018 19:46

Would it be possible to spawn vehicles using these decorations?

User avatar
yusuf8a684
Inhabitant of a Country
Reactions:
Posts: 915
Joined: Sun Dec 10, 2017 22:09
Location: Turkiye
Plugins: Show
Phone model: Discovery One

Re: Road decoration

Post by yusuf8a684 » Sat Jun 09, 2018 19:49

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

User avatar
Pounkiller
Inhabitant of a Conurbation
Reactions:
Posts: 497
Joined: Mon Jan 15, 2018 15:53
Location: Turkey
Plugins: Show
Phone model: Huawei Mate 10 Lite

Re: Road decoration

Post by Pounkiller » Sun Jun 10, 2018 9:05

Mann,these are so complicated.
Hello people,I'm Turkish and I like foreign languages especially English and I love video games too.
I love City Builders,that's why I am playing this game.
''Si vis pacem,para bellum''.

User avatar
CommanderABab
AB
Reactions:
Posts: 6867
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Road decoration

Post by CommanderABab » Sun Jun 10, 2018 17:32

KINGTUT10101 wrote:
Sat Jun 09, 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.
587587Currently using beta 587. 587 What's new? :)
bus routes are supposed to be fixed!!
:cry:

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

User avatar
KINGTUT10101
1,000,000 inhabitants
Reactions:
Posts: 1837
Joined: Thu Jul 07, 2016 22:50
Location: 'Merica
Plugins: Show
Version: Beta
Phone model: Moto Z Force Droid

Re: Road decoration

Post by KINGTUT10101 » Sun Jun 10, 2018 18:29

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

User avatar
-LeoLeo-
Inhabitant of a Planet
Reactions:
Posts: 1535
Joined: Sat Jul 08, 2017 12:46
Location: Planet Fastoon, Polaris Galaxy // Th
Plugins: Show
Version: Beta
Phone model: Vivo V7
Contact:

Re: Road decoration

Post by -LeoLeo- » Sun Aug 05, 2018 10:38

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?
• I'm one with the Lombaxes •
-สวัสดี! มีใครอ่านไทยมั๊ยฮะ?-
- #PrayForAizat -


Detroit: Become Human looks cool AS HELL ❤️ |ℹ️|
¤ The P.M. of Attobaxia.
¤ The CEO of Leopolis Corp.
¤ Love Ratchet&Clank

;) :space

User avatar
Lobby
Developer
Reactions:
Posts: 3186
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Re: Road decoration

Post by Lobby » Sun Aug 05, 2018 11:31

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).
...Have a nice stay

User avatar
Kulche
Inhabitant of a Country
Reactions:
Posts: 854
Joined: Wed Jun 07, 2017 20:28
Location: Far, far away
Plugins: Show
Version: Beta
Phone model: I use a tablet!

Re: Road decoration

Post by Kulche » Wed Oct 10, 2018 17:21

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 on battery saving mode!

User avatar
CommanderABab
AB
Reactions:
Posts: 6867
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Re: Road decoration

Post by CommanderABab » Wed Oct 10, 2018 17:31

wgreyroadrd.png
wgreyroadrd.png (3.22 KiB) Viewed 571 times
Counting from 0, you can see that the straight sections are at 5 and 10.
587587Currently using beta 587. 587 What's new? :)
bus routes are supposed to be fixed!!
:cry:

Telegram - t.me/
🆎️🆎️🆎️🆎️Commander🆎️🆎️

User avatar
Kulche
Inhabitant of a Country
Reactions:
Posts: 854
Joined: Wed Jun 07, 2017 20:28
Location: Far, far away
Plugins: Show
Version: Beta
Phone model: I use a tablet!

Re: Road decoration

Post by Kulche » Wed Oct 10, 2018 17:32

Thanks! :json
I'm not lazy, I'm on battery saving mode!

Shama
Settler
Reactions:
Posts: 5
Joined: Tue May 08, 2018 11:00
Plugins: Show

Re: Road decoration

Post by Shama » Tue Jan 15, 2019 5:25

Hi everyone! Just started posting and doing plugin stuff, 2nd post ever! I thought I would save others the trouble I just went through trying to figure this out. (for sidewalks for my upcoming roads plugin :)

There is an error of sorts in Lobby's posted code, and zip. Obviously the in game decos are fine, but the problem seems to be spread to others plugins. The same problem was even in Rockforts trees deco json, and i'm sure many others.

The image coordinates are a bit off.. doesnt show with his trees, or really much at all unless you are trying to do sidewalks or anything that hugs the road, or are OCD with ya pixels :D)

Anyway..
{"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":92,"w":32,"handle y":8}]}

92 should be 96

...and whalla! Thanks for the great game Lobby and putting the code and what not up for us to use and play with!

before:
20190114_210559[1].png
and after:
20190114_210634[1].png
Shaman - Beneficent Monarch of the city-state of Kektaka
Less corrupt than DC, stronger than London, better churches than the Vatican, and more gold than Dubai!!

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest