LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

PlayerStateSwim

Parent
PlayerStateBase
Functions

isAvailable

Description
Check if state is available if player is in water
Definition
isAvailable()
Return Values
booltrueif player can swim
Code
29function PlayerStateSwim:isAvailable()
30 local isInWater = self.player.baseInformation.isInWater
31
32 if isInWater then
33 return true
34 end
35 return false
36end

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

update

Description
Update method. Will deactivate if player is not in water anymore
Definition
update(float dt)
Arguments
floatdtdelta time in ms
Code
41function PlayerStateSwim:update(dt)
42 if not self.player.baseInformation.isInWater then
43 self:deactivate()
44 end
45end