Roads

Learn here how to create and use plugins.

Moderator: Plugin Moderators

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

Roads

Post by Lobby » Sun Jun 04, 2017 22:01

So let's create a road plugin. I would like to have a blue road similar to the existing country road that looks like this:
Image


To get started we need some frames for the base graphics first: road.png
Image
The orientation follows a specific order. For your own road it's sufficient to use this graphic as template. You have to provide 16 frames here.

As we want to have a bridge we also have to provide graphics for it: bridge.png
Image
The ordering is important :!:
If we want to use a bridge we have to tell TheoTown the pixel height of it. For some reason the height has to be 12. The number of frames must be a multiple of 12. If you provide 24 frame for example, your road will have two bridge types.

Additionally, in case we want to have some traffic lights, we might use this ones: tf.png
Image
If we use traffic lights, we also have to provide more information about phase lengths.

Our json code may now look like

Code: Select all

[
  {
    "id":"$testroad00",
    "type":"road",
    "level":1,
    "speed":2.0,

    "frames":[{"bmp":"road.png","w":32,"h":16,"count":16}],

    "bridge frames":[{"bmp":"bridge.png","w":32,"h":48,"count":12}],
    "bridge height":12,

    "traffic lights":[{"bmp":"tf.png","w":32,"h":32,"count":4}],
    "green phase":3000,
    "yellow phase":500,

    "price":50,
    "bridge price":200,
    "monthly price":2
  }
]
Note how I use can reference multiple frames from one image by providing values w, h and count.

The value level determines whether this road overrides other road types. Every road has it's own level and can only override roads which have a lower level. Value speed determines how fast cars will drive on this road. For reference, the slowest road has speed 1.0, the fastest road has speed 5.0 (natively in the game).

If you don't provide any frames for traffic lights your road won't have any. The values green phase and yellow phase indicate phase length in milliseconds (1000ms = 1s).

That's all, have fun 8)
Last edited by Lobby on Sun Jun 04, 2017 23:47, edited 1 time in total.

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

Post by Lobby » Mon Jun 05, 2017 15:06

There are some more values you might optionally provide.


auto join (default=true)
Determines whether neighboring roads should be joined automatically. May be useful for roads with multiple lanes (see value width below).

allow bus (default=true)
Determines whether bus stops may be place on this road.

allow transfer (default=true)
Determines whether buildings have a road connection if they are nearby.

allow crossing (default=true)
Determines whether road tool should allow X crossings. We discourage you to use it as it's no fun for the player.

one way (default=false)
If true, cars can only drive into one direction on this road type. You then have to provide 64 instead of 16 frames. First 16 frames will be used for alignment SOUTH_EAST, the next 16 frames for NORTH_EAST, then NORTH_WEST and at least SOUTH_WEST. You may save texture space by providing the first 16 frames multiple times and use one way frames for an alignment specific overlay.

one way frames (default=[])
For one ways only. Here you can provide 4 frames which will then be used as overlay dependent on road alignment. The order is SOUTH_EAST, NORTH_EAST, NORTH_WEST, SOUTH_WEST.

overrunnable (default=true)
For one ways only. If true, cars may overrun others on this one way.

width (default=1)
Number of lanes that should be built at the same time from road tool. In combination with flag one way this can be used to define highways or alleys. For alleys you can define decorations that should be used with decoration buildings.

decoration buildings (default=[])
Only used if width is odd and greater than 2. An array of ids of 1x1 sized decoration buildings that should be used for decoration purposes. For example the default alley uses "$decoroad00".

connectable (default=true)
If true, this road can connect to neighbor cities.

pile distant (default=2)
In case you use bridges this is the intended distance between piles.


You also may set flags, you can find more information about that in this thread.
Last edited by Lobby on Fri Jun 09, 2017 21:51, edited 2 times in total.

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

Re: Roads

Post by Lobby » Wed Jun 21, 2017 17:34

In case you need templates for your own roads, here you have our frames for dirty road and country road.
Image
Image

As usual, you're free to use these graphics in your own TheoTown plugins as long as you state it's source (me and theo) in your publications of it.
...Have a nice stay

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

Re: Roads

Post by Lobby » Wed Jun 28, 2017 15:18

We added as speed that is only use if winter is active:

speed winter (default=speed)
Speed on this road in winter.
...Have a nice stay

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

Re: Road Animations

Post by CommanderABab » Mon Jul 24, 2017 12:10

See here for downloadviewtopic.php?p=43211#p43211

Code: Select all

{
    "id":"$ab.roadanim1",
    "author":"CommanderABab",
    "type":"animation",
	"width":1,
	"height":1,
	
	"frames":[
    {"bmp":"rainbowbar1.png","w":4,"target w":31,"target h":15,"handle x":0,"handle y":1,"offset x":0,"offset y":0,"count":16},
     {"bmp":"rainbowbar1.png","w":4,"target w":31,"target h":15,"handle x":0,"handle y":1,"offset x":0,"offset y":0,"count":16}
    ],
    "color":{"r":300,"g":300,"b":300,"a":95}
}
rainbowbar1.png
For reference only
rainbowbar1.png (681 Bytes) Viewed 3451 times

Code: Select all

{  "id":"$ab.roadanim2",
    "author":"CommanderABab",
    "type":"animation",
	"width":1,
	"height":1,
	
	"frames":[
    {"bmp":"drainbowbar1.png","w":4,"target w":31,"target h":15,"handle x":0,"handle y":1,"offset x":0,"offset y":0,"count":16},
     {"bmp":"drainbowbar1.png","w":4,"target w":31,"target h":15,"handle x":0,"handle y":1,"offset x":0,"offset y":0,"count":16}
    ],
    "color":{"r":300,"g":300,"b":300,"a":95}
}
drainbowbar1.png
For reference only
drainbowbar1.png (724 Bytes) Viewed 3451 times
Since the different color frames are only 4x4, they are enlarged using the target w and target h. I used 31 and 15 to stay within the road tile. The handle y:1 sets the animation so it can be seen.

The color statement determines amount of each color to allow through. "a" alpha of 0 would not show anything. 95 allows most of the projected image through.

Code: Select all

{
    "id":"$ab.test_road4",
    "title":"dirt road rainbow",
    "text":"showing how to use animations on roads",
    "author":"Lobby Divinus",
    "type":"road",
    "level":10,
    "frames":[{"x":512,"y":0,"w":32,"h":16,"count":16}],
    "speed":1.0,
    "animation":[
      {"id":"$animationblinkingredlight3x3","x":15,"y":-1},
      {"id":"$ab.roadanim1"},
      {"id":"$ab.roadanim2"}
    ],
    "frame animation indices":[
      [0,1,2],
      [0,1,2],
      [0,1,2],
      [1,2],

      [0,1,2],
      [1,2],
      [1,2],
      [1,2],

      [0,1,2],
      [1,2],
      [1,2],
      [1,2],

      [1,2],
      [1,2],
      [1,2],
      [0]
    ],
    "price":10,
    "monthly price":1,
    "connectable":false
  }
]

The road is level 10?
That's the way the example came to me! B)

How are the animations shown?
There are indices to each animation defined in the animations statement.
[0] is the first defined, [1] the next, etc.

So on my road:
[0] shows the blinking red light at that road tile. [] would show none of the animations. [1,2] shows the changing rainbow animations. [0,1,2] shows all three. You could have more.
606606Currently using beta 606. 606 What's new? :)
Trains!!
:)

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

User avatar
rjroldan1
Inhabitant of a Conurbation
Reactions:
Posts: 455
Joined: Mon Jul 17, 2017 16:16
Location: philippines
Plugins: Show
Version: Beta
Contact:

Re: Roads

Post by rjroldan1 » Tue Aug 29, 2017 2:39

i have question how about like highway whats the code for it and what are the value of height and width? or for those alley
❤Silent❤

President of Metropole region

____________________________________________________________________________________
❤I LOVE PHILIPPINES❤

User avatar
Kulche
Inhabitant of a Country
Reactions:
Posts: 878
Joined: Wed Jun 07, 2017 20:28
Location: In da house
Plugins: Show
Version: Beta

