LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

PlayerStateWalk

Parent
PlayerStateBase
Functions

canWalk

Description
Check if player is on the ground and he is not running
Definition
canWalk()
Return Values
booltrueif player can swim
Code
46function PlayerStateWalk:canWalk()
47 local isRunning = (self.player.inputInformation.runAxis ~= 0.0)
48
49 return self.player.baseInformation.isOnGround and not isRunning
50end

isAvailable

Description
Check if state is available
Definition
isAvailable()
Return Values
booltrueif player can swim
Code
28function PlayerStateWalk:isAvailable()
29 return self:canWalk()
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 PlayerStateWalk:new(player, stateMachine)
20 local self = PlayerStateBase:new(player, stateMachine, PlayerStateWalk_mt)
21
22 return self
23end

update

Description
Update method. Will deactivate if player is not moving anymore or if he starts running.
Definition
update(float dt)
Arguments
floatdtdelta time in ms
Code
35function PlayerStateWalk:update(dt)
36 local playerInputsCheck = ( self.player.inputInformation.moveForward ~= 0) or (self.player.inputInformation.moveRight ~= 0)
37
38 if not self:canWalk() or not playerInputsCheck then
39 self:deactivate()
40 end
41end