Cloning road vehicle.

Discuss the new AI features ("NoAI") introduced into OpenTTD 0.7, allowing you to implement custom AIs, and the new Game Scripts available in OpenTTD 1.2 and higher.

Moderator: OpenTTD Developers

Post Reply
User avatar
lukasz1985
Route Supervisor
Route Supervisor
Posts: 436
Joined: 27 Mar 2013 08:58
Location: Poland
Contact:

Cloning road vehicle.

Post by lukasz1985 »

I'm trying to clone a road vehicle and I don't know if there's is something I can't understand or it is a bug.

I've got the following code

Code: Select all

class eco.Vehicle {
	vehicle_id = null;
	engine_id = null;
	
	constructor(vehicle_id) {
		this.vehicle_id = vehicle_id;
	}
	
	function GetLocation() {
		local tile_index = GSVehicle.GetLocation(vehicle_id);
		local tile = Tile(tile_index);
		return tile;
	}
	function GetOwner() {
		return GSVehicle.GetOwner(vehicle_id);
	}
	
	function Clone(depot_tile_index) {
		local company = GSCompanyMode(GetOwner());
		local id = GSVehicle.CloneVehicle(depot_tile_index, vehicle_id, true );
		GSLog.Info( "isvalid: " +GSVehicle.IsValidVehicle(id));
		
	}
}
Calling the method "Clone" with a correct tile with depot tile_index doesn't spawn the vehicle.

The line GSLog.Info( "isvalid: " +GSVehicle.IsValidVehicle(id)); says it(the vehiclle) is valid but no real effect. I've tried also using GSExecMode() with nothing happening.

Any suggestions and help would be appreciated.
ImageImage
User avatar
lukasz1985
Route Supervisor
Route Supervisor
Posts: 436
Joined: 27 Mar 2013 08:58
Location: Poland
Contact:

Re: Cloning road vehicle.

Post by lukasz1985 »

Oh nevermind it works :)
ImageImage
Post Reply

Return to “OpenTTD AIs and Game Scripts”

Who is online

Users browsing this forum: No registered users and 12 guests