Car chains

Find tutorials, documentation, and resources for creating and using TheoTown plugins.
Previous topicNext topic
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Car chains

Post by Lobby »

See this thread on how to add custom cars to the game. Since version 385 you can define a chain of cars that behaves as one vehicle. See here an example:
2017-12-07 02.50.37.png
The garbage trucks were appended to the fire brigade truck to form long, connected vehicles. A better use would be for example a tram or a bending bus. There's basically no limit in the length of the chain.

To append cars to a car just use

Code: Select all

"tail":["anotherCarId",...]  // A list of cars to append
To append the car itself just use null as convenient placeholder. So a chain of a car of length 3 would have a tail of length 2:

Code: Select all

"tail":[null,null]
The car ids used in a tail array have to be already defined. Only the first variant (4 frames make up a variant) will be used for each car in a tail. You may use the empty/invisible car $car_null00 as placeholder between cars in a chain if sufficient.

The code to achieve the fire-garbage-trains as shown above :json

Code: Select all

[
  {
    "override":true,
    "id":"$carfirebrigade00",
    "type":"car",
    "frames":[{"x":512,"y":657,"w":32,"h":18,"count":4}],
    "tail":["$garbagetruck00","$garbagetruck00","$garbagetruck00","$garbagetruck00"]
  }
]
No extra graphics needed.
You do not have the required permissions to view the files attached to this post.
Last edited by Anonymous on 07 Dec 2017, 17:40, edited 1 time in total.
a
abcde
Settler
Reactions:
Posts: 2
Joined: 03 Jul 2020, 01:12

Re: Car chains

Post by abcde »

What should I do if I want to make a train? The car chain looks like a train, but how to make it run on the rail? Can I add a few lines of code to make it a train?
thanks :bq
User avatar
Lobby
Inhabitant of a Supercluster
Reactions:
Posts: 3756
Joined: 26 Oct 2008, 10:34
Plugins: Showcase Store

Re: Car chains

Post by Lobby »

Basically yes, adding

Code: Select all

"flag normal": false,
"flag train": true
to your car chain would allow it to drive on rails. However, you need a building (e.g. a station) that spawns it because it won't be spawned automatically.
C
ChunFangXin
Settler
Reactions:
Posts: 3
Joined: 11 Jul 2020, 05:54

Re: Car chains

Post by ChunFangXin »

I'm very sorry to disturb you again, because I have encountered a terrible plug-in problem. I make a lot of trains, but they always carry a car. Sometimes I make a garbage truck on top of the train, and sometimes the fire engine will be embedded in the locomotive. It's strange. But I firmly believe that this is my programming. There is a problem with the two parameters of X and y. Because when I adjust these two parameters, the situation will change, but it never disappears. There is always this strange problem. What is the problem? How to calculate the four parameters of X, y, W and h when making automobile chain? thank you. I'm very sorry, because my English is not good, this paragraph uses the translation software to translate, if there is something wrong, I'm very sorry. :bq
i
imajoke
Inhabitant of a Conurbation
Reactions:
Posts: 528
Joined: 27 Oct 2019, 00:39
Plugins: Showcase Store
Version: Beta

Platform

Re: Car chains

Post by imajoke »

ChunFangXin wrote: 23 Jul 2020, 11:06 I'm very sorry to disturb you again, because I have encountered a terrible plug-in problem. I make a lot of trains, but they always carry a car. Sometimes I make a garbage truck on top of the train, and sometimes the fire engine will be embedded in the locomotive. It's strange. But I firmly believe that this is my programming. There is a problem with the two parameters of X and y. Because when I adjust these two parameters, the situation will change, but it never disappears. There is always this strange problem. What is the problem? How to calculate the four parameters of X, y, W and h when making automobile chain? thank you. I'm very sorry, because my English is not good, this paragraph uses the translation software to translate, if there is something wrong, I'm very sorry. :bq
It isn't your programing, it's your textures.
Eugh. I remembered this account existed and all I did.
I'm a better person now. Most likely to stay inactive.
Awesome community by the way y'all are peak 🗣️🗣️

