LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

PlayerStateAnimalFeed

Parent
PlayerStateBase
Functions

activate

Description
Activate method
Definition
activate()
Code
45function PlayerStateAnimalFeed:activate()
46 PlayerStateAnimalFeed:superClass().activate(self)
47 local dogHouse = g_currentMission:getDoghouse(self.player.farmId)
48 if dogHouse ~= nil and dogHouse.dog ~= nil then
49 dogHouse.dog:feed()
50 end
51 self:deactivate()
52end

deactivate

Description
Deactivate method
Definition
deactivate()
Code
56function PlayerStateAnimalFeed:deactivate()
57 PlayerStateAnimalFeed:superClass().deactivate(self)
58 self.isDog = false
59end

isAvailable

Description
Check if we can feed an animal.
Definition
isAvailable()
Return Values
boolreturnstrue if player can feed an animal
Code
29function PlayerStateAnimalFeed:isAvailable()
30 self.isDog = false
31 if self.player.isClient and self.player.isEntered and not g_gui:getIsGuiVisible() then
32 local playerHandsEmpty = self.player.baseInformation.currentHandtool == nil and not self.player.isCarryingObject
33 local dogHouse = g_currentMission:getDoghouse(self.player.farmId)
34
35 if playerHandsEmpty and dogHouse ~= nil and dogHouse.isActivatable and dogHouse.dog ~= nil and not getVisibility(dogHouse.foodNode) then
36 self.isDog = true
37 return true
38 end
39 end
40 return false
41end

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 PlayerStateAnimalFeed:new(player, stateMachine)
20 local self = PlayerStateBase:new(player, stateMachine, PlayerStateAnimalFeed_mt)
21
22 self.isDog = false
23 return self
24end