eleglas Posted July 6, 2010 Share Posted July 6, 2010 I have a problem. I'm trying to create a convertible roof and have 2 statics, one disabled, they are referenced as 000RoofOpenRef and 000RoofOpenClose; I've made a button that when activated should disable one and enable another depending on which is currently enabled but I'm having trouble; I keep getting this problem a lot when trying to make the script; I keep getting told the GECK is mistaking my references for commands. Here's my code: SCN 000RoofX Short RoofOpen Short RoofClosed Begin OnActivate Set RoofOpen to 000RoofOpenRef Set RoofClosed to 000RoofCloseRef If RoofOpen.GetDisabled == 1 RoofOpen.Enable RoofClosed.Disable Elseif RoofClosed.GetDisabled == 1 RoofClosed.Enable RoofOpen.Disable Endif END Any help will be great, thanks. Link to comment Share on other sites More sharing options...
rickerhk Posted July 6, 2010 Share Posted July 6, 2010 Define your varibales as REFs SCN 000RoofX ref RoofOpen ref RoofClosed Link to comment Share on other sites More sharing options...
eleglas Posted July 6, 2010 Author Share Posted July 6, 2010 Yeah I tried that before, same problem. Link to comment Share on other sites More sharing options...
Quetzlsacatanango Posted July 7, 2010 Share Posted July 7, 2010 SCN 000RoofX ;Short RoofOpen ;Short RoofClosed Begin onactivate ;Set RoofOpen to 000RoofOpenRef ;Set RoofClosed to 000RoofCloseRef If 000RoofOpenRef.GetDisabled == 1 000RoofOpenRef.Enable 000RoofCloseRef.Disable Elseif 000RoofCloseRef.GetDisabled == 1 000RoofCloseRef.Enable 000RoofOpenRef.Disable Endif END That should probably work. Make sure 000RoofCloseRef and 000RoofOpenRef are persistent references. Link to comment Share on other sites More sharing options...
Cipscis Posted July 7, 2010 Share Posted July 7, 2010 rickerhk is absolutely right that only "ref" variables can be used to call references functions, but the problem here is a more obscure one. The GECK's compiler cannot find references by their editorRefIDs if they start with a number. I recommend that if you want your references to be easy to find, use a unique string to do with you or your mod instead of "000" or "aaa". The GECK's filter system makes them just as easy to find, and you can sort by formID to bring your references to the top without requiring a unique string anyway. Once you've fixed your editorRefIDs, you won't need to use "ref" variables as intermediaries at all. Just use code like this: ScriptName RoofX Begin OnActivate if RoofOpenRef.GetDisabled RoofOpenRef.Enable 0 RoofCloseRef.Disable else RoofOpenRef.Disable RoofCloseRef.Enable 0 endif End If you specify one reference as the Enable Parent of the other, and tick the "Set Enable State to Opposite of Parent" box, then you'll only need to Enable and Disable the master reference. Cipscis Link to comment Share on other sites More sharing options...
eleglas Posted July 7, 2010 Author Share Posted July 7, 2010 Thanks Cipscis; you seem to be the one whose always digging me out of these scripting messes; thanks for that. Link to comment Share on other sites More sharing options...
Quetzlsacatanango Posted July 7, 2010 Share Posted July 7, 2010 Huh. Didn't know about the number thing. Good to know. Link to comment Share on other sites More sharing options...
pkleiss Posted July 7, 2010 Share Posted July 7, 2010 One more thing, if you want... This:ScriptName RoofX Begin onactivate if RoofOpenRef.GetDisabled RoofOpenRef.Enable 0 RoofCloseRef.Disable else RoofOpenRef.Disable RoofCloseRef.Enable 0 endif End Can be expressed by this: ScriptName RoofX Begin onactivate if RoofOpenRef.GetDisabled RoofOpenRef.Enable 0 else RoofOpenRef.Disable endif End If you set the enable parent of RoofCloseRef to RoofOpenRef and check the enable state flag to 'opposite of parent'. In this case, RoofCloseRef would not need to be persistent either. Link to comment Share on other sites More sharing options...
Recommended Posts