Car Updated

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Kiki012
Inhabitant of a Megacity
Reactions:
Posts: 207
Joined: Mon Jan 06, 2020 9:57
Location: No one care
Plugins: Show
Version: Beta

Plugin Creator

Platform

Car Updated

#1

Post by Kiki012 »

this. Tutorial is incomplete,find original tutorial for moment
Hello there, I'm recreating car and car chain tutorial
Car code basically looks like:

Code: Select all    Reset

[ { "type":"car", "speed":1.0, "v2":true, "frames":[ { "bmp":"img.png", "count":4, "w":20, "h":20 } ] } ]
JSON checker
Check
You will notice that I provide 4 frames here. That's needed as we need a frame (image) for each direction in which the car can drive. We indexed the directions as followed:
image.png
image.png (3.11 KiB) Viewed 83 times


So example car frames looks like:
image (1).png
image (1).png (1007 Bytes) Viewed 83 times
Notice how we load 4 frames from a single image by providing the width and height of each frame and the number of frames we want to extract. The plugin loader will automatically load "count" many frames of the given width and height from left to right out of the provided image. You can provide multiple cars within a single plugin by just providing more frames. The total number of frames has to be a multiple of 4.

It's worth to mention that "v2":true indicates that we want to use the second generation of car loading. We recommend that as it's much easier to use and takes less expensive texture space. However, a lot of cars are still internally defined using the old system. The provided frames there have to look like that:
image (2).png
image (2).png (638 Bytes) Viewed 83 times
We can do that by defining a car spawner with the following attributes:
• cars - An array of car ids
• radius - Radius for the cars to be spawned. Big radius are heavy on computation, so try to avoid them. To cover the whole map you might use a value like 512
• count - Number of cars that should be spawned
• targets - An array of building ids that should be targeted by spawned cars. If empty, any buildings will be
• targeted (default behavior). Entry null will represent the building in which the car spawner is defined (for convenience).

So spawner code looks like:

Code: Select all    Reset

"car spawner":[ { "cars":["$lobby_carplugin00"], "radius":10, "count":5 } ]
JSON checker
Check
Place it on building code,such as example Plugin

You can add some stuff such as:

Code: Select all    Reset

[ { "type":"car", "speed":1.0, "v2":true, "frames":[ { "bmp":"img.png", "count":4, "w":20, "h":20 } ], "capacity":10,//capacity for car "flag bus":true,//flag usefull for making train tram bus or others "frames per car":4,//usefull if you use multiple frames require atleast 2 frames "tail":["carid"]//usefull if you want make train or trams } ]
JSON checker
Check
Override in game car is possible see this

Find in game car id on JSON,but for example:
$carres00
$carres01
$carres02
$carind00
$carind01
$carind02
$carfirebrigade00
$carpolice00
$carbus00
$carswat00
$tank00
$mltry_truck00
$carmedic00

In game car frames:
image (4).png
image (4).png (22.64 KiB) Viewed 83 times
For someone else who want make long train
PARTB.png
PARTB.png (935 Bytes) Viewed 91 times
PARTA.png
PARTA.png (934 Bytes) Viewed 91 times
this two image owned by me, please credit!

credit: theo & lobby
Image...image credits:here!
Finishing my jobs

Return to “Tutorials and Documentation”