Determining vehicle direction on roads

Learn here how to create and use plugins.

Moderator: Plugin Moderators

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

Platform

Plugin Creator

Determining vehicle direction on roads

#1

Post by CommanderABab » Fri Jul 20, 2018 4:25

How to change the standard movement on roads:

Remember, arrays start with 0. :)
innerr.png
innerr.png (2.04 KiB) Viewed 1180 times
Subtile Order of Each Road Tile:

..........❌
.....❌ 2 ❌
.❌ 0 ❌ 3 ❌
.....❌ 1 ❌
..........❌


Moving direction is the sum of:
(This is from one of the subtiles above; a vehicle has reached this spot, the sum equals the possible directions it can go from here.)
↘️ 1
↗️ 2
↖️ 4
↙️ 8

So, "No direction" would be 0. Thus the vehicle would stop and most likely despawn. All directions would be 15 (for intersections).

An example of dirs for a two way road (24 number array):
(Dirs need to be provided for the frame in the comments, the others are determined from these)

Code: Select all

    "dirs":[
      12,9,3,6 , //0
      1, 1, 8,4,  //1
   
      1,1, 8, 2,  //3
  
      9,9,6,6, //5
    
      1, 3, 12, 6,  //7
  
      13,11,14,7 //15
    ]
An example of dirs for a one way road (64 number array):
(One for each of the first 15 road frames, the others are adapted from these.)

Code: Select all

      "dirs":[
       0,0,0,0,
       1,1,1,1,
       2,2,2,2,
       1,1,9,1,
       4,4,4,4,
       9,9,3,3,
       3,2,2,2,
       3,3,3,3,
       8,8,8,8,
       3,3,1,1,
       6,3,6,3,
       3,3,3,3,
       9,8,9,8,
       9,9,9,9,
       6,6,6,6,
       11,11,11,11
    ]
Note: the numbers in these examples are from my b3.plugin, which allows non-standard road movements so that cars can switch lanes across 3 or more lanes from the inner 2 way road straight sections across the straight sections of the one way roads placed adjacent. Thus, the cars may be seen driving off the side of ramps. :)
754!754Currently using beta 754. 754 What's new? :)
harder hard mode!!
:)

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

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

Platform

Plugin Creator

Re: Determining vehicle direction on roads

#2

Post by CommanderABab » Fri Jul 20, 2018 4:31

Image


So, you may see the t intersection directions better. :)

7,11,13,14 above are the t intersections. The yellow line though the center has breaks instead of being solid.
754!754Currently using beta 754. 754 What's new? :)
harder hard mode!!
:)

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

User avatar
Mg3094066
Inhabitant of a Supercluster
Reactions:
Posts: 3102
Joined: Sun May 28, 2017 1:50
Location: United Mexican States
Plugins: Show
Version: Beta
Phone model: LG H320mb 5.0.1

Plugin Creator

Platform

Re: Determining vehicle direction on roads

#3

Post by Mg3094066 » Fri Jul 20, 2018 8:41

Aaaaaaa my head will exlode D:
I want my diamonds you get the plugins free or not :bd

User avatar
danekbel
Inhabitant of a Galaxy Cluster
Reactions:
Posts: 2773
Joined: Thu May 05, 2016 9:33
Location: in your dreams
Plugins: Show
Version: Beta

Platform

Plugin Creator

Re: Determining vehicle direction on roads

#4

Post by danekbel » Fri Jul 20, 2018 10:24

i think it's time to throw my brain to the trash can
some text.

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

Platform

Plugin Creator

Re: Determining vehicle direction on roads

#5

Post by CommanderABab » Thu Jun 06, 2019 2:07

CommanderABab wrote:
Fri Jul 20, 2018 4:25
How to change the standard movement on roads:

Remember, arrays start with 0. :)
Image


Subtile Order of Each Road Tile:

..........❌
.....❌ 2 ❌
.❌ 0 ❌ 3 ❌
.....❌ 1 ❌
..........❌


Moving direction is the sum of:
(This is from one of the subtiles above; a vehicle has reached this spot, the sum equals the possible directions it can go from here.)
↘️ 1
↗️ 2
↖️ 4
↙️ 8

So, "No direction" would be 0. Thus the vehicle would stop and most likely despawn. All directions would be 15 (for intersections).

An example of dirs for a two way road (24 number array):
(Dirs need to be provided for the frame in the comments, the others are determined from these)

Code: Select all

    "dirs":[
      12,9,3,6 , //0
      1, 1, 8,4,  //1
   
      1,1, 8, 2,  //3
  
      9,9,6,6, //5
    
      1, 3, 12, 6,  //7
  
      13,11,14,7 //15
    ]
An example of dirs for a one way road (64 number array):
(One for each of the first 15 road frames, the others are adapted from these.)

Code: Select all

      "dirs":[
       0,0,0,0,
       1,1,1,1,
       2,2,2,2,
       1,1,9,1,
       4,4,4,4,
       9,9,3,3,
       3,2,2,2,
       3,3,3,3,
       8,8,8,8,
       3,3,1,1,
       6,3,6,3,
       3,3,3,3,
       9,8,9,8,
       9,9,9,9,
       6,6,6,6,
       11,11,11,11
    ]
