LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

PlayerStateFall

Parent
PlayerStateBase
Functions

isAvailable

Description
Check if state is available. If player is not on the ground and is not in water and vertical velocity lower than
Definition
isAvailable()
Return Values
booltrueif state is available
Code
28function PlayerStateFall:isAvailable()
29 local isOnGround = self.player.baseInformation.isOnGround
30 local isInWater = self.player.baseInformation.isInWater
31 local verticalVelocity = self.player.motionInformation.currentSpeedY
32
33 if not isOnGround and not isInWater and (verticalVelocity < self.player.motionInformation.minimumFallingSpeed) then
34 return true
35 end
36 return false
37end

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 PlayerStateFall:new(player, stateMachine)
20 local self = PlayerStateBase:new(player, stateMachine, PlayerStateFall_mt)
21
22 return self
23end

update

Description
Update method. Will deactivate when player hits the ground or is in water
Definition
update(float dt)
Arguments
floatdtdelta time in ms
Code
42function PlayerStateFall:update(dt)
43 local isOnGround = self.player.baseInformation.isOnGround
44 local isInWater = self.player.baseInformation.isInWater
45
46 if isOnGround or isInWater then
47 self:deactivate()
48 end
49end