Vehicle.holdPosition ▲ 41

Available from Easy Red 2 2.1.1

The vehicle stays where it is, as a sentinel, within radius metres of its current position. Same as moveTo with the vehicle's own position.


Return value

Return TypeDescription
voidTrue if the order was given. False when a player is at the wheel, on planes, or when nobody is aboard.

Parameters

ParameterTypeDescription
1NumberHow far from the current position the vehicle may wander, in metres. Optional, 5 by default.

Examples

Vehicle as a sentinel

-- the nearest tank to the crossroads parks there and guards it
local crossroads = vec3(412, 31, 870)
local tank = er2.getNearestVehicle(crossroads, 300)
if tank ~= nil then
    if tank:moveTo(crossroads, 4) then
        er2.print("The tank is moving to the crossroads")
    end
end

-- later: let the crew follow its own orders again
-- tank:getLeader():getSquad():followLeader()

Back to Scripting API