File upandaway/components/staticchargeable.lua

Simple component for handling static state transitions.

Author:

simplex

Functions

StaticChargeable:Charge (force) Charges if not already.
StaticChargeable:GetOnChargedDelay () Returns the oncharge delay as a number.
StaticChargeable:GetOnChargedFn (fn) Returns the oncharge callback.
StaticChargeable:GetOnUnchargedDelay () Returns the onuncharge delay as a number.
StaticChargeable:GetOnUnchargedFn (fn) Returns the onuncharge callback.
StaticChargeable:GetStateHoldingDuration () Returns the duration of the current state holding, and nil otherwise.
StaticChargeable:HoldState (time) Keeps the current state for a predetermined amount of time.
StaticChargeable:IsCharged () Returns whether it is charged.
StaticChargeable:IsInHeldState () Returns whether the current state is unaffected by the ambient.
StaticChargeable:OnLoad (data) Loads the charged state.
StaticChargeable:OnSave () Saves the charged state.
StaticChargeable:ReleaseState () Reverses the effect of the KeepState.
StaticChargeable:SetOnChargedDelay (delay) Sets the oncharge delay.
StaticChargeable:SetOnChargedFn (fn) Sets the oncharge callback.
StaticChargeable:SetOnUnchargedDelay (delay) Sets the onuncharge delay.
StaticChargeable:SetOnUnchargedFn (fn) Sets the onuncharge callback.
StaticChargeable:Toggle (force) Toggles the state.
StaticChargeable:Uncharge (force) Uncharges if not already.

Tables

StaticChargeable Simple component for handling static state transitions.


Functions

StaticChargeable:Charge (force)
Charges if not already.

Parameters

  • force: Forces the charging, even if already charged.
StaticChargeable:GetOnChargedDelay ()
Returns the oncharge delay as a number.
StaticChargeable:GetOnChargedFn (fn)
Returns the oncharge callback.

Parameters

  • fn:
StaticChargeable:GetOnUnchargedDelay ()
Returns the onuncharge delay as a number.
StaticChargeable:GetOnUnchargedFn (fn)
Returns the onuncharge callback.

Parameters

  • fn:
StaticChargeable:GetStateHoldingDuration ()
Returns the duration of the current state holding, and nil otherwise.
StaticChargeable:HoldState (time)
Keeps the current state for a predetermined amount of time. During that period, the state doesn't change with the ambient.

Parameters

  • time:
StaticChargeable:IsCharged ()
Returns whether it is charged.
StaticChargeable:IsInHeldState ()
Returns whether the current state is unaffected by the ambient.
StaticChargeable:OnLoad (data)
Loads the charged state. Calls Charge() or Uncharge() appropriately.

Parameters

  • data:
StaticChargeable:OnSave ()
Saves the charged state. Tries to use as little savedata as possible, since we'll have a lot of entities with this component.
StaticChargeable:ReleaseState ()
Reverses the effect of the KeepState.
StaticChargeable:SetOnChargedDelay (delay)
Sets the oncharge delay. Can be a function.

Parameters

  • delay:
StaticChargeable:SetOnChargedFn (fn)
Sets the oncharge callback.

Parameters

  • fn:
StaticChargeable:SetOnUnchargedDelay (delay)
Sets the onuncharge delay. Can be a function.

Parameters

  • delay:
StaticChargeable:SetOnUnchargedFn (fn)
Sets the onuncharge callback.

Parameters

  • fn:
StaticChargeable:Toggle (force)
Toggles the state.

Parameters

  • force:
StaticChargeable:Uncharge (force)
Uncharges if not already.

Parameters

  • force: Forces the uncharging, even if already uncharged.

Tables

StaticChargeable
Simple component for handling static state transitions.

Valid XHTML 1.0!