Re: Roads

Post by Kulche » Tue Aug 29, 2017 9:40

rjroldan1 wrote: ↑
Tue Aug 29, 2017 2:39
i have question how about like highway whats the code for it and what are the value of height and width? or for those alley
Said above.
Width must be greater than 2 to place decos.
I'm not lazy, I'm on battery saving mode!

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

Re: Roads

Post by CommanderABab » Tue Aug 29, 2017 10:08

Width must be odd above or equal to 3 for decos.
606606Currently using beta 606. 606 What's new? :)
Trains!!
:)

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

User avatar
JustAnyone
Junior Developer
Reactions:
Posts: 2485
Joined: Sun Jul 23, 2017 12:45
Location: Pickle command administration
Plugins: Show
Version: Beta
Phone model: Picklephone S5

Re: Roads

Post by JustAnyone » Sun Nov 12, 2017 13:45

Can I use steal frames attribute for roads? And how?

User avatar
JustAnyone
Junior Developer
Reactions:
Posts: 2485
Joined: Sun Jul 23, 2017 12:45
Location: Pickle command administration
Plugins: Show
Version: Beta
Phone model: Picklephone S5

Re: Roads

Post by JustAnyone » Sun Nov 12, 2017 13:54

KoalaGuy wrote: ↑
Sun Nov 12, 2017 13:52
JustAnyone wrote: ↑
Sun Nov 12, 2017 13:45
Can I use steal frames attribute for roads? And how?
Yes. Same as in every other building. I think there's a topic for that.

Code: Select all

[
{
"id":"$devroad001",
"type":"road",
"hidden":false,
"override":true,
"level":3,
"speed": 3.5,
"title":"DSA Vehicle Road",
"text":"Dedicated road for all DSA vehicles.",
"frames": [{
		"steal":"$devroad00"
	}],
 "price":50,
 "monthly price":2
 }
]

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

Re: Roads

Post by CommanderABab » Sun Nov 12, 2017 14:30

Nope.
606606Currently using beta 606. 606 What's new? :)
Trains!!
:)

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

User avatar
JustAnyone
Junior Developer
Reactions:
Posts: 2485
Joined: Sun Jul 23, 2017 12:45
Location: Pickle command administration
Plugins: Show
Version: Beta
Phone model: Picklephone S5

Re: Roads

Post by JustAnyone » Sun Nov 12, 2017 15:58

Or there is another option.
@Lobby could I get national road textures?

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

Re: Roads

Post by Lobby » Tue Nov 14, 2017 22:42

:img
Attachments
national_road.png
national_road.png (3.48 KiB) Viewed 2964 times
...Have a nice stay

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

Re: Roads

Post by danekbel » Sat Nov 18, 2017 11:35

Can I have bridge frames for a county road, please?
some text.

User avatar
fico240
Townsman
Reactions:
Posts: 64
Joined: Thu Dec 21, 2017 3:20
Location: Córdoba, Argentina
Plugins: Show
Version: Beta
Phone model: Motorola G2

Re: Roads

Post by fico240 » Sun Dec 24, 2017 18:25

I don't know how write a title and description :(
The name of road is: <draft:unidirectionalfreeway:title>
:bd :bp :mine

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

Re: Roads

Post by CommanderABab » Sun Dec 24, 2017 18:46

Code: Select all

  "title":"unidirectional freeway",
  "text":"freeway lanes to be placed in one direction","...
606606Currently using beta 606. 606 What's new? :)
Trains!!
:)

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

User avatar
fico240
Townsman
Reactions:
Posts: 64
Joined: Thu Dec 21, 2017 3:20
Location: Córdoba, Argentina
Plugins: Show
Version: Beta
Phone model: Motorola G2

Re: Roads

Post by fico240 » Sun Dec 24, 2017 18:55

CommanderABab wrote: ↑
Sun Dec 24, 2017 18:46

Code: Select all

  "title":"unidirectional freeway",
  "text":"freeway lanes to be placed in one direction","...
Yes, I know, but when I add it to the json, it does not let me use the plugin
:bd :bp :mine

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

