Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- PlayerStateAnimalInteract
- PlayerStateAnimalPet
- PlayerStateAnimalRide
- PlayerStateBase
- PlayerStateCrouch
- PlayerStateCycleHandtool
- PlayerStateDrop
- PlayerStateFall
- PlayerStateIdle
- PlayerStateJump
- PlayerStateMachine
- PlayerStatePickup
- PlayerStateRun
- PlayerStateSwim
- PlayerStateThrow
- PlayerStateUseLight
- PlayerStateWalk
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
PlayerStateAnimalInteract
ParentPlayerStateBaseFunctions
activate
DescriptionActivate method. If animal is a dog, we pet him.Definition
activate()Code
68 | function PlayerStateAnimalInteract:activate() |
69 | PlayerStateAnimalInteract:superClass().activate(self) |
70 | |
71 | if self.dog ~= nil then |
72 | if self.dog.entityFollow == self.player.rootNode then |
73 | self.dog:goToSpawn() |
74 | else |
75 | self.dog:followEntity(self.player) |
76 | end |
77 | |
78 | self:deactivate() |
79 | |
80 | else |
81 | if self.husbandry ~= nil and self.cluster ~= nil then |
82 | g_client:getServerConnection():sendEvent(AnimalCleanEvent.new(self.husbandry, self.cluster.id)) |
83 | g_soundManager:playSample(self.player.model.soundInformation.samples.horseBrush) |
84 | self:deactivate() |
85 | end |
86 | end |
87 | end |
deactivate
DescriptionDeactivate methodDefinition
deactivate()Code
91 | function PlayerStateAnimalInteract:deactivate() |
92 | PlayerStateAnimalInteract:superClass().deactivate(self) |
93 | self.dog = nil |
94 | self.husbandry = nil |
95 | self.cluster = nil |
96 | end |
isAvailable
DescriptionCheck if we can interact with an animal.Definition
isAvailable()Return Values
bool | returns | true if player can interact with an animal |
34 | function PlayerStateAnimalInteract:isAvailable() |
35 | self.dog = nil |
36 | |
37 | if self.player.isClient and self.player.isEntered and not g_gui:getIsGuiVisible() then |
38 | local playerHandsEmpty = self.player.baseInformation.currentHandtool == nil and not self.player.isCarryingObject |
39 | local dogHouse = g_currentMission:getDoghouse(self.player.farmId) |
40 | if playerHandsEmpty and dogHouse ~= nil then |
41 | local dog = dogHouse:getDog() |
42 | if dog ~= nil and dog.playersInRange[self.player.rootNode] ~= nil then |
43 | self.dog = dog |
44 | if dog.entityFollow == self.player.rootNode then |
45 | self.interactText = g_i18n:getText("action_interactAnimalStopFollow") |
46 | else |
47 | self.interactText = g_i18n:getText("action_interactAnimalFollow") |
48 | end |
49 | |
50 | return true |
51 | end |
52 | end |
53 | end |
54 | |
55 | self:detectAnimal() |
56 | |
57 | if self.husbandry ~= nil then |
58 | self.interactText = string.format(g_i18n:getText("action_interactAnimalClean"), self.cluster:getName()) |
59 | return true |
60 | end |
61 | |
62 | self.interactText = "" |
63 | return false |
64 | end |
new
DescriptionCreating instance of state.Definition
new(table player, table stateMachine)Arguments
table | player | instance of player |
table | stateMachine | instance of the state machine manager |
table | instance | instance of object |
19 | function PlayerStateAnimalInteract.new(player, stateMachine) |
20 | local self = PlayerStateBase.new(player, stateMachine, PlayerStateAnimalInteract_mt) |
21 | |
22 | self.dog = nil |
23 | self.husbandry = nil |
24 | self.cluster = nil |
25 | |
26 | self.castDistance = 1.5 -- in m |
27 | self.interactText = "" |
28 | return self |
29 | end |
update
DescriptionUpdate methodDefinition
update(float dt)Arguments
float | dt | delta time in ms |
110 | function PlayerStateAnimalInteract:update(dt) |
111 | self:detectAnimal() |
112 | end |