dizietemblesssma Posted October 16, 2020 Share Posted October 16, 2020 If I have, say, six trigger boxes, all physically separate in the same cell, all with the same script attached; is there a way for the script to 'know' which box has been triggered and thus set a variable such that, when a different trigger box is entered (same script remember) the script can compare variables and know that a different box has been entered? diziet Link to comment Share on other sites More sharing options...
dylbill Posted October 16, 2020 Share Posted October 16, 2020 Put all of your trigger box object references in a formlist. It's easy to drag them in from the cell view. Then in your script you can do this: Scriptname TriggerBoxScript extends ObjectReference Formlist Property TriggerBoxes Auto Event OnTrigger(ObjectReference akActionRef) Int TriggerBoxIndex = TriggerBoxes.Find(Self) If TriggerBoxIndex == 0 ;do something elseif TriggerBoxIndex == 1 ;do something else Endif EndEvent Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 17, 2020 Author Share Posted October 17, 2020 This is what I currently have: Event OnTriggerEnter(ObjectReference triggerRef) ;this is triggered when entering the trigger box If dz_changing_area_used.GetAt(0) == Self || dz_changing_area_used.GetAt(0) == NONE Else Return EndIf If (triggerRef as Actor) ;is the trigger an actor? Else Return ;if not exit the function EndIf If triggerRef == PlayerRef && !PlayerRef.isincombat() ;checks to see if the trigger is the player and also not in combat If disrobed == False dz_undress_player_F() ;if so call the function to undress the player dz_changing_area_used.AddForm(Self) Return ;we are done, exit the function ElseIf disrobed == True dz_redress_player_F() dz_changing_area_used.Revert() Return EndIf EndIf EndEvent the idea is that the player enters a triggerbox, changes and then only chnages again if she enters the same triggerbox; upon doing so the entry in the formlist is removed. I do not intend for there ever to be more than one entry in the formlist. Does this work? Particularly the|| dz_changing_area_used.GetAt(0) == NONE diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 17, 2020 Share Posted October 17, 2020 I would have used a global variable to indicate the player's dressed / undressed status and a local bool variable to indicate the trigger instance's status with regards to the player undressing within. Something like: Bool IsUndressed = false GlobalVariable Property PlayerDressedStatus Auto {0 = dressed, 1 = undressed} Event OnTriggerEnter(ObjectReference triggerRef) ;this is triggered when entering the trigger box If (triggerRef as Actor) ;is the trigger an actor? Else Return ;if not exit the function EndIf If triggerRef == PlayerRef && !PlayerRef.isincombat() ;checks to see if the trigger is the player and also not in combat If IsUndressed == False && PlayerDressedStatus.Value == 0 IsUndressed = true PlayerDressedStatus.SetValue(1) dz_undress_player_F() ;if so call the function to undress the player dz_changing_area_used.AddForm(Self) Return ;we are done, exit the function ElseIf IsUndressed == True && PlayerDressedStatus.Value == 1 IsUndressed = false PlayerDressedStatus.SetValue(0) dz_redress_player_F() dz_changing_area_used.Revert() Return EndIf EndIf EndEvent This way each trigger tracks with the local variable whether the player undressed within. The global variable tracks the player's dressed status. The player won't try to dress or undress when entering the other triggers because the local bool variable won't be the correct value to correspond with the value of the global variable. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 17, 2020 Author Share Posted October 17, 2020 Groovy! Thankyou diziet Link to comment Share on other sites More sharing options...
ReDragon2013 Posted October 18, 2020 Share Posted October 18, 2020 (edited) You do not need the formlist action. I changed Isharas script a bit.. and is always a good idea to use states for trigger events. snipped ; https://forums.nexusmods.com/index.php?/topic/9211103-identify-specific-trigger-box/ GlobalVariable PROPERTY PlayerDressedStatus auto ; getValue {0 = undressed, 1 = dressed}, new globalVar created with CK Bool bUSED ; [default=false] ; idea is that the player enters a triggerbox to make dress changes and then ; only changes again, if he/she enters the same triggerbox ; -- EVENT -- EVENT OnTriggerEnter(ObjectReference triggerRef) ; an objectRef (which can be an actor) is entering the trigger box IF (triggerRef as Actor) ELSE RETURN ; - STOP - not triggered by actor ENDIF ;--------------------- IF (triggerRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not triggered by the player ENDIF ;--------------------- gotoState("Busy") ; ### STATE ### do not handle more events until action has been finished myF_Action(triggerRef as Actor) gotoState("") ; ### STATE ### back to default state to wait for entering trigger again ENDEVENT ;============================== state Busy ;========= EVENT OnTriggerEnter(ObjectReference triggerRef) ; empty event to cover triggerbox action ENDEVENT ;======= endState ; -- FUNCTION -- ;-------------------------------- FUNCTION myF_Action(Actor player) ; keep in mind this function may run for every instance of this script ;-------------------------------- IF player.IsInCombat() RETURN ; - STOP - player is in combat mode, do not redress !! ENDIF ;--------------------- ;; Debug.Trace(self+" has been entered by the player " +bUSED) IF ( bUSED ) ; == TRUE player was redressed by this trigger bUSED = False dz_undress_player_F() ; call func to undress the player PlayerDressedStatus.SetValue(0) ; switch global to undressed ELSEIF (PlayerDressedStatus.GetValue() == 0.0) PlayerDressedStatus.SetValue(1) ; switch global to dressed state dz_redress_player_F() bUSED = TRUE ;ELSE ; player was dressed by another trigger (with the same script attached) already ENDIF ENDEVENT Edited October 18, 2020 by ReDragon2013 Link to comment Share on other sites More sharing options...
Recommended Posts