Jump to content

Need help with a light script


Guest Messenjah

Recommended Posts

Guest Messenjah

Hey guys, I need help with a light script. I basically need a particular npc to walk into a trigger and the light turns on and when they leave the light turns off.

 

 

The "Token" mentioned in the script is a player item I've created that serves no purpose, uses one of the extra unused slots if it is ever equipped and it is used as an easy way to denote to other activator scripts which npc is active. I know that NVSE does something like this but better but I'm trying not to use NVSE because I don't want to force players to download other mods when they do not need too.

 

Anyway, the light never turns on. Any ideas?

SCN ACGomLightTriggerSCRIPT

REF NPC01
REF NPC02
REF NPC03
REF NPC04
REF Lights



;	TRIGGER ENTER BLOCK
;********************************************


Begin OnTriggerEnter

	Set NPC01 to ACGamStageDancer01
	Set NPC01 to ACGamStageDancer02
	Set NPC01 to ACGamStageDancer03
	Set NPC01 to ACGamStageDancer04
	Set Lights to GetLinkedRef

	If GetActionRef == NPC01 || NPC02 || NPC03 || NPC04

		If NPC01.GetItemCount ACToken > 0

			Lights.Enable

		Elseif NPC02.GetItemCount ACToken > 0

			Lights.Enable

		Elseif NPC03.GetItemCount ACToken > 0

			Lights.Enable

		Elseif NPC04.GetItemCount ACToken > 0

			Lights.Enable

		Endif

	Endif

End


;	TRIGGER LEAVE BLOCK
;********************************************

Begin OnTriggerLeave


	Set NPC01 to ACGamStageDancer01
	Set NPC01 to ACGamStageDancer02
	Set NPC01 to ACGamStageDancer03
	Set NPC01 to ACGamStageDancer04
	Set Lights to GetLinkedRef

	If GetActionRef == NPC01 || NPC02 || NPC03 || NPC04

		If NPC01.GetItemCount ACToken > 0

			Lights.Disable

		Elseif NPC02.GetItemCount ACToken > 0

			Lights.Disable

		Elseif NPC03.GetItemCount ACToken > 0

			Lights.Disable

		Elseif NPC04.GetItemCount ACToken > 0

			Lights.Disable

		Endif

	Endif

End
Link to comment
Share on other sites

See if this works:

Begin OnTriggerEnter

    Set rLights to GetLinkedRef
    Set rActor to GetActionRef
    
    If rActor != ACGamStageDancer01 && rActor != ACGamStageDancer02 && rActor != ACGamStageDancer03 && rActor != ACGamStageDancer04
        Return
    EndIf
    
    If rActor.GetItemCount ACToken
        rLights.Enable
    EndIf

End

The sixth line is a little obtuse, but not to the point of being incomprehensible.

But actually, I'd prefer the following solution instead:

Begin OnTriggerEnter

    Set rLights to GetLinkedRef
    Set rActor to GetActionRef
    
    If rActor.GetItemCount ACToken && rActor.IsInList ACGamStageDancerList
        rLights.Enable
    EndIf

End

This checks to see if the base object of the triggering reference is present in a form list. Now you don't need to edit the script if you want to have more or fewer actors, just add or remove them from the list.

Link to comment
Share on other sites

Guest Messenjah

Oooh, I like the looks of this script. If I may, can I throw another question at you....

 

 

This line:

 If rActor.GetItemCount ACToken && rActor.IsInList ACGamStageDancerList

This simplifies the script by quite a bit. The problem is that other scripts are not quite as simple with these dancers. Is there a way to make a script that looks through a form list, then finds the actor with the token and then finally sets the actor with the token to a reference. Basically the reverse of what you just did. For example, some of my scripts tied to the dancers don't use getactionref.

 

For example, the way I have been doing this:

REF NPC01
REF NPC02
REF rActor

Short DoOnce

Begin GameMode

If DoOnce == 0

Set NPC01 to ActorReference01
Set NPC02 to ActorReference02

If NPC01.GetItem ACToken > 0

Set rActor to NPC01

Elseif NPC02.GetItem ACToken > 0

Set rActor to  NPC02

Endif


;rActor Do Stuff

Endif

End

Basically here, I made a script that first links a the script reference to a referenced actor. Then I check through the different references to see who has a token, and then I finally assign the reference containing the token to a new reference in order to simplify everything I need to do with that actor. Any way to shorten this process?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...