antstubell Posted October 19, 2012 Share Posted October 19, 2012 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") endifendevent Link to comment Share on other sites More sharing options...
acidzebra Posted October 19, 2012 Share Posted October 19, 2012 (edited) 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 October 19, 2012 by acidzebra Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 19, 2012 Share Posted October 19, 2012 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 More sharing options...
Ghaunadaur Posted October 19, 2012 Share Posted October 19, 2012 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: Link to comment Share on other sites More sharing options...
antstubell Posted October 19, 2012 Author Share Posted October 19, 2012 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 More sharing options...
antstubell Posted October 19, 2012 Author Share Posted October 19, 2012 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 More sharing options...
Recommended Posts