LivewareCascade Posted December 3, 2015 Share Posted December 3, 2015 Hello, I am producing a modders resource that works similar to the light switch script but takes into account whether the lights have actually been built yet or not. I'm trying to understand the process of calling a script function from another script, but I'm having difficulty understanding the process - I'm thoroughly mystified by the process of casting. Basically you have a script running on a persistent controller objectref (typically an XMarker) called the "controller". This is the one that contains state switching logic for the lights on, lights off, or lightsnotbuilt state. LightsNotBuilt is the entry state, and DOES NOT contain any conditions that enable the script to move out of it's state. This is to make the process of actually "building" the lights entirely event-driven. A second, smaller script acts on a miscitem when the player "builds" the lights at a house workbench. This is the CraftItem script, and enables an initially disabled objectref called "BuildMarker" and then removes itself. A function, LightsBuiltCheck contained in the Controller script checks the Enable State of the build marker, and then moves to Lights On/Lights Off as appropriate. It is this function I am trying to call when the CraftItem script fires. I'm hoping that someone might be able to assist me with the syntax of calling this function, as I've been unable to compile and call it so far. I've managed to specify the Controller script as a parent, but it doesn't appear to do anything. Additionally, given that this function is switching between states in the Controller script, can it still force a movement in states if called within another function? If not, is there a way to specify it's parent script and to force it to change states? The Controller script can be found hereThe CraftItem script can be found here Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 3, 2015 Share Posted December 3, 2015 Your craft item script: Reveal hidden contents Scriptname BALSCraftItem extends ObjectReference {Removes the crafted item, passes time and then enables specified items} ObjectReference Property EnableRef Auto {One of the references to be enabled} MiscObject Property CraftItem Auto {This targets the item the script is attached to so it may be removed from your inventory} BalsController Property BalsC Auto {This targets the form that contains the script BalsController. If script is used multiple times, pick the correct form.} Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) EnableRef.enable(true) Game.GetPlayer().RemoveItem(CraftItem,1,True) BalsC.LightsBuiltCheck(EnableRef) Return EndEvent That should get your craft script to run the LightsBuiltCheck function on your controller script. Be sure to fill the newly added property. Link to comment Share on other sites More sharing options...
LivewareCascade Posted December 3, 2015 Author Share Posted December 3, 2015 On 12/3/2015 at 7:44 PM, IsharaMeradin said: Your craft item script: Reveal hidden contents Scriptname BALSCraftItem extends ObjectReference {Removes the crafted item, passes time and then enables specified items} ObjectReference Property EnableRef Auto {One of the references to be enabled} MiscObject Property CraftItem Auto {This targets the item the script is attached to so it may be removed from your inventory} BalsController Property BalsC Auto {This targets the form that contains the script BalsController. If script is used multiple times, pick the correct form.} Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) EnableRef.enable(true) Game.GetPlayer().RemoveItem(CraftItem,1,True) BalsC.LightsBuiltCheck(EnableRef) Return EndEvent That should get your craft script to run the LightsBuiltCheck function on your controller script. Be sure to fill the newly added property. Thank you so much Ishara, that worked perfectly. Can I please credit you as a contributor when I release this? You've helped me absolutely massively. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted December 3, 2015 Share Posted December 3, 2015 No need to, but whether you do or not is up to you. Link to comment Share on other sites More sharing options...
Recommended Posts