Jump to content

Scripting Problem


eleglas

Recommended Posts

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

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

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...