maxarturo Posted June 18, 2019 Share Posted June 18, 2019 (edited) I have two scripts and each one is in two different trigger boxes that are link to the same objects and do the same things but they react to different Events. And B is leaving inside A. A) The First OnTriggerEnter. B) The second OnMagicEffectApply. And i want when the one is triggered the other one to go to state "Done" and vice versa. My scene is that an explosion will clear the path for the player to move forwards. OnTriggerEnter if he has equiped a torch the scene will trigger and the explosion will occur. OnMagicEffectApply if he hits the oil pool with destruction magic the scene will trigger. Right now the way i have script them they don't work correctly : When A is trigger, A will disable and delete B and vice versa, but now i get two "actor damge health" when A is trigger and two "explosions" and two "actor damge health" when B gets trigger. So, the disabling each other doesn't seem to work. The scripts goes like this right now : aXMDtochIgnitesOilSCRIP01 auto state waiting Event OnTriggerEnter(ObjectReference akActionRef) if (akActionRef == Game.GetPlayer()) if (Game.GetPlayer().GetEquippedItemType(0) == 11) TriggerBoxMagic.Disable() ;< B trigger box Utility.wait(0.2) TriggerBoxMagic.Delete() ; Do Stuff endif endif ENDEVENT ENDSTATE EVENT onTriggerLeave(ObjectReference akActionRef) if (akActionRef == Game.GetPlayer()) ExitMessage02.Show() Endif ENDEVENT state done EVENT onTriggerLeave(ObjectReference akActionRef) if (akActionRef == Game.GetPlayer()) ; Do Nothing Endif ENDEVENT EndState aXMDspellIgnitesOilSCRIP01 auto state waiting EVENT OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect) if (akEffect.getAssociatedSkill() == "Destruction") && isDestruction TriggerBoxAction.Disable() ;< A trigger box Utility.wait(0.2) TriggerBoxAction.Delete() ; Do Stuff endif ENDEVENT ENDSTATE * Both scripts works fine by themself. Thank you very much for looking at this whoever you are !. And any help would be greatly appreciated !. Edited June 18, 2019 by maxarturo Link to comment Share on other sites More sharing options...
Evangela Posted June 18, 2019 Share Posted June 18, 2019 All I can say is that Scripts are objects and therefore can be set as properties in other scripts. From there all properties and functions from the other scripts are accessible(but not variables, or properties with certain flags like hidden, etc). Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 18, 2019 Share Posted June 18, 2019 Linking scripts via property is one way but in this instance I think using a global variable as a sort of bool would do the trick. Have it initially at a value of 0 and when one script does the work change the value to 1. The condition that the value be at 0 would cause the other script to skip doing the stuff on next run and you can also tell it to go to the desired state for any future run attempts after that. Link to comment Share on other sites More sharing options...
maxarturo Posted June 18, 2019 Author Share Posted June 18, 2019 Thank you both for replying !, i'll try both suggestions. Link to comment Share on other sites More sharing options...
TobiaszPL Posted June 18, 2019 Share Posted June 18, 2019 How about my suggestion ? :DIm using Activate to comunicate Scripts :) its my own idea xD With my way u can:- Communicate any script with any script ready for communication- Send your special events ( via Key words )- Delete / Create NEW script instance in gameAnd probably many more xD Script One: Scriptname QLG_SimpleScript_Activate extends ObjectReference { Activate() only for player } ;===- Base Info. -===; ;Created: 2019-05-23 ;Update: 2019-05-23 ;Author: TobiPL ;Unit: M.PC<1> ;===- Var. setup -============================================ Actor Property QPlayer Auto { Player Ref. } ObjectReference Property QActRef Auto { Ref. to Activate } ;================================================ ;===- Main Script -============================== ;***********************************************; Event OnActivate( ObjectReference QRef ) If( QRef == QPlayer ) QActRef.Activate( self ) EndIf EndEvent ; The End Script two: ( only half of script ) ObjectReference Property QActGround Auto { Object Ref. Trigger Box that support Ground Activation } ObjectReference Property QActPlant Auto { Object Ref. Trigger Box that support Planting new Tree } ObjectReference Property QActHold Auto { Object Ref. Trigger Box that support Hold Tree Activation } ObjectReference Property QActCut Auto { Object ref. Trigger Box that support Cutting Tree } State Ready Event OnActivate( ObjectReference QRef ) GoToState( "Wait" ) If( QRef == QActGround ) QLGround() ElseIf( QRef == QActPlant ) QLPlant() ElseIf( QRef == QActHold ) QLHold() ElseIf( QRef == QActCut ) QLCut() EndIf GoToState( "Ready" ) EndEvent EndState You can just use Activate() to send events to other scriptsand You can use Key Words to send "data" to other scripts but ofc. scripts have to know how to handle those Key Words thats my idea to communicate scripts and objects :Dim not sure but it will probably work even if objects are in difreent cells but u probably have to enable object first :x :3 Link to comment Share on other sites More sharing options...
maxarturo Posted June 19, 2019 Author Share Posted June 19, 2019 (edited) Thanks for your suggestion Toby. But this got a little more complicated than i expected, and although i tried a bunch of things, like creating a third script that i put on an xMarker, that when each individual "trigger boxes" got triggered would retrive from the xMarker the "Function" to execute while at the same time disableing the other.Or making each "Trigger Box" - Script to be Linked to its own objects to handle, or Linking them to their own "xMarker Activators" to handle the objects (enable/disable - activate - play), or other things like the suggestions above, but... i still had the same problem that insisted in all my attempts. Problem :- Whenever "Trigger Box B" got triggered, the one that reacts OnMagicEffectApply and is living inside "Trigger Box A" that reacts OnTriggerEnter (also all objects are living inside Trigger A), would also trigger the script from "Triggere Box A".So, i had to go with an unorthodox approach and remove some functions from "Script B" to be handled just by "Script A". Anyway... thanks a lot to all for your suggestions !. Edited June 19, 2019 by maxarturo Link to comment Share on other sites More sharing options...
TobiaszPL Posted June 19, 2019 Share Posted June 19, 2019 (edited) Im not sure i understand your post cause my english isn't so great but:would retrive from the xMarker the "Function" to execute while at the same time disableing the other. You can use functions in other scripts by KeyWords Egh... using words is hard for me to explain xDHere u have IMG: //Edit:Every script that have acces to our "Virtual Stack lel" << :3 hyhycan execute Functions on Values sended by other scripts but:1) We CAN'T send Function to execute :: We can send ONLY values and Events 2) Script need to have 2 Var-s in code ( Stack and Pointer to Stack )is like ebp and stack in ASM :smile: if you know ASM you should understand my Idea i hope it was ebp cause i were not using ASM last 3/4 years xDbut u know this pointer what is pointing on first stack element after using function 4 example in C++ xD egh :x... my english... 3) Remember it will work slow xDcause it is using FormList :c... and probably FormList is only one way to create Global Stack in CK Edited June 19, 2019 by TobiaszPL Link to comment Share on other sites More sharing options...
IsharaMeradin Posted June 19, 2019 Share Posted June 19, 2019 Problem :- Whenever "Trigger Box B" got triggered, the one that reacts OnMagicEffectApply and is living inside "Trigger Box A" that reacts OnTriggerEnter (also all objects are living inside Trigger A), would also trigger the script from "Triggere Box A".So, i had to go with an unorthodox approach and remove some functions from "Script B" to be handled just by "Script A". Trigger volume box A wraps completely around Trigger volume box B. A is entered and does its thing. Then B is entered does its thing but also re-triggers A. Is that correct? And because the actor did not leave Trigger volume A the second run of the script probably does not reflect any changes to variables or status as one would think it should. My only solution would be to reduce the size of Trigger volume A so that it does not include Trigger volume B and if necessary add additional copies of Trigger volume A at various key points in the room. By not overlapping the trigger volume boxes the global variable bool idea mentioned earlier should then work. Link to comment Share on other sites More sharing options...
maxarturo Posted June 19, 2019 Author Share Posted June 19, 2019 Im not sure i understand your post cause my english isn't so great but:would retrive from the xMarker the "Function" to execute while at the same time disableing the other. You can use functions in other scripts by KeyWords Egh... using words is hard for me to explain xDHere u have IMG: HeyHey.png //Edit:Every script that have acces to our "Virtual Stack lel" << :3 hyhycan execute Functions on Values sended by other scripts but:1) We CAN'T send Function to execute :: We can send ONLY values and Events 2) Script need to have 2 Var-s in code ( Stack and Pointer to Stack )is like ebp and stack in ASM :smile: if you know ASM you should understand my Idea i hope it was ebp cause i were not using ASM last 3/4 years xDbut u know this pointer what is pointing on first stack element after using function 4 example in C++ xD egh :x... my english... 3) Remember it will work slow xDcause it is using FormList :c... and probably FormList is only one way to create Global Stack in CKYeah... i meant "EVENT" instead of "Function".I tend to make stupid mistakes when i write fast and i'm already frustrated. For that experiment i was using :https://www.creationkit.com/fallout4/index.php?title=Custom_Papyrus_Eventshttps://www.creationkit.com/fallout4/index.php?title=SendCustomEvent_-_ScriptObjecthttps://www.creationkit.com/fallout4/index.php?title=RegisterForCustomEvent_-_ScriptObject Link to comment Share on other sites More sharing options...
maxarturo Posted June 19, 2019 Author Share Posted June 19, 2019 Problem :- Whenever "Trigger Box B" got triggered, the one that reacts OnMagicEffectApply and is living inside "Trigger Box A" that reacts OnTriggerEnter (also all objects are living inside Trigger A), would also trigger the script from "Triggere Box A".So, i had to go with an unorthodox approach and remove some functions from "Script B" to be handled just by "Script A". Trigger volume box A wraps completely around Trigger volume box B. A is entered and does its thing. Then B is entered does its thing but also re-triggers A. Is that correct? And because the actor did not leave Trigger volume A the second run of the script probably does not reflect any changes to variables or status as one would think it should. My only solution would be to reduce the size of Trigger volume A so that it does not include Trigger volume B and if necessary add additional copies of Trigger volume A at various key points in the room. By not overlapping the trigger volume boxes the global variable bool idea mentioned earlier should then work. I can't reduce the trigger boxes or add more copies, its all happening in a very narrow space, and B has to live inside A. Unfortunately is what the scene requairds.No worries though... at the end i managed to make it work as i wanted to, now everything is handle by Script A in Trigger Box A managing both trigger boxes. Thank you very much for taking the time to think about this !!. Link to comment Share on other sites More sharing options...
Recommended Posts