Thief3Wannabe Posted March 2, 2010 Share Posted March 2, 2010 Currently I'm using the light switch script to allow the player to turn on a vaults power supply: ScriptName LightSwitchScript ref light Begin OnActivate if light == 0 set light to GetLinkedRef endif if light.GetDisabled light.Enable else light.Disable endif ActivateEnd However, I would like to make it so the player can only turn on the power once and not be able to turn it off. I've got everything else set up thanks to enable parenting but I'm obviously missing something really simple here. I tried looking at scripts that use "counts" but anytime I try to incorporate what I think I've learned into the lightswitch script it just doesn't work. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Cipscis Posted March 2, 2010 Share Posted March 2, 2010 As you've no doubt realised, the script that you're using allows the player to turn the lights on and off any number of times by repeatedly activating the switch. If you only want the first activation to have an effect, then you'll want to use a variable to store whether or not it has been activated already, and only run code the first time it is activated:ScriptName LightSwitchScript int bDoOnce ref rLinkedRef Begin OnActivate player if bDoOnce == 0 set bDoOnce to 1 set rLinkedRef to GetLinkedRef rLinkedRef.Enable Activate endif EndP.S. Please use code or codebox tags when posting scripts. This forces them to be displayed in a fixed width font and maintains indentation, making them easier to read. If you don't know how to indent your scripts, here is a web-based tool that can do it for you - Script Validator Cipscis Link to comment Share on other sites More sharing options...
Thief3Wannabe Posted March 4, 2010 Author Share Posted March 4, 2010 Had to switch a few things around but it works now, thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts