Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Player
- PlayerModelManager
- PlayerPickUpObjectEvent
- PlayerSetFarmAnswerEvent
- PlayerSetFarmEvent
- PlayerSetHandToolEvent
- PlayerStateActivateObject
- PlayerStateAnimalFeed
- PlayerStateAnimalInteract
- PlayerStateAnimalPet
- PlayerStateAnimalRide
- PlayerStateBase
- PlayerStateCrouch
- PlayerStateCycleHandtool
- PlayerStateDrop
- PlayerStateFall
- PlayerStateIdle
- PlayerStateJump
- PlayerStateMachine
- PlayerStatePickup
- PlayerStateRun
- PlayerStateSwim
- PlayerStateThrow
- PlayerStateUseLight
- PlayerStateWalk
- PlayerStyle
- PlayerSwitchedFarmEvent
- PlayerTeleportEvent
- PlayerThrowObjectEvent
- PlayerToggleLightEvent
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
PlayerStateAnimalPet
ParentPlayerStateBaseFunctions
activate
DescriptionActivate methodDefinition
activate()Code
49 | function PlayerStateAnimalPet:activate() |
50 | PlayerStateAnimalPet:superClass().activate(self) |
51 | local dogHouse = g_currentMission:getDoghouse(self.player.farmId) |
52 | if dogHouse ~= nil and dogHouse.dog ~= nil then |
53 | dogHouse.dog:pet() |
54 | end |
55 | self:deactivate() |
56 | end |
deactivate
DescriptionDeactivate methodDefinition
deactivate()Code
60 | function PlayerStateAnimalPet:deactivate() |
61 | PlayerStateAnimalPet:superClass().deactivate(self) |
62 | self.isDog = false |
63 | end |
isAvailable
DescriptionCheck if we can pet an animal.Definition
isAvailable()Return Values
bool | returns | true if player can pet an animal |
29 | function PlayerStateAnimalPet: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 | local _, playerY, _ = getWorldTranslation(self.player.rootNode) |
35 | playerY = playerY - self.player.baseInformation.capsuleTotalHeight * 0.5 |
36 | local deltaWater = playerY - g_currentMission.waterY |
37 | local playerInWater = deltaWater < 0.0 |
38 | |
39 | if playerHandsEmpty and not playerInWater and dogHouse ~= nil and dogHouse.dog ~= nil and dogHouse.dog.playersInRange[self.player.rootNode] then |
40 | self.isDog = true |
41 | return true |
42 | end |
43 | end |
44 | return false |
45 | 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.isDog = false |
23 | return self |
24 | end |