Page 1 of 5

Roads

Posted: Sun Jun 04, 2017 22:01
by Lobby
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 6203 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 6203 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.

Posted: Mon Jun 05, 2017 15:06
by Lobby
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.

Re: Roads

Posted: Wed Jun 21, 2017 17:34
by Lobby
In case you need templates for your own roads, here you have our frames for dirty road and country road.
dirt_road[1].png
dirt_road[1].png (7.61 KiB) Viewed 969 times
country_road[1].png
country_road[1].png (5.98 KiB) Viewed 969 times
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.

Re: Roads

Posted: Wed Jun 28, 2017 15:18
by Lobby
We added as speed that is only use if winter is active:

speed winter (default=speed)
Speed on this road in winter.

Re: Road Animations

Posted: Mon Jul 24, 2017 12:10
by CommanderABab
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}
}
For reference only
For reference only
rainbowbar1.png (681 Bytes) Viewed 10230 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}
}
For reference only
For reference only
drainbowbar1.png (724 Bytes) Viewed 10230 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.

Re: Roads

Posted: Tue Aug 29, 2017 2:39
by rjroldan1
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

Re: Roads

Posted: Tue Aug 29, 2017 9:40
by Kulche
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.

Re: Roads

Posted: Tue Aug 29, 2017 10:08
by CommanderABab
Width must be odd above or equal to 3 for decos.

Re: Roads

Posted: Sun Nov 12, 2017 13:45
by JustAnyone
Can I use steal frames attribute for roads? And how?

Re: Roads

Posted: Sun Nov 12, 2017 13:54
by JustAnyone
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
 }
]

Re: Roads

Posted: Sun Nov 12, 2017 14:30
by CommanderABab
Nope.

Re: Roads

Posted: Sun Nov 12, 2017 15:58
by JustAnyone
Or there is another option.
@Lobby could I get national road textures?

Re: Roads

Posted: Tue Nov 14, 2017 22:42
by Lobby
:img

Re: Roads

Posted: Sat Nov 18, 2017 11:35
by danekbel
Can I have bridge frames for a county road, please?

Re: Roads

Posted: Sun Dec 24, 2017 18:25
by fico240
I don't know how write a title and description :(
The name of road is: <draft:unidirectionalfreeway:title>

Re: Roads

Posted: Sun Dec 24, 2017 18:46
by CommanderABab

Code: Select all

  "title":"unidirectional freeway",
  "text":"freeway lanes to be placed in one direction","...

Re: Roads

Posted: Sun Dec 24, 2017 18:55
by fico240
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

Re: Roads

Posted: Sun Dec 24, 2017 19:16
by CommanderABab
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}    
     ],

Re: Roads

Posted: Sun Dec 24, 2017 22:57
by fico240
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!

Re: Roads

Posted: Sat Jan 13, 2018 21:09
by mdk_813
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?