Difference between revisions of "IsFurnitureInUse - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>B1gBadDaddy
(Added workaround for no marker being present)
imported>B1gBadDaddy
m
 
(2 intermediate revisions by the same user not shown)
Line 35: Line 35:
# If the furniture object has no marker, or is being activated remotely so no animation plays, IsFurnitureInUse will return false. To workaround this, if the furniture disables looking controls (for example crafting stations), the below example can be used instead.<br/>
# If the furniture object has no marker, or is being activated remotely so no animation plays, IsFurnitureInUse will return false. To workaround this, if the furniture disables looking controls (for example crafting stations), the below example can be used instead.<br/>
<source lang="papyrus">
<source lang="papyrus">
Event OnActivate(ObjectReference akActionRef)
  Utility.Wait(1.0)
  RegisterForSingleUpdate(0.5)
EndEvent
Event OnUpdate()
Event OnUpdate()
 
  if ( ! Game.IsLookingControlsEnabled() )
if ( ! Game.IsLookingControlsEnabled() )
    ; Controls disabled, Player must still be using this furniture
; Controls disabled, Player must still be using this furniture
    RegisterForSingleUpdate(0.5)
RegisterForSingleUpdate(0.5)
    return
return
  else  
else  
    ; Furniture no longer in use
; Furniture no longer in use
  endif
endif
 
EndEvent
EndEvent
</source>
</source>

Latest revision as of 10:36, 2 July 2017

Member of: ObjectReference Script

Checks to see if any furniture marker on this object is in use, optionally ignoring markers that are reserved, but not currently used.

Syntax[edit | edit source]

bool Function IsFurnitureInUse(bool abIgnoreReserved = false) native

Parameters[edit | edit source]

  • abIgnoreReserved: Whether to ignore reserved markers or not.
    • Default: False

Return Value[edit | edit source]

If any marker on the furniture is in use. (Or reserved, if we aren't ignoring reservations)

Examples[edit | edit source]

; Is the bed in use (or someone has reserved it)?
if Bed.IsFurnitureInUse()
  Debug.Trace("Bed is being used")
endIf


; Is the bed actually in use (ignoring reservations)?
if Bed.IsFurnitureInUse(true)
  Debug.Trace("Bed is actually being used")
endIf

Notes[edit | edit source]

  1. If the furniture object has no marker, or is being activated remotely so no animation plays, IsFurnitureInUse will return false. To workaround this, if the furniture disables looking controls (for example crafting stations), the below example can be used instead.
Event OnActivate(ObjectReference akActionRef)
  Utility.Wait(1.0)
  RegisterForSingleUpdate(0.5)
EndEvent

Event OnUpdate()
  if ( ! Game.IsLookingControlsEnabled() )
    ; Controls disabled, Player must still be using this furniture
    RegisterForSingleUpdate(0.5)
    return
  else 
    ; Furniture no longer in use
  endif
EndEvent

See Also[edit | edit source]