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
PlayerStateAnimalPet
ParentPlayerStateBaseFunctions
activate
DescriptionActivate methodDefinition
activate()Code
60 | function PlayerStateAnimalPet:activate() |
61 | PlayerStateAnimalPet:superClass().activate(self) |
62 | |
63 | if self.dog ~= nil then |
64 | self.dog:pet() |
65 | end |
66 | |
67 | self:deactivate() |
68 | end |
deactivate
DescriptionDeactivate methodDefinition
deactivate()Code
72 | function PlayerStateAnimalPet:deactivate() |
73 | PlayerStateAnimalPet:superClass().deactivate(self) |
74 | self.dog = nil |
75 | end |
isAvailable
DescriptionCheck if we can pet an animal.Definition
isAvailable()Return Values
bool | returns | true if player can pet an animal |
30 | function PlayerStateAnimalPet:isAvailable() |
31 | self.dog = nil |
32 | if self.player.isClient and self.player.isEntered and not g_gui:getIsGuiVisible() then |
33 | local playerHandsEmpty = self.player.baseInformation.currentHandtool == nil and not self.player.isCarryingObject |
34 | local dogHouse = g_currentMission:getDoghouse(self.player.farmId) |
35 | if dogHouse == nil then |
36 | return false |
37 | end |
38 | |
39 | local dog = dogHouse:getDog() |
40 | if dog == nil then |
41 | return false |
42 | end |
43 | |
44 | local _, playerY, _ = getWorldTranslation(self.player.rootNode) |
45 | playerY = playerY - self.player.model.capsuleTotalHeight * 0.5 |
46 | local deltaWater = playerY - self.player.waterY |
47 | local playerInWater = deltaWater < 0.0 |
48 | local playerInDogRange = dog.playersInRange[self.player.rootNode] ~= nil |
49 | |
50 | if playerHandsEmpty and not playerInWater and playerInDogRange then |
51 | self.dog = dog |
52 | return true |
53 | end |
54 | end |
55 | return false |
56 | 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 PlayerStateAnimalPet.new(player, stateMachine) |
20 | local self = PlayerStateBase.new(player, stateMachine, PlayerStateAnimalPet_mt) |
21 | |
22 | self.dog = nil |
23 | |
24 | return self |
25 | end |