Jump to content

Force Field Script Problem


Randaworgie

Recommended Posts

Force Field Script Problem.

 

I'm hivang some problems with a script and need help, when this script is applied to a switch activated the number 1's and 2's will deactivate and the 3's and 4's will activate, but upon the second activation the 1's and 2's activate but the 3's and 4's deactivate. now on the third press of the button the 1's and 2's will deactivate but the 3's and 4's will remain deactivated and no matter how many other times I the button only the 1's and 2's are effected by the scrip there after. all ref's are persistent and are NOT initially disabled.

 

ScriptName LDSSNCRForceSwitchScript

ref Light

Begin OnActivate
       if SSNCRCenterForce01 == 0
               set light to GetLinkedRef
       endif

       if SSNCRCenterForce01.GetDisabled
               SSNCRCenterForce01.Enable
               ssncrcenterforce03.disable
       else
               SSNCRCenterForce01.Disable
       endif
       
if SSNCRCenterForce02 == 0
               set light to GetLinkedRef
       endif

       if SSNCRCenterForce02.GetDisabled
               SSNCRCenterForce02.Enable
               ssncrcenterforce04.disable
       else
               SSNCRCenterForce02.Disable
       endif

if SNCRCenterForce02 == 0
               set light to GetLinkedRef
       endif

       if SNCRCenterForce02.GetDisabled
               SSNCRCenterForce02.Enable
               sncrcenterforce03.disable
       else
               SNCRCenterForce02.Disable
       endif

if SNCRCenterForce01 == 0
               set light to GetLinkedRef
       endif

       if SNCRCenterForce01.GetDisabled
               SNCRCenterForce01.Enable
               sncrcenterforce04.disable
       else
               SNCRCenterForce01.Disable
       endif
       Activate
End

Link to comment
Share on other sites

These statements aren't doing anything:

 

        if SSNCRCenterForce01 == 0 
               set light to GetLinkedRef 
       endif

 

because SSNCRCenterForce01 is a persistent reference and therefore non-zero, so your variable 'light' is never getting set. And I don't see anywhere in the script what you would do with light even if you did set it. What is the linked ref of the switch?

Link to comment
Share on other sites

What behavior are you trying to accomplish with refs 1,2,3 and 4? From your post I might guess toggle 1,2 on when 3,4 off, and 1,2 off when 3,4 on. If they are all initially enabled, there needs to be a startup part to disable two of them.

 

 

ScriptName LDSSNCRForceSwitchScript 

short iState
short iActivated
short iInit

Begin OnActivate

if IsActionREF Player == 1
 set iActivated to 1
 if iState == 0
  SetOpenState 1  ;Green light on switch goes on
 else
  SetOpenState 0
 endif
endif

END


BEGIN GameMode

if iInit == 0
 sncrcenterforce03.disable
 sncrcenterforce04.disable
 set iInit to 1
 return
endif

if iActivated == 0
 return
else
 if iState == 0   ;toggle
  SSNCRCenterForce01.Disable
  SSNCRCenterForce02.Disable
  SSNCRCenterForce03.Enable
  SSNCRCenterForce04.Enable
  set iState to 1
 else
  SSNCRCenterForce01.Enable
  SSNCRCenterForce02.Enable
  SSNCRCenterForce03.Disable
  SSNCRCenterForce04.Disable
  set iState to 0
 endif
 
 set iActivated to 0
 
endif

END


 

 

Link to comment
Share on other sites

Thankyou rickerhk for your help with this, the scrip (with a few tweaks) now works fully and as intended. and this is the full scrip =]

 

ScriptName LDSSNCRForceSwitchScript 

short iState
short iActivated
short iInit

Begin OnActivate

if IsActionREF Player == 1
 set iActivated to 1
 if iState == 0
  SetOpenState 1  ;Green light on switch goes on
 else
  SetOpenState 0
 endif
endif

END


BEGIN GameMode

if iInit == 0
 sncrcenterforce03.disable
 sncrcenterforce04.disable
 ssncrcenterforce03.disable
 ssncrcenterforce04.disable
 set iInit to 1
 return
endif

if iActivated == 0
 return
else
 if iState == 0   ;toggle
  SSNCRCenterForce01.Disable
  SSNCRCenterForce02.Disable
  SNCRCenterForce01.Disable
  SNCRCenterForce02.Disable
  SSNCRCenterForce03.Enable
  SSNCRCenterForce04.Enable
  SNCRCenterForce03.Enable
  SNCRCenterForce04.Enable
  set iState to 1
 else
  SSNCRCenterForce01.Enable
  SSNCRCenterForce02.Enable
  SNCRCenterForce01.Enable
  SNCRCenterForce02.Enable
  SSNCRCenterForce03.Disable
  SSNCRCenterForce04.Disable
  SNCRCenterForce03.Disable
  SNCRCenterForce04.Disable
  set iState to 0
 endif
 
 set iActivated to 0
 
endif

END

 

again thankyou rickerhk

Link to comment
Share on other sites

  • Recently Browsing   0 members

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