The YouTube account isn't mine anymore by the way, a different family member uses it now.
User avatar
Jaforzem
Villager
Reactions:
Posts: 10
Joined: 04 Jul 2020, 21:51
Location: Mexico
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Car chains

Post by Jaforzem »

SmartSelect_20250930-110541_TheoTown.jpg
Hello, How can I stop it from gathering and there is one booth in front and one in the back?

Code: Select all    Reset

[ { "id": "$TLS1AT", "type": "car", "frames":[ {"bmp":"TLS1AT.png","count":4,"x":0,"w":11,"h":14} ], "v2": [ 2, 0, 2, 0], "moveable":false, "length":29, "auto colorize":true, "chargeable": false, "flag all": true }, { "id": "$TLS1AM", "type": "car", "frames":[ {"bmp":"TLS1AM.png","count":4,"x":0,"w":29,"h":21} ], "v2": [ -5, 1, -6, 0], "moveable":false, "length":29, "auto colorize":true, "chargeable": false, "flag all": true }, { "id": "$TLS1AF", "type": "car", "title":"TLS1A", "frames":[ {"bmp":"TLS1AF.png","count":4,"x":0,"w":11,"h":14} ], "flag all": true, "length": 29, "capacity":100, "moveable": false, "speed": 1.05, "auto colorize":true, "chargeable": false, "tail":["$TLS1AM", "$TLS1AT"], "meta": {"tags": {"short_distance_passenger_train": {}}}, "v2": [ 2, 0, 2, 0] } ]
JSON checker
Check
You do not have the required permissions to view the files attached to this post.
User avatar
JustAnyone
Honorary Contributor
Reactions:
Posts: 3664
Joined: 23 Jul 2017, 10:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: Car chains

Post by JustAnyone »

You'd generally add an empty car between them with "$car_null00"
User avatar
Jaforzem
Villager
Reactions:
Posts: 10
Joined: 04 Jul 2020, 21:51
Location: Mexico
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Car chains

Post by Jaforzem »

SmartSelect_20251001-102757_TheoTown.jpg
When I put $car_null00 in a side pass this (The cabin of front don't see well) and the other side pass this (The cabin of back don't see well)
SmartSelect_20251001-102823_TheoTown.jpg
This is my code

Code: Select all    Reset

[ { "id": "$TLS1AT", "type": "car", "frames":[ {"bmp":"TLS1AT.png","count":4,"x":0,"w":11,"h":14, "length":11} ], "v2": [ 4, 0, 4, 0], "moveable":false, "auto colorize":true, "chargeable": false, "flag all": true }, { "id": "$TLS1AM", "type": "car", "frames":[ {"bmp":"TLS1AM.png","count":4,"x":0,"w":29,"h":21, "length":25} ], "v2": [ -5, 1, -6, 0], "moveable":false, "auto colorize":true, "chargeable": false, "flag all": true }, { "id": "$TLS1AF", "type": "car", "title":"TLS1A", "frames":[ {"bmp":"TLS1AF.png","count":4,"x":0,"w":11,"h":14, "length":11} ], "flag all": true, "capacity":100, "moveable": false, "speed": 1.05, "auto colorize":true, "chargeable": false, "tail":["$car_null00", "$TLS1AM","$car_null00","$TLS1AT"], "meta": {"tags": {"short_distance_passenger_train": {}}}, "v2": [ 4, 0, 4, 0] } ]
JSON checker
Check
You do not have the required permissions to view the files attached to this post.
O
Ostrovsk
Townsman
Reactions:
Posts: 42
Joined: 13 Oct 2023, 16:31
Location: Rostov-on-Don
Plugins: Showcase Store
Version: Beta

Re: Car chains

Post by Ostrovsk »

