Jump to content

I'm missing a piece of script, Help please.


antstubell

Recommended Posts

Hi all.

Its been so long since I scripted that I've forgotten some things. I have a basic Debug message below which I want to show once and never again when player enters the trigger. I can't for the life of me remember the line of code I need to add. Please help.

 

Event OnTriggerEnter(objectreference akactionref)

if akactionref == game.getplayer()

debug.messagebox("Blah, blah, blah")

 

endif

endevent

Link to comment
Share on other sites

int DoOnce

Event OnTriggerEnter(objectreference akactionref)
if DoOnce == 0
if akactionref == game.getplayer()
debug.messagebox("Blah, blah, blah")
DoOnce = 1
endif
endif
endevent

 

would do it I think but it's pretty brutal. I have no idea about persistence etc.

 

Urgh, nested ifs are ugly. Let's see if someone has a better way.

Edited by acidzebra
Link to comment
Share on other sites

I have something similar to what you want on one of my mods.

 

You can adapt what you need from it. The important thing is the message box shows only once and never again

 

Scriptname abIM_StorageAndRetrieval extends ObjectReference
{Initial Greet on first activation -- manual usage on every activation thereafter}

Import Utility
Import Game
Import Debug

;the container used
ObjectReference Property abIM_SoS_CONT Auto

;the formlists of items
FormList Property abIM_SLGM_INGR_ALCH auto
FormList Property abIM_MISC auto

;the intergers needed
Int Check1
Int Check2

;global variables
GlobalVariable Property abIM_DoUpdate Auto
GlobalVariable Property abIM_DoOnce Auto

Event OnActivate(ObjectReference Turtle)
If abIM_DoOnce.GetValueInt() == 0
	GetStarted()
EndIf
EndEvent

Function GetStarted()
      	RegisterForUpdate(60)
abIM_DoOnce.SetValueInt(1)
Debug.MessageBox("------ Thank you for using Glimpse of Elsweyr ------ ---------- Before reading anything else ---------- Please read the Journal located inside the satchel")
EndFunction

Event OnUpdate()
Actor Player = GetPlayer()
If abIM_DoUpdate.GetValueInt() == 1 &&  !(Player.IsInCombat())
        int PlayerBaseMagicka = Player.GetBaseActorValue("magicka") as int
        float PercentOfMagicka = PlayerBaseMagicka * 0.33
	String AutoStored = "Crafting supplies auto stored"
	Check1 = Player.GetItemCount(abIM_SLGM_INGR_ALCH)
	Check2 = Player.GetItemCount(abIM_MISC)
	If (Check1 >= 1 || Check2 >= 1 )
		If Check1 >= 1
			Player.RemoveItem(abIM_SLGM_INGR_ALCH,Check1,True,abIM_SoS_CONT)
   		EndIf
   		If Check2 >= 1
			Player.RemoveItem(abIM_MISC,Check2,True,abIM_SoS_CONT)
   		EndIf
   		Player.DamageActorValue("magicka",PercentOfMagicka)
   		Return Notification(AutoStored)
    	EndIf
ElseIf (abIM_DoUpdate.GetValueInt() == 0) || (abIM_DoUpdate.GetValueInt() == 1 && Player.IsInCombat())
;do nothing
ElseIf (abIM_DoUpdate.GetValueInt() != 0) && (abIM_DoUpdate.GetValueInt() != 1)
        UnregisterForUpdate()
        Debug.MessageBox("Glimpse of Elsweyr is now safe to uninstall")
EndIf
EndEvent

 

Link to comment
Share on other sites

I have something similar to what you want on one of my mods.

 

You can adapt what you need from it. The important thing is the message box shows only once and never again

 

Scriptname abIM_StorageAndRetrieval extends ObjectReference
{Initial Greet on first activation -- manual usage on every activation thereafter}

Import Utility
Import Game
Import Debug

;the container used
ObjectReference Property abIM_SoS_CONT Auto

;the formlists of items
FormList Property abIM_SLGM_INGR_ALCH auto
FormList Property abIM_MISC auto

;the intergers needed
Int Check1
Int Check2

;global variables
GlobalVariable Property abIM_DoUpdate Auto
GlobalVariable Property abIM_DoOnce Auto

Event OnActivate(ObjectReference Turtle)
If abIM_DoOnce.GetValueInt() == 0
	GetStarted()
EndIf
EndEvent

Function GetStarted()
      	RegisterForUpdate(60)
abIM_DoOnce.SetValueInt(1)
Debug.MessageBox("------ Thank you for using Glimpse of Elsweyr ------ ---------- Before reading anything else ---------- Please read the Journal located inside the satchel")
EndFunction

Event OnUpdate()
Actor Player = GetPlayer()
If abIM_DoUpdate.GetValueInt() == 1 &&  !(Player.IsInCombat())
        int PlayerBaseMagicka = Player.GetBaseActorValue("magicka") as int
        float PercentOfMagicka = PlayerBaseMagicka * 0.33
	String AutoStored = "Crafting supplies auto stored"
	Check1 = Player.GetItemCount(abIM_SLGM_INGR_ALCH)
	Check2 = Player.GetItemCount(abIM_MISC)
	If (Check1 >= 1 || Check2 >= 1 )
		If Check1 >= 1
			Player.RemoveItem(abIM_SLGM_INGR_ALCH,Check1,True,abIM_SoS_CONT)
   		EndIf
   		If Check2 >= 1
			Player.RemoveItem(abIM_MISC,Check2,True,abIM_SoS_CONT)
   		EndIf
   		Player.DamageActorValue("magicka",PercentOfMagicka)
   		Return Notification(AutoStored)
    	EndIf
ElseIf (abIM_DoUpdate.GetValueInt() == 0) || (abIM_DoUpdate.GetValueInt() == 1 && Player.IsInCombat())
;do nothing
ElseIf (abIM_DoUpdate.GetValueInt() != 0) && (abIM_DoUpdate.GetValueInt() != 1)
        UnregisterForUpdate()
        Debug.MessageBox("Glimpse of Elsweyr is now safe to uninstall")
EndIf
EndEvent

 

 

Thank you both.

@acidzebra - Brutal but effective.

@IsharaMeradin- That's some impressive code.

Link to comment
Share on other sites

Another example:

 

Auto State NotEntered    
Event OnTriggerEnter(objectreference akActionRef) 					
	  if akActionRef == Game.GetPlayer() 		   
		   Debug.Messagebox("Blah")  
		   GoToState("")
	  endif
EndEvent  
EndState  

 

 

Now you can choose from three options. :unsure:

 

Thanks Ghaunadaur, another excellent script.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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