LegoManIAm94 Posted November 19, 2016 Share Posted November 19, 2016 I've been trying for hours and searching all over the net trying t figure out how to call a function from script A to run on a script B on another object. Essentially I want Object A which has Script A attached to it to run the RunMe() function in Object B which has Script B attached to it. In Script B there is a function called RunMe(). Is this even possible or is there another method. Link to comment Share on other sites More sharing options...
irswat Posted November 19, 2016 Share Posted November 19, 2016 (edited) ScriptB.RunMe() Edited November 19, 2016 by irswat Link to comment Share on other sites More sharing options...
LegoManIAm94 Posted November 19, 2016 Author Share Posted November 19, 2016 ScriptB.RunMe() Is ScriptB a ObjectReference property? And are there any more properties needed? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 19, 2016 Share Posted November 19, 2016 It is a little bit more than what irswat said. ScriptA needs to know about ScriptB first. Here is one example where I called upon variables on a MCM script from a stock script without having to add properties to the stock script.In the empty state immediately following existing property declarations:abim_RM_MCM_QuestScript MCMScriptAs the first thing that ran in the first possible event that would run on the script:MCMScript = (Game.GetFormFromFile(0x00000D62,"Random Mining MCM.esp") as Quest) as abim_RM_MCM_QuestScriptWhenever I wanted to access a function or variable throughout the rest of the script:MCMScript.ExpValue as Int Link to comment Share on other sites More sharing options...
irswat Posted November 19, 2016 Share Posted November 19, 2016 Hmm. I think this is more than just calling a function from script B from Script A? Link to comment Share on other sites More sharing options...
LegoManIAm94 Posted November 19, 2016 Author Share Posted November 19, 2016 I think I got it! ObjectReference Property OBJECTREF Auto Event OnInIt() RegisterForUpdate(2.0) EndEvent Event OnUpdate() (OBJECTREF as OBJECTSCRIPT).RunCustomFunction() EndEvent This will run the RunCustomFunction() in OBJECTSCRIPT that is attached to OBJECTREF. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 19, 2016 Share Posted November 19, 2016 That will work. That is one of the other ways to obtain information from another script. Reference the object itself then cast it as the script assigned to it. Link to comment Share on other sites More sharing options...
Recommended Posts