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
PlayerStateCycleHandtool
ParentPlayerStateBaseFunctions
activate
DescriptionActivate method.Definition
activate()Code
38 | function PlayerStateCycleHandtool:activate() |
39 | PlayerStateCycleHandtool:superClass().activate(self) |
40 | |
41 | local farm = g_farmManager:getFarmById(self.player.farmId) |
42 | local handTools = farm.handTools |
43 | local currentId = 0 |
44 | |
45 | if self.player:hasHandtoolEquipped() then |
46 | local currentConfigFileName = self.player.baseInformation.currentHandtool.configFileName |
47 | |
48 | for key, filename in pairs(handTools) do |
49 | if filename:lower() == currentConfigFileName:lower() then |
50 | currentId = key |
51 | break |
52 | end |
53 | end |
54 | end |
55 | |
56 | currentId = currentId + self.cycleDirection |
57 | if currentId > #handTools then |
58 | currentId = 0 |
59 | elseif currentId < 0 then |
60 | currentId = #handTools |
61 | end |
62 | |
63 | if currentId == 0 then |
64 | self.player:equipHandtool("", false) |
65 | else |
66 | self.player:equipHandtool(handTools[currentId], false) |
67 | end |
68 | |
69 | self:deactivate() |
70 | end |
isAvailable
DescriptionDefinitionisAvailable()Return Values
bool | true | if player can idle |
29 | function PlayerStateCycleHandtool:isAvailable() |
30 | local farm = g_farmManager:getFarmById(self.player.farmId) |
31 | local isInWater = self.player.baseInformation.isInWater |
32 | |
33 | return #farm.handTools > 0 and not isInWater and not self.player.isCarryingObject |
34 | 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 PlayerStateCycleHandtool.new(player, stateMachine) |
20 | local self = PlayerStateBase.new(player, stateMachine, PlayerStateCycleHandtool_mt) |
21 | |
22 | self.cycleDirection = 1 |
23 | return self |
24 | end |