:windows :android
Screenshot_2025-10-31-21-30-23-00_b9c7f85ab9c096b4378029bc61eaf2d6.jpg
Hello, how can you fix this style of bus? There is a $car_null00 between the parts, only the first and second frames have this problem, the third and fourth seem normal
You do not have the required permissions to view the files attached to this post.
Last edited by Ostrovsk on 31 Oct 2025, 20:11, edited 1 time in total.
User avatar
Jaforzem
Villager
Reactions:
Posts: 10
Joined: 04 Jul 2020, 21:51
Location: Mexico
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Car chains

Post by Jaforzem »

Hello, I was already able to solve the problem and what happened was that the frame size was incorrect, in my case it was too small
O
Ostrovsk
Townsman
Reactions:
Posts: 42
Joined: 13 Oct 2023, 16:31
Location: Rostov-on-Don
Plugins: Showcase Store
Version: Beta

Re: Car chains

Post by Ostrovsk »

[цитата=Jaforzem post_id=240754 время=1761948312 пользователь_id=24836]
Здравствуйте, я уже смог решить проблему и произошло то, что размер кадра был неправильным, в моем случае он был слишком мал
[/цитировать]
Hello, do you need the first, second and other parts of the transport to be the same size? For example, 15x15?
O
Ostrovsk
Townsman
Reactions:
Posts: 42
Joined: 13 Oct 2023, 16:31
Location: Rostov-on-Don
Plugins: Showcase Store
Version: Beta

Re: Car chains

Post by Ostrovsk »

JustAnyone wrote: 01 Oct 2025, 12:46 You'd generally add an empty car between them with "$car_null00"
Hello, where can I find the Json code for the Vanilla Accordion Bus?
O
Ostrovsk
Townsman
Reactions:
Posts: 42
Joined: 13 Oct 2023, 16:31
Location: Rostov-on-Don
Plugins: Showcase Store
Version: Beta

Re: Car chains

Post by Ostrovsk »

:android I don't know what to do and who to contact. I still did not understand how to make an elongated bus normally. I'm not even talking about my bus, I recreated a vanilla model of the bus, exactly like in the game, 3 and 4 frames are absolutely normal, perfect. But the first 2 frames have a hole between the parts. No matter how hard I try, it does not clean. I'll send photos and code
Screenshot_2025-11-15-21-07-45-69_b9c7f85ab9c096b4378029bc61eaf2d6.jpg
Screenshot_2025-11-15-21-07-38-63_b9c7f85ab9c096b4378029bc61eaf2d6.jpg
Screenshot_2025-11-15-21-07-32-17_b9c7f85ab9c096b4378029bc61eaf2d6.jpg
Screenshot_2025-11-15-21-07-26-29_b9c7f85ab9c096b4378029bc61eaf2d6.jpg
Screenshot_2025-11-15-21-07-19-18_b9c7f85ab9c096b4378029bc61eaf2d6.jpg
And here is my code:

[
{
"id":"Kamaz6299Popa",
"type":"car",
"author":"Ostrovsk",
"flag normal": false,
"flag bus": true,
"frames":[{"bmp":"Kamaz6299Popa.png","count":4,"w":14,"h":13}],
"v2": [ 2, 0, 3, 0 ],
"speed": 1
},
{
"id":"Kamaz6299Pered",
"type":"car",
"author":"Ostrovsk",
"flag normal": false,
"flag bus": true,
"meta": {"tags": {"ts_normal_bus": {}}},
"capacity": 175,
"requirements":[{"type": "RANK", "lvl": 3}],
"title":"Kamaz 6299 Harmonica[ru]Камаз 6299 Гармошка",
"frames":[{"bmp":"Kamaz6299Pered.png","count":4,"w":18,"h":15}],
"tail":["$car_null00","Kamaz6299Popa"],
"v2": [ 1, 0, 0, 1 ],
"speed": 1
}
]
You do not have the required permissions to view the files attached to this post.
Previous topicNext topic