Jump to content

Light Switch Script


TodaY

Recommended Posts

Hi everybody ;D

I've been trying to get this script running for over a week now, and I just can't seem to do it. I want to make a switch that turns a flame (activator) and "light bulb" on and off. So I made both the flame and the light bulb persistant referances, and gave them a reference ID. Then I made a script like this:

---

short stage

 

Begin onactivate

if stage == 0

REFID.disable

set stage to 1

elseif stage == 1

REFID.enable

set stage to 0

endif

end

---

(I left the anim scripting for the swich out, as that worked)

That script didn't work, so I made the flame the parent of the switch, and the lightbulb the parent of the flame, and wrote this script:

---

ref myparent

short stage

 

begin onactivate

set parent to myparent (I know parent is wrong here - I did it correct in the script, but can't think of the real command at the moment)

if stage == 0

myparent.disable

set stage to 1

elseif stage == 1

myparent.enable

set stage to 0

endif

end

---

That didn't work either, and I really don't know what I am doing wrong here.

If anyone helps me solve this problem, kudos, hugs and cookies will be given.

Execpt for I don't have cookies, and hugs are gonna be hard since you probably live in another country O.-

Happy modding, and thnks for reading! ;D

Link to comment
Share on other sites

Here is a script I made. I tested it and it works. I added the timer, because it turns out that the first and second blocks were activating simultaneously. (Or actually one a split second after the other, but within the duration of the instant which is activation.)

 

SCN AATESTLightswitch

; Object script applied to switch.

Short State
Short Timer

Begin OnActivate
If State == 0 && Timer == 0
	AATESTLight.Enable
	AATESTFire.Enable
	Set State to 1
	Set Timer to 3
EndIf

If State == 1 && Timer == 0
	AATESTLight.Disable
	AATESTFire.Disable
	Set State to 0
	Set Timer to 3
EndIf
End

Begin GameMode
If Timer > 0
	Set Timer to Timer - GetSecondsPassed
EndIf
End   

Link to comment
Share on other sites

  • Recently Browsing   0 members

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