Re: Roads

Post by CommanderABab » Sun Dec 24, 2017 19:16

For example:

Code: Select all

{  
     "active": true,
     "id":"$redyellow00", 
     "type":"road", 
    // "ordinal":10,
     //"category":"$ab.myroads.s00utile",
     //"author": "Commander ABab",
     "level":4,
     "width":2,
     "height":1,
     "frames":[
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16}    
     ],
     
     "one way frames":[
       {"steal":"$arrows04","frame":0,"count":4}
     ],
     "show arrows":true,
     "bridge frames":[ 
       {"bmp":"Gb1.png"},
       {"bmp":"Gb2.png"},
       {"bmp":"Gb3.png"},
       {"bmp":"Gb4.png"},
       {"bmp":"Gb5.png","handle x":0,"handle y":19},
       {"bmp":"Gb6.png","handle x":0,"handle y":19},
       {"bmp":"Gb7.png","handle x":0,"handle y":19},
       {"bmp":"Gb8.png","handle x":0,"handle y":19},
       {"bmp":"Gb9.png","handle x":0,"handle y":19},
       {"bmp":"Gb10.png","handle x":0,"handle y":19},
       {"bmp":"Gb11.png","handle x":0,"handle y":19},
       {"bmp":"Gb12.png","handle x":0,"handle y":19}
     ],
     "traffic lights":[
       {"bmp":"Gtl3.png"},
       {"bmp":"Gtl4.png"},
       {"bmp":"Gtl1.png"},
       {"bmp":"Gtl2.png"}
     ],
     "bridge height":        -20,
     "bridge price":         100,
     "overrunnable":         false,
     "one way":              true,
     "green phase":          6000,
     "yellow phase":         1000,
     "speed":                25.2,
     "price":                50, 
     "monthly price":        4,
     "auto join":      false,
     "allow bus stop": true,
     "allow crossing": false,
     "allow transfer": true,
     "title":"Yellow Road", 
     "text":"\nFor those from desert areas. :)"
  },
What does your .json look like?

If you have

Code: Select all

     "one way": true,
, then you have to provide 64 frames for the road:

Code: Select all

"frames":[
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16}    
     ],
606606Currently using beta 606. 606 What's new? :)
Trains!!
:)

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

User avatar
fico240
Townsman
Reactions:
Posts: 64
Joined: Thu Dec 21, 2017 3:20
Location: Córdoba, Argentina
Plugins: Show
Version: Beta
Phone model: Motorola G2

Re: Roads

Post by fico240 » Sun Dec 24, 2017 22:57

CommanderABab wrote: ↑
Sun Dec 24, 2017 19:16
For example:

Code: Select all

{  
     "active": true,
     "id":"$redyellow00", 
     "type":"road", 
    // "ordinal":10,
     //"category":"$ab.myroads.s00utile",
     //"author": "Commander ABab",
     "level":4,
     "width":2,
     "height":1,
     "frames":[
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16}    
     ],
     
     "one way frames":[
       {"steal":"$arrows04","frame":0,"count":4}
     ],
     "show arrows":true,
     "bridge frames":[ 
       {"bmp":"Gb1.png"},
       {"bmp":"Gb2.png"},
       {"bmp":"Gb3.png"},
       {"bmp":"Gb4.png"},
       {"bmp":"Gb5.png","handle x":0,"handle y":19},
       {"bmp":"Gb6.png","handle x":0,"handle y":19},
       {"bmp":"Gb7.png","handle x":0,"handle y":19},
       {"bmp":"Gb8.png","handle x":0,"handle y":19},
       {"bmp":"Gb9.png","handle x":0,"handle y":19},
       {"bmp":"Gb10.png","handle x":0,"handle y":19},
       {"bmp":"Gb11.png","handle x":0,"handle y":19},
       {"bmp":"Gb12.png","handle x":0,"handle y":19}
     ],
     "traffic lights":[
       {"bmp":"Gtl3.png"},
       {"bmp":"Gtl4.png"},
       {"bmp":"Gtl1.png"},
       {"bmp":"Gtl2.png"}
     ],
     "bridge height":        -20,
     "bridge price":         100,
     "overrunnable":         false,
     "one way":              true,
     "green phase":          6000,
     "yellow phase":         1000,
     "speed":                25.2,
     "price":                50, 
     "monthly price":        4,
     "auto join":      false,
     "allow bus stop": true,
     "allow crossing": false,
     "allow transfer": true,
     "title":"Yellow Road", 
     "text":"\nFor those from desert areas. :)"
  },
