File upandaway/components/climbable.lua
The Climbable component.
Author:
simplex |
Functions
Climbable:Climb () | Climbs in the configured direction. |
Climbable:DestroyCave (callback) | Destroys the associated cave, if any. |
Climbable:GetCaveNumber () | Returns the current cave number, if any. |
Climbable:GetDirection () | Returns the current climbing direction. |
Climbable:GetDirectionString () | Returns the current direction as a string. |
Climbable:GetEffectiveCaveNumber () | Returns the effective cave number. |
Climbable:OnLoad (data) | Loads the cave number. |
Climbable:OnRemoveEntity () | Destroys the cave. |
Climbable:OnRemoveFromEntity () | Destroys the cave. |
Climbable:OnSave () | Saves the cave number. |
Climbable:SetDirection (direction) | Sets the climbing direction. |
should_have_cavenum (self) | Local function dictating when a Climbable should have a cave number. |
Tables
Climbable | The Climbable component. |
Functions
- Climbable:Climb ()
- Climbs in the configured direction. Raises an error if there isn't any.
- Climbable:DestroyCave (callback)
-
Destroys the associated cave, if any.
Parameters
- callback: An optional callback to be called after completion.
- Climbable:GetCaveNumber ()
- Returns the current cave number, if any.
- Climbable:GetDirection ()
- Returns the current climbing direction.
- Climbable:GetDirectionString ()
-
Returns the current direction as a string.
Return value:
"UP", "DOWN" or "". - Climbable:GetEffectiveCaveNumber ()
- Returns the effective cave number. If the climbable prefab has a cave number, returns it. Otherwise, if we are in a cave level, returns its cave number. Otherwise, returns 0.
- Climbable:OnLoad (data)
-
Loads the cave number.
Parameters
- data:
- Climbable:OnRemoveEntity ()
- Destroys the cave.
- Climbable:OnRemoveFromEntity ()
- Destroys the cave.
- Climbable:OnSave ()
- Saves the cave number.
- Climbable:SetDirection (direction)
-
Sets the climbing direction. Performs cleanup, if needed, in case a previous direction was already set.
Parameters
- direction: Should be either a number or a string ("up" or "down", case insensitive). If it is a number, its sign will dictate the direction. ]]
- should_have_cavenum (self)
-
Local function dictating when a Climbable should have a cave number. The below behaviour was changed, at least provisionally. Otherwise, save files for higher levels would not be properly deleted if a lower beanstalk is chopped (this issue also affects vanilla, with ruins' save files being left behind).
This will only return true if either:- The direction is up and we are not below ground.
- The direction is down and we are not above ground.
Parameters
- self: