dizietemblesssma Posted October 17, 2023 Share Posted October 17, 2023 I want to have one script that will be attached to two magic effects, in that script is a function that I want to know which effect is the one the script is attached to - so that the function can do one of two things.my_function(Bool choice)where choice = True or False depending on which magic effect has the script running.I think that using 'self' might be the answer to determine the boolean value to pass to the function but just by itself just gives me the name of the script.Is this a doable thing?I could just make two scripts very similar to each other, but I wish to avoid having to maintain two scripts and keep them in sync if I can just have the one. diziet Link to comment Share on other sites More sharing options...
dylbill Posted October 17, 2023 Share Posted October 17, 2023 Yes, you would use self. Self points to whatever your script is attached to. If your script extends ActiveMagicEffect though youll want to use: If self.GetBaseObject() == MyMagicEffect ;do something Endif Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 19, 2023 Author Share Posted October 19, 2023 Ah, thankyou. This is exactly what I need:)As an aside, would it be possible to somehow pass a value/parameter etc. to a magiceffect when the spell is cast without using a global variable or script property? I ask out of pure academic interest since your answer satisfies my needs completely! diziet Link to comment Share on other sites More sharing options...
dylbill Posted October 19, 2023 Share Posted October 19, 2023 No problem, and not that I'm aware of. You'd need a script property at least. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 20, 2023 Share Posted October 20, 2023 (edited) As an aside, would it be possible to somehow pass a value/parameter etc. to a magiceffect when the spell is cast without using a global variable or script property? I ask out of pure academic interest since your answer satisfies my needs completely! GetFormFromFile might work in this scenario. If the magic effect needs to get a variable value from another script (say a quest script): ;inside a function or event NameOfQuestScript myQuestScript = (Game.GetFormFromFile(0x12345678,"WhateverPlugin.esp") as Quest) as NameOfQuestScript If myQuestScript.myVar = XYZ ; change XYZ depending up whatever type of variable ; do stuff if matches Else ; do stuff if does not match EndIf Edited October 20, 2023 by IsharaMeradin Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 21, 2023 Author Share Posted October 21, 2023 OK that's cwl, thankyou:) diziet more questions incoming... Link to comment Share on other sites More sharing options...
Recommended Posts