Difference between revisions of "Talk:Dissecting the Scripts for Weapon Racks"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>HawkFest
imported>HawkFest
Line 10: Line 10:
{A marker reference parent of other objects that you wish to enable when the player becomes member of some allowed faction}
{A marker reference parent of other objects that you wish to enable when the player becomes member of some allowed faction}
Actor Property PlayerREF Auto
Actor Property PlayerREF Auto
Bool ShouldWaitForAllowedFaction = True


Event OnLoad()
Event OnLoad()
If MarkerEnabler.IsDisabled()
If ShouldWaitForAllowedFaction
GoToState("WaitForAllowedFaction")
GoToState("WaitForAllowedFaction")
EndIf
EndIf
Line 20: Line 21:
Event OnBeginState()
Event OnBeginState()
If PlayerREF.IsInFaction(AllowedFaction)
If PlayerREF.IsInFaction(AllowedFaction)
MarkerEnabler.Enable()
ShouldWaitForAllowedFaction = False
; Do what you want to do
Else
Else
RegisterForSingleUpdateGameTime(0.9)
RegisterForSingleUpdateGameTime(0.9)

Revision as of 16:05, 29 January 2013

Erroneous assertion

It's written: « I'm not going to try and explain states here, but it's redundant and has no utility if you only have a single state in a script. »

That's plain wrong: a singleton state can be essential e.g. when monitoring things, while using RegisterForSingleUpdateGameTime for instance. One example which is quite self-explanatory:

Scriptname FactionDetectionScript extends ObjectReference  
{Script to be attached to some object in the cell you wish to be monitoring for the player to be a member in some allowed faction}
ObjectReference Property MarkerEnabler Auto
{A marker reference parent of other objects that you wish to enable when the player becomes member of some allowed faction}
Actor Property PlayerREF Auto
Bool ShouldWaitForAllowedFaction = True

Event OnLoad()
	If ShouldWaitForAllowedFaction
		GoToState("WaitForAllowedFaction")
	EndIf
EndEvent

State WaitForAllowedFaction
	Event OnBeginState()
		If PlayerREF.IsInFaction(AllowedFaction)
			ShouldWaitForAllowedFaction = False
			; Do what you want to do
		Else
			RegisterForSingleUpdateGameTime(0.9)
		EndIf
	EndEvent

	Event OnUpdateGameTime()
		GoToState("WaitForAllowedFaction")
	EndEvent
EndState

--HawkFest (talk) 2013-01-29T15:34:42 (EST)