Jump to content

Vehicles list


Maris

Recommended Posts

  • 2 weeks later...

I am not sure how to list all vehicles in the world, but I do know how to list vehicles near your cell.

 

Try one of these list of methods:

  • getCell():getVehicles()
  • getWorld():getCell():getVehicles()

 

Both should return an ArrayList java object full of vehicles in the IsoCell that the player is in.

 

-- Returns an ArrayList of vehicles near the player's cell that they are in.
local function getVehicles()
	local cell = getCell();
	local vehicles = cell:getVehicles();
	
	return vehicles;
end

-- Returns an ArrayList of vehicles near the player's cell that they are in.
local function getVehiclesIsoWorld()
	local world = getWorld();
	local cell = world:getCell();
	local vehicles = cell:getVehicles();
	
	return vehicles;
end

 

I'm not sure how to put rust on vehicles. That's out of my coding scope for now. But maybe this might help. Good luck!

local function addRustToVehicles()
	local world = getWorld();
	local cell = world:getCell();
	local vehicles = cell:getVehicles();
	
	local size = vehicles:size();
	for i=0, size - 1 do
		local vehicle = vehicles:get(i);
		
		-- Put rust on vehicle somehow?
		
		
	end
	
end

 

 

Here's the methods I was using.

 

getWorld()

image.thumb.png.b9c54b6a451af5ceac890c4f16c653f0.png

 

IsoWorld:getCell()

image.thumb.png.146b706f66d52587b188854af7c5913a.png

 

getCell()

image.thumb.png.7f3d240358cf0b5e6a113fd5bd3bc383.png

 

IsoCell:getVehicles()

image.thumb.png.4f7acd986da38e93baf276ec58f73afc.png

Edited by ATPHHe
small modification to lua code for addRustToVehicles() function
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...