LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

PlayerStateRun

Parent
PlayerStateBase
Functions

canRun

Description
Check that player is on the ground.
Definition
canRun()
Return Values
booltrueif player can run
Code
46function PlayerStateRun:canRun()
47 return self.player.baseInformation.isOnGround
48end

isAvailable

Description
Check if state is available.
Definition
isAvailable()
Return Values
booltrueif player can run
Code
28function PlayerStateRun:isAvailable()
29 return self:canRun()
30end

new

Description
Creating instance of state.
Definition
new(table player, table stateMachine)
Arguments
tableplayerinstance of player
tablestateMachineinstance of the state machine manager
Return Values
tableinstanceinstance of object
Code
19function PlayerStateRun:new(player, stateMachine)
20 local self = PlayerStateBase:new(player, stateMachine, PlayerStateRun_mt)
21
22 return self
23end

update

Description
Update method. Will deactivate if player stops moving, is not on the ground or if the run input is not pressed.
Definition
update(float dt)
Arguments
floatdtdelta time in ms
Code
35function PlayerStateRun:update(dt)
36 local playerInputsCheck = (self.player.inputInformation.runAxis ~= 0.0) and (( self.player.inputInformation.moveForward ~= 0) or (self.player.inputInformation.moveRight ~= 0))
37
38 if (self:canRun() == false) or (playerInputsCheck == false) then
39 self:deactivate()
40 end
41end