Note: the numbers in these examples are from my b3.plugin, which allows non-standard road movements so that cars can switch lanes across 3 or more lanes from the inner 2 way road straight sections across the straight sections of the one way roads placed adjacent. Thus, the cars may be seen driving off the side of ramps. :)
754!754Currently using beta 754. 754 What's new? :)
harder hard mode!!
:)

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

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

Platform

Plugin Creator

Re: Determining vehicle direction on roads

#6

Post by CommanderABab » Thu Jun 06, 2019 2:40

Code: Select all

    "dirs":[
      12,9,3,6 , //0
      1, 1, 8,4,  //1
      1,1, 8, 2,  //3
      9,9,6,6, //5
      8, 1, 6, 6,  //7
      8,1,4,2 //15
    ]

Where will it go?

:)
754!754Currently using beta 754. 754 What's new? :)
harder hard mode!!
:)

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

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

Platform

Plugin Creator

Re: Determining vehicle direction on roads

#7

Post by CommanderABab » Thu Jul 04, 2019 12:07

Currently used in green road special:

Code: Select all

    "dirs":[
      12,9,3,6 , //0
      1, 1, 8,4,  //1
      1,1, 8, 2,  //3
      9,9,6,6, //5
      9, 1, 6, 6,  //7
      8,1,4,2 //15
    ]
Screenshot_20190704-054947.jpg
754!754Currently using beta 754. 754 What's new? :)
harder hard mode!!
:)

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

User avatar
Lakan Haraya
Villager
Reactions:
Posts: 23
Joined: Thu Mar 28, 2019 9:34
Location: Manila, Philippines
Plugins: Show
Version: Beta

Re: Determining vehicle direction on roads

#8

Post by Lakan Haraya » Thu Jul 04, 2019 12:31

CommanderABab wrote:
Thu Jun 06, 2019 2:40

Code: Select all

    "dirs":[
      12,9,3,6 , //0
      1, 1, 8,4,  //1
      1,1, 8, 2,  //3
      9,9,6,6, //5
      8, 1, 6, 6,  //7
      8,1,4,2 //15
    ]

Where will it go?

:)
Answer key ;)
Conversion to moving directions
↖&↙,↘&↙,↗&↖,↘&↗ //0 (frame 0)
↘,↘,↙,↖ //1 (frame 1)
↘,↘,↙,↗ //3 (frame 3)
↘&↙,↘&↙,↗&↖,↗&↖ //5 (frame 5)
↙,↘,↗&↖,↗&↖ //7 (frame 7)
↙,↘,↖,↗ //15 (frame 15)
:calc
I think frame 0 won't spawn in this moving directions, frame 1 looks like a U-turn slot, frame 3 is a 2-way road turning to the perpendicular row of tiles, frame 5 seems to be a 2-way road bounded intersection for directions 2 ↗ (for 4 ↖) and 8 ↙ (for 1 ↘), frame 7 is more like these sequence... ↙,↘,↖↗,↖↗ ... :)
Frame 15 is fully bounded intersection (I mean, the vehicles will only turn right in the corner)
:bt
To illustrate:
received_1384531225019585-1.jpg
Ako ang iyong Haráya
I am your Imagination

Founder of the first jeepney manufacturer in TheoTown
________________________________________
Taganayon

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

Platform

Plugin Creator

Re: Determining vehicle direction on roads

#9

Post by CommanderABab » Thu Jul 04, 2019 14:06

I'm glad that you are taking interest. :)

Frame 0 is just a single road tile unconnected. The idea here is if a car spawns here, it will move to an adjacent road if available.

Note my restored post above showing what I currently use in Green Road Special.

You are correct about frame 15.

Frame 1 is the end section of the road.

Frame 3 is the curve of the road.

Frame 5 is the straight of the road, connected on both ends. The idea here is that this two way section can be used as a median section between two one way spans. Cars can thus move to the one way spans also, in addition to going straight.

You are correct about frame 7 as you quoted it, but in the actual plugin, cars can also go straight instead of being forced to turn right. But I still do not allow the left turn. And, on the far side of the T, it still behaves as the straight section.
754!754Currently using beta 754. 754 What's new? :)
harder hard mode!!
:)

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

User avatar
Lakan Haraya
Villager
Reactions:
Posts: 23
Joined: Thu Mar 28, 2019 9:34
Location: Manila, Philippines
Plugins: Show
Version: Beta

Re: Determining vehicle direction on roads

#10

Post by Lakan Haraya » Thu Jul 04, 2019 15:04

I thought about it one night... I knew it!
It is interesting for traffic management and I think it could be a helpful tool to create real-life gas station in the game... I mean, passing cars beneath the station's roof... :/
Ako ang iyong Haráya
I am your Imagination

Founder of the first jeepney manufacturer in TheoTown
________________________________________
Taganayon

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”

Who is online

Users browsing this forum: No registered users and 3 guests