Jump to content

Lightswitches


lilwayne1982

Recommended Posts

im upgrading one of my mods and placing light switches everywhere for it, its just whenever i get in game and press the switch, it turns the light of but the switch disappears, am i doing something wrong? i took the lightswitch script from the one on GECK's website, id appreciate the help
Link to comment
Share on other sites

Gere goes my working script:

 

setopenstate does the trick with my vanilla lightswitch.

 

scn GSCannabisGrowRoomGrowLightsSwitchObjectSCRIPT


short bInitialized
short bLit   ; 1 = Light is on.

begin OnActivate
if (IsActionRef Player == 1)  
 if bLit == 0
  set bLit to 1
 elseif bLit == 1
  set bLit to 0
 endif
endif
end

begin OnLoad
if bInitialized == 0
 set bLit to 1
 set bInitialized to 1
endif
end


begin GameMode

if bLit == 0
  set bLit to 0
  SetOpenState 0
  GSCannabisGrowRoomGrowLampOffREF01.Enable
  GSCannabisGrowRoomGrowLampOffREF02.Enable
  GSCannabisGrowRoomGrowLampOffREF03.Enable
  GSCannabisGrowRoomGrowLampOffREF04.Enable
  GSCannabisGrowRoomGrowLampOffREF05.Enable
  GSCannabisGrowRoomGrowLampOffREF06.Enable
  GSCannabisGrowRoomGrowLampOffREF07.Enable
  GSCannabisGrowRoomGrowLampOffREF08.Enable
  GSCannabisGrowRoomSeedLampOffREF01.Enable
  GSCannabisGrowRoomSeedLampOffREF02.Enable
  GSCannabisGrowRoomGrowLightREF01.Disable
  GSCannabisGrowRoomGrowLightREF02.Disable
  GSCannabisGrowRoomGrowLightREF03.Disable
  GSCannabisGrowRoomGrowLightREF04.Disable
  GSCannabisGrowRoomGrowLightREF05.Disable
  GSCannabisGrowRoomGrowLightREF06.Disable
  GSCannabisGrowRoomGrowLightREF07.Disable
  GSCannabisGrowRoomGrowLightREF08.Disable
  GSCannabisGrowRoomSeedLightREF01.Disable
  GSCannabisGrowRoomSeedLightREF02.Disable
  GSCannabisGrowRoomGrowLampOnREF01.Disable
  GSCannabisGrowRoomGrowLampOnREF02.Disable
  GSCannabisGrowRoomGrowLampOnREF03.Disable
  GSCannabisGrowRoomGrowLampOnREF04.Disable
  GSCannabisGrowRoomGrowLampOnREF05.Disable
  GSCannabisGrowRoomGrowLampOnREF06.Disable
  GSCannabisGrowRoomGrowLampOnREF07.Disable
  GSCannabisGrowRoomGrowLampOnREF08.Disable
  GSCannabisGrowRoomGrowLampOnREF01.Disable
  GSCannabisGrowRoomGrowLampOnREF02.Disable
elseif bLit == 1

  set bLit to 1
  SetOpenState 1
  GSCannabisGrowRoomGrowLampOffREF01.Disable
  GSCannabisGrowRoomGrowLampOffREF02.Disable
  GSCannabisGrowRoomGrowLampOffREF03.Disable
  GSCannabisGrowRoomGrowLampOffREF04.Disable
  GSCannabisGrowRoomGrowLampOffREF05.Disable
  GSCannabisGrowRoomGrowLampOffREF06.Disable
  GSCannabisGrowRoomGrowLampOffREF07.Disable
  GSCannabisGrowRoomGrowLampOffREF08.Disable
  GSCannabisGrowRoomSeedLampOffREF01.Disable
  GSCannabisGrowRoomSeedLampOffREF02.Disable
  GSCannabisGrowRoomGrowLightREF01.Enable
  GSCannabisGrowRoomGrowLightREF02.Enable
  GSCannabisGrowRoomGrowLightREF03.Enable
  GSCannabisGrowRoomGrowLightREF04.Enable
  GSCannabisGrowRoomGrowLightREF05.Enable
  GSCannabisGrowRoomGrowLightREF06.Enable
  GSCannabisGrowRoomGrowLightREF07.Enable
  GSCannabisGrowRoomGrowLightREF08.Enable
  GSCannabisGrowRoomSeedLightREF01.Enable
  GSCannabisGrowRoomSeedLightREF02.Enable
  GSCannabisGrowRoomGrowLampOnREF01.Enable
  GSCannabisGrowRoomGrowLampOnREF02.Enable
  GSCannabisGrowRoomGrowLampOnREF03.Enable
  GSCannabisGrowRoomGrowLampOnREF04.Enable
  GSCannabisGrowRoomGrowLampOnREF05.Enable
  GSCannabisGrowRoomGrowLampOnREF06.Enable
  GSCannabisGrowRoomGrowLampOnREF07.Enable
  GSCannabisGrowRoomGrowLampOnREF08.Enable
  GSCannabisGrowRoomSeedLampOnREF01.Enable
  GSCannabisGrowRoomSeedLampOnREF02.Enable
endif

end

 

 

Link to comment
Share on other sites

You want to use "enable parenting". Pick one light to be the parent. This is the one your switch will enable or disable. For each other light, select the "enable parent" tab and set the parent of this light to your parent light. Then all the lights will enable or disable together.
Link to comment
Share on other sites

OK quick step by step of how ive achieved this.

 

1. Add a reference of an ON light

2. Add a reference of an OFF light

3. Add your light emitter

4. Add your Activator (switch) you have to be able to add a script to it.

5. Make the ON light a persistant reference and disabled by default.

6. add your script to the switch, should be something like on activate if linked ref is disabled enable linked ref else disable linked ref (give a heads up if you want the script, you should use the "activate" function in the script to simulate the switch animation after each enable or disable)

7. add linked ref on the switch to the ON light.

8. Add parent ON light to the OFF light and make sure you set to "opposite enable state of parent" and "pop in"

9. set parent of light emmiter to the ON light (dont set anything for opposite or pop in leave them unchecked) but make sure they are disabled by default

10. any extra lights you want to run off this setup, just make the ON and OFF and emitter lights children of the main ON light with all the OFF versions being "opposite enable state" and "pop in"

11. Make sure all the extra ON lights and emitters are disabled by default.

 

So what happens is you wil be in your worldspace with all the OFF light models showing, the on lights and emitters are disabled by default so they wont be in view, you activate the switch, the script runs (with the activate function in it the switch will animate) it will then enable the main ON light, all the other ON lights which are children will then also come on, the OFF lights set to opposite enable state will then disable (as the ON light is enabled) the emitters at the same time being children of the main on light have also come on, your world is lit, turning the switch off will have the opposite effect.

 

I have a mod in the works called OpenDoors which has some light switches (hopefully releasing new version tonight) which are also dependant on power being on for the building. (so 1 big switch to get power on for the building, if the generator is running....then smaller switches that control lights in each room) If youre still having problems i suggest downloading it and opening it up and seeing how ive done it.

 

Hope that helps.

 

Mike

Edited by mjskull
Link to comment
Share on other sites

  • Recently Browsing   0 members

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