-
Notifications
You must be signed in to change notification settings - Fork 0
Mission
MISSION
is the global variable containing mission data from the MissionData
class adapted to Lua.
and this class share A LOT of methods, so if you want to learn how to use them faster use these examples here.
missionData
(PROTECTED) - A userdata that contains mission data.
missionSummary
- A userdata containing summary data of the mission.
No Mission Objects are included, just actors that are adapted with automatic Mission Objects through the Lua compiler.
-
LuaMissionScript
(MISSION
) -
Actor
: A actor in actor definitions -
Node
: A logic node in node definitions -
CollectionOfWires
: Wire collection containing wire nodes -
MissionSummary
(MISSION.missionSummary
)
List of functions for the class LuaMissionScript
(MISSION
) below, with some examples to let you knowing how to use it properly.
All these functions might create internally and return a Node
of the type of the created node,
Otherwise a error if invalid arguments were inputed.
This function allows you create a collection of wires (wire collection) to the mission data.
Returns:
-
CollectionOfWires
empty or containing empty nodes (depending in nWires).
Optional Parameters:
- nWires : number of wires you want to instantiate in the same collection of wires
MISSION.LogicStart("Example Sample - Custom Collection of Wires").wireCollection = MISSION.CreateWireCollection()
This node is fired when the game has loaded the mission,
Basically a initialization node.
Returns:
-
Node
class of this type of node.
Optional Parameters:
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
local LogicStart = MISSION.LogicStart("Example Sample - LogicStart")
-- Debug text (equivalent to print() function, but Driv3r disabled debug text)
LogicStart.wireCollection.Add(MISSION.DebugText("Hello, World!")) -- adds functionality to LogicStart
ActorCreation(Actor actor, [ int activity=1, int flags=0, string note = "", int r = 0, int g = 200, int b = 122)
Spawns a actor in the actor list that hasn't spawned yet,
This is applied when the first digit of your actor's flag is set to 1
.
Pretty useful for actors that can't be created by this flag or mostly used when you want to make actors spawn in a specific point.
Returns:
-
Node
class of this type of node. - Otherwise: A error if the inputed actor is invalid.
Required Parameters:
- actor : The actor to spawn.
Optional Parameters:
- activity : A number representing the type of activity to spawn the inputed actor. (1 = spawn, 2 = despawn)
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
The example below spawns an actor that wasn't initially spawned yet.
-- Let's say we have UnspawnedActor as our target actor
-- And that this actor's first digit of the flags property is set to 0
local LogicStart = MISSION.LogicStart("Example Sample - Actor Creation")
-- Creates the actor that hasn't been spawned by the game yet.
LogicStart.wireCollection.Add(MISSION.ActorCreation(UnspawnedActor))
Despawns an actor that is spawned in the game. this function is automatic, derivated from function ActorCreation
.
Returns:
-
Node
class of this type of node.
Required Parameters:
- actor : The actor to spawn.
Optional Parameters:
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
A timer node that works like a thread sleep function
Returns:
-
Node
class of this type of node.
Required Parameters:
- interval : The interval time of the timer (in seconds).
Optional Parameters:
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
local LogicStart = MISSION.LogicStart("Example Sample - Timer")
local Timer = MISSION.Timer(4.5) -- 4 seconds and 500 miliseconds timer
LogicStart.wireCollection.Add(Timer) -- adds it's functionality to the logic start
-- displays a message to the player
Timer.wireCollection.Add(MISSION.DisplayMessage(0,5))
A disabled function to the game, if you want to debug text with this function you better use it in Driv3r Xbox Press Demo.
Returns:
-
Node
class of this type of node.
Required Parameters:
- message : A string of the message you want to show in-game as a debug text.
Optional Parameters:
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
local LogicStart = MISSION.LogicStart("Example Sample - DebugText")
LogicStart.wireCollection.Add(MISSION.DebugText("Hello, World!")) -- adds the debug text to the logic start.
DisplayMessage(int localisedStringId,int duration,int priority = 100, int flags = 65536, string note = "DisplayMessage()", int r = 55, int g = 255, int b = 0)
Creates a node that displays a message to the player. The message must be a localised string ID.
Returns:
-
Node
class of this type of node.
Required Parameters:
- localisedStringId : A number representing the ID of a localised string.
- duration : Duration of the message (in seconds).
Optional Parameters:
- priority : The priority of this message.
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
local LogicStart = MISSION.LogicStart("Example Sample - DisplayMessage")
LogicStart.wireCollection.Add(MISSION.DisplayMessage(0,5))
Controls the type of music that is playing in-game.
Returns:
-
Node
class of this type of node.
Required Parameters:
- type : The type of music (0 = muted, 1 = normal, 2 = chase, 3 = fade).
Optional Parameters:
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
The example below plays the chase music in the game.
local LogicStart = MISSION.LogicStart("Example Sample - MusicControl")
LogicStart.wireCollection.Add(MISSION.MusicControl(2)) -- Set music type to chase type
FadeIn(float duration=0.3f,byte R = 0, byte G = 0, byte B = 0, byte A = 0, string note = "FadeIn()", int r = 255, int g = 200, int b = 128)
Fades in screen, this is a automatic function derivated from FadeControl
which is why FadeControl
isn't present here.
Counterpart: FadeOut
Returns:
-
Node
class of this type of node.
Optional Parameters:
- duration : The duration of the fade animation.
- R : The amount of red to the fade color.
- G : The amount of green to the fade color.
- B : The amount of blue to the fade color.
- A : The amount of alpha to the fade color.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
FadeOut(float duration=0.3f,byte R = 0, byte G = 0, byte B = 0, byte A = 0, string note = "FadeOut()", int r = 255, int g = 200, int b = 128)
Fades out screen, this is a automatic function derivated from FadeControl
which is why FadeControl
isn't present here.
Counterpart: FadeIn
Returns:
-
Node
class of this type of node.
Optional Parameters:
- duration : The duration of the fade animation.
- R : The amount of red to the fade color.
- G : The amount of green to the fade color.
- B : The amount of blue to the fade color.
- A : The amount of alpha to the fade color.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
FailMission(int message, [ float failDelay = 2.0f, int flags = 0, string note = "", int r = 0, int g = 200, int b = 122)
Fails the mission.
Returns:
-
Node
class of this type of node.
Required Parameters:
- message : A number representing the ID of a localised string.
Optional Parameters:
- failDelay : The time in seconds given to show you mission failed menu.
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
This example fails the mission when the player is dead
-- Let's say the variable "Player" is a actor and exists in your mission
local playerIsDead = MISSION.CharacterHasDied(Player)
playerIsDead.wireCollection.Add(MISSION.FailMission(0)) -- fail the mission
Completes the mission, depending on your mission it can play part 1, 2, 3, etc. of your mission until it's complete.
Optional Parameters:
- nodelay : The boolean representing if the mission will be complete instantly or not.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
CopControl(int chasers, [ int type=1, int aggresion=5, int armor=2, int goonWeapon1=1, int goonWeapon2=0, int goonWeapon3=0, int flags = 524290, string note = "", int r = 0, int g = 200, int b = 122)
Controls the density of the police/pursuers in the game.
Returns:
-
Node
class of this type of node.
Required Parameters:
- chasers : Number of max pursuers.
Optional Parameters:
- type : The type of pursuers
- aggresion
- armor
- goonWeapon1
- goonWeapon2
- goonWeapon3
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
CivilianTrafficControl(float pingInRadius = 130, float pingOutRadius = 135, int density = 0, int parkedCarDensity = 0, int attractorParkedCarDensity = -3, int flags = 65536, string note = "", int r = 0, int g = 200, int b = 122)
Controls the density of civilians who are driving in traffic.
Returns:
-
Node
class of this type of node.
Required Parameters: There are no required parameters for this function.
Optional Parameters:
- pingInRadius : The distance where the civilians will spawn.
- pingOutRadius : The distance where the civilians will despawn.
- density : The density type you want to control.
- parkedCarDensity : The parked cars density type you want to control.
- attractorParkedCarDensity : The attractor parked cars density type you want to control.
- flags : A number containing extra information for this definition.
- note : A note you want to add to this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
CreateCharacter(float x, float y, float z, float angle, int role, string personality, int personalityId, int personalityIndex, float health, float felony, int weapon, float vulnerability, [ string note="", int flags = 131073, byte r = 0,byte g = 155,int b = 200)
Creates a actor of the type of Character.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- x,y,z : The position of this character.
- angle : The angle that this character is facing in degrees.
- personality : A string containing the name of the personality of this character.
- personalityId : The personality ID of this character.
- personalityIndex : The personality index of this character.
- health : The amount of health of this character from 0 to 1.
- felony : The amount of felony (crime) of this character. (only affects player)
- weapon : A number representing the ID of a weapon's ID.
- vulnerability : Vulnerability of your character. (lower = stronger this character is, higher = weaker this character is)
Optional Parameters:
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
This example creates the player
local Player = MISSION.CreateCharacter(-1894.65, 1, -453.17, 0, 1, "Player", -1, -1, 1.0, 0.0, 0, 1.0)
CreateVehicle(float x, float y, float z, float angle, int vehicleId, int colorId, [ string note="", int flags = 302186497, float damage = 0, float softness=1, float weight=1f, float fragility=1, int r = 0, int g = 200, int b = 122)
Creates a actor of the type of Vehicle.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- x,y,z : The position of this vehicle.
- angle : The angle that this vehicle is facing in degrees.
- vehicleId : A number that represents the ID of a vehicle type.
- colorId : the ID of the color of this vehicle.
Optional Parameters:
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- damage : A number from 0 to 1 defining the damage of this vehicle. (basically a percentage)
- softness : The weakness of this vehicle.
- weight : The weight of this vehicle
- fragility: Amount of how the parts of the vehicle comes to break easily.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
This example creates a Ford Bruiser in downtown.
local Vehicle = MISSION.CreateVehicle(-836.8671, 0.5190547, 1486.318, 0, 0x6, 0, "Vehicle")
CreateCharacterInVehicle(Actor vehicle, int role, string personality, int personalityId, int personalityIndex, float health, float felony, int weapon, float vulnerability, float sx = 0, float sy = 0, float sz = 0, byte seatType = 2, string note = "", int flags = 131073, byte r = 0, byte g = 155, int b = 200)
Creates a actor of the type of Character in a vehicle.
From: CreateCharacter
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- vehicle : The vehicle to put this character in.
- personality : A string containing the name of the personality of this character.
- personalityId : The personality ID of this character.
- personalityIndex : The personality index of this character.
- health : The amount of health of this character from 0 to 1.
- felony : The amount of felony (crime) of this character. (only affects player)
- weapon : A number representing the ID of a weapon's ID.
- vulnerability : Vulnerability of your character. (lower = stronger this character is, higher = weaker this character is)
Optional Parameters:
- sx,sy,sz : The seat offset where this character is sitting relative to the vehicle.
- seatType : The type of the seat the character is sitting down. (1 = one-handed wheel, 2 = two-handed wheel, 3 = heavy vehicle, 10 = passenger)
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
This example creates the player in a '69 Bruiser with a generic seat offset.
local Vehicle = MISSION.CreateVehicle(-836.8671, 0.5190547, 1486.318, 0, Vehicle.Mustang_Grey, 0, "Vehicle")
local Player = MISSION.CreateCharacterInVehicle(Vehicle, 0, 1, "Player", -1, -1, 1.0, 0.0, 0, 1.0, -0.1, -0.1, 0.1, 1)
CreateCollectable(float x, float y, float z, int type, int clips, [ float rotation = 0, string note = "", int flags = 1, byte r = 200, byte g = 0, int b = 255)
Creates a collectable, a item that you can collect in the game.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- x,y,z : The coordinates to spawn this collectable.
- type : A number to the type of this collectable, a list of collectable types can be seen here.
Optional Parameters:
- rotation : The pitch axis of this collectable in radians, you can convert degrees to radians via
math.rad(deg)
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
This example creates a machine gun like if it was lying down in the ground.
local machineGun = CreateCollectable(0,0,0, COLLECTABLE_MG, math.rad(90), "Machine Gun")
CreateObjectiveIcon(float x, float y, float z, [ int height = 1, int maxAdaptiveHeight = 0, int type = 0, bool canGoUp = true, string note = "", int r = 255, int g = 200, int b = 122)
Creates a objective icon in your minimap.
NOTE: Use ActorCreation()
to spawn actors of this type.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- x,y,z : The coordinates to spawn this objective icon.
Optional Parameters:
- height : The minimum height that this objective arrow can go from.
- maxAdaptiveHeight : The maximum height the objective arrow can go to.
- type : The type of objective icon.
- canGoUp : A boolean if the objective arrow can go up depending of the distance of the player.
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
CreateObjectiveIconAttachedTo(Actor actor, [ int height = 1, int maxAdaptiveHeight = 0, int type = 0, bool canGoUp = true, string note = "", int r = 255, int g = 200, int b = 122)
Creates a objective icon attached to an valid actor in your minimap. This function is derivated from CreateObjectiveIcon
NOTE: Use ActorCreation()
to spawn actors of this type.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- actor : The actor this objective icon is attached to.
Optional Parameters:
- height : The minimum height that this objective arrow can go from.
- maxAdaptiveHeight : The maximum height the objective arrow can go to.
- type : The type of objective icon.
- canGoUp : A boolean if the objective arrow can go up depending of the distance of the player.
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
CreateCamera(float x, float y, float z, double pitch, double yaw, double roll, [ float cameraZoom = 1, float speed = 1, float blur = 0, Actor lookAt = null, Actor attachTo = null, string note = "", int flags = 0, byte r = 0, byte g = 155, int b = 200)
Creates a cutscene camera that can be used with CameraSelect()
method.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- x,y,z : The coordinates of this camera, depending on the optional parameter "attachTo" the coordinates are relative.
- pitch,yaw,roll : The rotation of this camera.
Optional Parameters:
- cameraZoom : The zoom defined to this camera from 1 to any.
- speed : The game's speed when the camera is in use.
- blur : The amount of motion-blur when the camera is in use.
- lookAt : The actor to the camera to look to.
- attachTo : The actor that this camera will be attached to.
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
No example available for this function.
CameraSelect(Actor target, int cameraType, [ float duration = 0, float blendTime = 0, float thrillCamZoom = 1, float thrillCamSpeed = 1, float thrillCamBlur = 0, int flags = 0, string note = "CameraSelect()", int r = 128, int g = 0, int b = 255)
Selects a cinematic camera set.
Returns:
-
Actor
class of this type of node. - Otherwise: A error if arguments are invalid.
Required Parameters:
- target : The camera's target depending on the
cameraType
parameter. - cameraType : The type of camera to be selected, you can use 1 for cinematic camera
Optional Parameters:
- cameraZoom : The zoom defined to this camera from 1 to any.
- speed : The game's speed when the camera is in use.
- blur : The amount of motion-blur when the camera is in use.
- lookAt : The actor to the camera to look to.
- attachTo : The actor that this camera will be attached to.
- note : A note you want to add to this definition.
- flags : A number containing extra information for this definition.
- r : The amount of red to the color of this definition.
- g : The amount of green to the color of this definition.
- b : The amount of blue to the color of this definition.
The example below creates a camera that spins around the player.
local firstSel = nil
local prevSel = nil
local spinSpeed = 0.5
local spinDuration = 0.1
local cameraDistance = 10.0
local cameraHeight = 1.5
local lookAtPlayer = true
for angle = 0, 360, 10 do
local ang = math.rad(angle)
local camera = MISSION.CreateCamera(math.sin(ang)*cameraDistance,cameraHeight,math.cos(ang)*cameraDistance, 0,lookAtPlayer and 0 or angle,0, 1, 1.0, 0, lookAtPlayer and Player or nil, Player)
local sel = MISSION.CameraSelect(camera, 1, spinDuration/spinSpeed, spinDuration/spinSpeed, 1, 1, 0, 0x2)
if (prevSel == nil) then
firstSel = sel
LogicStart.Wires.Add(sel)
else
prevSel.Wires.Add(sel)
end
prevSel = sel
if (angle>=360) then
sel.Wires.Add(firstSel)
end
end