Roads

Learn here how to create and use plugins.

Moderator: Plugin Moderators

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

Platform

Roads

#1

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.png
image.png (7.44 KiB) Viewed 196 times
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).



:66:
For recent versions please note that the road on the ramp needs one additional line of pixels on the top end to cover specific transitions between slopes and none slopes. The ramps in the image above have already been fixed.

Since terrain was added you can now specify your own frames that will be used for road that is placed directly onto slopes:

Code: Select all

"slope frames":[
  {"x":120,"y":311,"w":32,"h":32,"count":4,"offset x":2048,"offset y":1024}
],
For example:
image.png
image.png (2.68 KiB) Viewed 196 times
By default the game will use the frames provided for flat road and squeeze them onto the slope. Alternatively, if provided, the ramps of the bridge(s) will be used.
Last edited by Lobby on Sun Jun 04, 2017 23:47, edited 1 time in total.

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

Platform

#2

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

There are some more values you might optionally provide.

Show
auto join (default=true)
Determines whether neighboring roads should be joined automatically. May be useful for roads with multiple lanes (see value "width" below).
Show
allow bus (default=true)
Determines whether bus stops may be place on this road.
Show
allow transfer (default=true)
Determines whether buildings have a road connection if they are nearby.
Show
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.
Show
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.
Show
one way frames (default=empty by 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.
Show
overrunnable (default=true)
For one ways only. If true, cars may overrun others on this one way.
Show
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.
Show
decoration buildings (empty by 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".
Show
connectable (default=true)
If true, this road can connect to neighbor cities.
Show
pile distant (default=2)
In case you use bridges this is the intended distance between piles.


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

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

Platform

Re: Roads

#3

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: 3314
Joined: Sun Oct 26, 2008 12:34
Plugins: Show
Version: Beta
Phone model: S7 edge

Platform

Re: Roads

#4

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: 7433
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Road Animations

#5

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

See here for downloadhttp://www.theotown.com/forum/viewtopic ... 211#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 4223 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 4223 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.
719719Currently using alpha 719. 719 What's new? :)
hills & night!!
:)

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

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

Platform

Plugin Creator

Re: Roads

#6

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: 911
Joined: Wed Jun 07, 2017 20:28
Location: In da house
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Roads

#7

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: 7433
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Roads

#8

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

Width must be odd above or equal to 3 for decos.
719719Currently using alpha 719. 719 What's new? :)
hills & night!!
:)

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

User avatar
JustAnyone
Junior Developer
Reactions:
Posts: 2572
Joined: Sun Jul 23, 2017 12:45
Location: No idea either
Plugins: Show

Plugin Creator

Platform

Re: Roads

#9

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: 2572
Joined: Sun Jul 23, 2017 12:45
Location: No idea either
Plugins: Show

Plugin Creator

Platform

Re: Roads

#10

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: 7433
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Roads

#11

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

Nope.
719719Currently using alpha 719. 719 What's new? :)
hills & night!!
:)

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

User avatar
JustAnyone
Junior Developer
Reactions:
Posts: 2572
Joined: Sun Jul 23, 2017 12:45
Location: No idea either
Plugins: Show

Plugin Creator

Platform

Re: Roads

#12

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

Or there is another option.
[mention]Lobby[/mention] could I get national road textures?

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

Platform

Re: Roads

#13

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

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

User avatar
danekbel
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2769
Joined: Thu May 05, 2016 9:33
Location: in your dreams
Plugins: Show
Version: Beta
Phone model: person, who uses cracked software and doesn't see why it's a bad thing N-1

Platform

Plugin Creator

Re: Roads

#14

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

Platform

Re: Roads

#15

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: 7433
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Roads

#16

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

Code: Select all

  "title":"unidirectional freeway",
  "text":"freeway lanes to be placed in one direction","...
719719Currently using alpha 719. 719 What's new? :)
hills & night!!
:)

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

Platform

Re: Roads

#17

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: 7433
Joined: Tue Jun 07, 2016 21:12
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Roads

#18

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}    
     ],
719719Currently using alpha 719. 719 What's new? :)
hills & night!!
:)

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

Platform

Re: Roads

#19

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, [mention]CommanderABab[/mention] now my route contain title!
:bd :bp :mine

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

Platform

Re: Roads

#20

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!

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 1 guest