Vehicles
DefineVehicle makes a car out of the game’s Catamount, in OnLoaded; SpawnVehicle places one:
DefineVehicle( new PluginVehicle { Name = "Rally", Base = "Catamount", TopSpeed = 90f, Tint = "#8a1408" } );var car = SpawnVehicle( "Rally", position, yaw );| Helper | Does |
|---|---|
DefineVehicle( vehicle ) |
Add a car to the game: the console command vehicle.spawn Rally places it too |
SpawnVehicle( name, position, yaw ) |
Place a car, yours or "Catamount", facing yaw (degrees, 0 = +X). Returns its Vehicle, null for an unknown name (with a warning in the console) |
RemoveVehicle( vehicle ) |
Remove a car, any car, without a wreck. Its driver gets out first |
PluginVehicle |
|
|---|---|
Name, Base |
Its name (64 characters at most), and the car it is made from: "Catamount" (also when empty), or a car of a plugin that loaded before this one (plugins load in file name order). Any other base: a warning in the console and the car is not defined |
Model |
Its body: a model package of the s&box cloud (see Models and sounds from the s&box cloud) or a model path of the game; empty: the base’s. Until the package is downloaded, the car shows the Catamount’s body. Its collision is the model’s bounding box, and the Catamount’s wheels, seat and lights are moved in proportion to it. Pick a model facing +X, about the size of a car: each side of that box is kept between a quarter and four times the Catamount’s. A model that does not load leaves the Catamount’s body, with a warning in the console |
Tint |
A colour on its body, "#rrggbb". The Catamount’s black body is repainted all in it (its stripes go); it shows brighter than its code (the Rally’s #8a1408 is orange). Over a Skin it is multiplied onto the skin instead |
Skin |
A skin of the game for the Catamount’s body: "rust" or "flames" (placeholders for now, the same names will get the final paint), any case. Empty: the base’s. A name the game does not know: no skin, the black paint (not the base’s skin). A cloud Model keeps its own look. The car still goes grey as it is damaged, and its wreck looks like every other |
Icon |
Its picture on its tiles in the admin menu (World tab, VEHICLES): an image address (see Images). Empty: the base’s; a car made from the Catamount without one shows a ? |
Health |
0: the base’s (Catamount 800) |
TopSpeed |
The engine’s top speed setting, m/s (Catamount 71.5), 1 to 150 |
Mass |
kg (Catamount 1500), 100 to 20000 |
MaxTurn, MinTurn |
Steering angle in degrees at low and at top speed (Catamount 15 and 10), 1 to 60 |
EngineSound |
A sound name of the game (Catamount "car_engine"); an unknown name is silent |
RepairItem, RepairAmount |
The item that repairs it (players hold E next to it), by its title (Catamount "Metal Fragments"), and how many of it repair it from 0 to full (Catamount 50), 1 to 10000. A game item only: a plugin’s custom item (DefineItem) is not found. A title that is no item: it cannot be repaired |
0 or empty keeps the base’s value, and a value out of range is brought back in range: a car stays drivable whatever the
numbers. On a Vehicle: Name, Health, MaxHealth, Driver (a RustPlayer, null when empty), WorldPosition,
Eject() (the driver gets out).
Cars stay when the plugins restart and are saved with the world. Each car carries its whole definition: if the plugin is removed, the cars already out keep their model, color and speed, and only new ones can no longer be spawned.