What does your .json look like?

If you have

Code: Select all

     "one way": true,
, then you have to provide 64 frames for the road:

Code: Select all

"frames":[
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16},
       {"bmp":"yellowroad.png","w":32,"count":16}    
     ],
thanks, @CommanderABab now my route contain title!
:bd :bp :mine

User avatar
mdk_813
Inhabitant of a Country
Reactions:
Posts: 849
Joined: Fri Dec 16, 2016 2:38
Location: Germany
Plugins: Show

Re: Roads

Post by mdk_813 » Sat Jan 13, 2018 21:09

Hi guys,
I have a question.
Let's say I want to make a oneway-road, but without 64 frames and without an arrow-overlay. Would it be possible to provide just 16 frames and still have it work as a oneway road. Obviously one would have to pay attention to use the proper directions when building it, but still, would it work?
My Plugins: Link

PLEASE NOTE: My plugins are not open source! So, ask me first before altering and republishing any of my plugins!

User avatar
mdk_813
Inhabitant of a Country
Reactions:
Posts: 849
Joined: Fri Dec 16, 2016 2:38
Location: Germany
Plugins: Show

Re: Roads

Post by mdk_813 » Sat Jan 13, 2018 23:14

Thanks, @KoalaGuy !
My Plugins: Link

PLEASE NOTE: My plugins are not open source! So, ask me first before altering and republishing any of my plugins!

User avatar
mdk_813
Inhabitant of a Country
Reactions:
Posts: 849
Joined: Fri Dec 16, 2016 2:38
Location: Germany
Plugins: Show

Re: Roads

Post by mdk_813 » Sun Jan 14, 2018 1:09

Hm, not quite yet, I'm afraid. The game crashes when I'm scrolling to my custom oneway-road in the road menu...
Any ideas what causes this crash?
@KoalaGuy @former member ?
My Plugins: Link

PLEASE NOTE: My plugins are not open source! So, ask me first before altering and republishing any of my plugins!

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

Re: Roads

Post by CommanderABab » Sun Jan 14, 2018 2:28

One way roads require 64 frames. You may use 16, and repeat 3 more times, like I showed above.

Of course, you might not want to use my handles for the bridge frames,
as this is for tunnel bridges.
606606Currently using beta 606. 606 What's new? :)
Trains!!
:)

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

User avatar
mdk_813
Inhabitant of a Country
Reactions:
Posts: 849
Joined: Fri Dec 16, 2016 2:38
Location: Germany
Plugins: Show

Re: Roads

Post by mdk_813 » Sun Jan 14, 2018 2:56

CommanderABab wrote: ↑
Sun Jan 14, 2018 2:28
One way roads require 64 frames. You may use 16, and repeat 3 more times, like I showed above.

Of course, you might not want to use my handles for the bridge frames,
as this is for tunnel bridges.
Indeed, thanks. I specified the same image three additional times as frames and the crashes are gone now.
The road still doesn't work, though. My cars won't spawn (I used a custom flag both in the car and the spawner building). Don't know why, but nothing happens there.
My Plugins: Link

PLEASE NOTE: My plugins are not open source! So, ask me first before altering and republishing any of my plugins!

User avatar
rjroldan1
Inhabitant of a Conurbation
Reactions:
Posts: 455
Joined: Mon Jul 17, 2017 16:16
Location: philippines
Plugins: Show
Version: Beta
Contact:

Re: Roads

Post by rjroldan1 » Sun Jan 14, 2018 3:24

about the bridge how to customize it?
❤Silent❤

President of Metropole region

____________________________________________________________________________________
❤I LOVE PHILIPPINES❤

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest