Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Moving Light Script isn't working more than twice?


JulianSull
 Share

Recommended Posts

scn 00MovingLight

float timer

float fQuestDelayTime

ref thing

begin GameMode

set fQuestDelayTime to 1

set thing to getSelf

set timer to timer + getSecondsPassed

if ( timer == 3 )

thing.disable

thing.moveTo 00Target1

thing.enable

else if ( timer == 7 )

thing.disable

thing.moveTo 00Target2

thing.enable

else if ( timer == 10 )

thing.disable

thing.moveTo 00Target3

thing.enable

else if ( timer == 13 )

thing.disable

thing.moveTo 00Target4

thing.enable

else if ( timer == 17 )

thing.disable

thing.moveTo 00Target5

thing.enable

else if ( timer == 20 )

thing.disable

thing.moveTo 00Target3

thing.enable

else if ( timer == 23 )

thing.disable

thing.moveTo 00Target1

thing.enable

else if ( timer == 26 )

thing.disable

thing.moveTo 00Target2

thing.enable

else if ( timer == 28 )

thing.disable

thing.moveTo 00Target5

thing.enable

else if ( timer == 30 )

thing.disable

thing.moveTo 00Target4

thing.enable

set timer to 0

endif

end

Beautiful code. Why does it not like me? I have a red light that is suppose to move from target to target every 3 or 4 seconds but instead it for some reason skips right to 00Target2 and stops. It never goes to the first one as far as I know. I know there is definitely no second instance of any of the target X markers (00Target1-5 are X markers) and I am definitely referencing the moving light when this code activates. Am I missing something?

Link to comment
Share on other sites

scn 00MovingLight


float timer

float fQuestDelayTime

ref thing


begin GameMode

	set fQuestDelayTime to 1

     set thing to getSelf

     set timer to timer + getSecondsPassed

     if ( timer == 3 )

          thing.disable

		thing.moveTo 00Target1

          thing.enable

	else if ( timer == 7 )

          thing.disable

          thing.moveTo 00Target2

          thing.enable

	else if ( timer == 10 )

          thing.disable

		thing.moveTo 00Target3

          thing.enable

	else if ( timer == 13 )

          thing.disable

		thing.moveTo 00Target4

          thing.enable

	else if ( timer == 17 )

          thing.disable

		thing.moveTo 00Target5

          thing.enable

	else if ( timer == 20 )

          thing.disable

		thing.moveTo 00Target3

          thing.enable

	else if ( timer == 23 )

          thing.disable

		thing.moveTo 00Target1

          thing.enable

	else if ( timer == 26 )

          thing.disable

		thing.moveTo 00Target2

          thing.enable

	else if ( timer == 28 )

          thing.disable

		thing.moveTo 00Target5

          thing.enable

	else if ( timer == 30 )

          thing.disable

		thing.moveTo 00Target4

          thing.enable

		set timer to 0

	endif



end

Link to comment
Share on other sites

you Reference name starts with a number.

change 00Target1 (and all the targets) so that they start with a letter.

any reference name or objectID cannot start with a number, the CS gets confused by it.

EDIT: Same goes for the script name at the top....any ID in the CS cannot start with a number.

Link to comment
Share on other sites

Tried it again and I even changed the light that I'm moving around to not have the 00 at the beginning. When I fixed all of them, it just flat out refused to move =/.

EDIT: The reference Variable is now MovingLight123 but it's actual name I guess is 00AmbientYellow. Does that matter?

Edited by JulianSull
Link to comment
Share on other sites

Tried it again and I even changed the light that I'm moving around to not have the 00 at the beginning. When I fixed all of them, it just flat out refused to move =/.

EDIT: The reference Variable is now MovingLight123 but it's actual name I guess is 00AmbientYellow. Does that matter?

yep, you need to remove the 00 from everything you've given an ID to. Scriptname, objects, variables, references everything. The CS/game gets confused as it thinks you are talking about a formID, or something to do with the mod load order.

most modders put 'aaa' in front of their ID to make them appear at the top of the lists.

Link to comment
Share on other sites

still not working, then ont ot the next thing, your if statements.

You are using == ... generally not a good idea with a timer, as it will return a float, if that timer gets even 0.01 off the true seconds...then your == will retrun as false.

because you have a quest script with 1 second delay there might be a quick fix. simply change your timer to a short instead of float...this will round it out each time the getsecondspassed runs, because it will run every second, it should then return timer = timer + 1 every time.

give it a go and tell me what happens.

I only have to worry about this if it is affected by code right? Every other one of the...lots...of objects I created don't need to be changed right?

...errr...you might be able to get away with it, as long as those objects arent going ot be effected by scripts. Just remember in future to name starting with a letter, it'll help avoid any isses with it.

Link to comment
Share on other sites

Ok so here is what I have now:

 scn MovingLight


short timer

float fQuestDelayTime

ref thing


begin GameMode

	set fQuestDelayTime to 1

     set thing to getSelf

     set timer to timer + getSecondsPassed

     if ( timer == 3 )

          thing.disable

		thing.moveTo TargetArrows1

          thing.enable

	else if ( timer == 7 )

          thing.disable

          thing.moveTo TargetArrows2

          thing.enable

	else if ( timer == 10 )

          thing.disable

		thing.moveTo TargetArrows3

          thing.enable

	else if ( timer == 13 )

          thing.disable

		thing.moveTo TargetArrows4

          thing.enable

	else if ( timer == 17 )

          thing.disable

		thing.moveTo TargetArrows5

          thing.enable

	else if ( timer == 20 )

          thing.disable

		thing.moveTo TargetArrows3

          thing.enable

	else if ( timer == 23 )

          thing.disable

		thing.moveTo TargetArrows1

          thing.enable

	else if ( timer == 26 )

          thing.disable

		thing.moveTo TargetArrows2

          thing.enable

	else if ( timer == 28 )

          thing.disable

		thing.moveTo TargetArrows5

          thing.enable

	else if ( timer == 30 )

          thing.disable

		thing.moveTo TargetArrows4

          thing.enable

		set timer to 0

	endif



end

My light is called aaaAmbientYellow. My XMarkers are called XMarkers with a ref ID of TargetArrows1-5. Nothing effected by script for this area has 00 anywhere. The light doesn't move from it's original position. =/

Link to comment
Share on other sites

well this would be a good way to test if its a timer problem, try this code. All it is, is because your script will only run 1 time every second, use that as the timer, each time it runs, add 1. Give it a go, if it still doesnt work then I will load in the code myself and test it.

scn MovingLight


short timer

float fQuestDelayTime

ref thing


begin GameMode

     set fQuestDelayTime to 1

     set thing to getSelf

     set timer to timer + 1

     if ( timer == 3 )

          thing.disable

		thing.moveTo TargetArrows1

          thing.enable

	else if ( timer == 7 )

          thing.disable

          thing.moveTo TargetArrows2

          thing.enable

	else if ( timer == 10 )

          thing.disable

          thing.moveTo TargetArrows3

          thing.enable

	else if ( timer == 13 )

          thing.disable

          thing.moveTo TargetArrows4

          thing.enable

	else if ( timer == 17 )

          thing.disable

          thing.moveTo TargetArrows5

          thing.enable

	else if ( timer == 20 )

          thing.disable

          thing.moveTo TargetArrows3

          thing.enable

	else if ( timer == 23 )

          thing.disable

          thing.moveTo TargetArrows1

          thing.enable

	else if ( timer == 26 )

          thing.disable

          thing.moveTo TargetArrows2

          thing.enable

	else if ( timer == 28 )

          thing.disable

          thing.moveTo TargetArrows5

          thing.enable

	else if ( timer == 30 )

          thing.disable

          thing.moveTo TargetArrows4

          thing.enable

          set timer to 0

	endif

end

Link to comment
Share on other sites

I'm beginning to doubt this is a coding problem. Both of our codes seem to be fine, it's just that the light refuses to move for some reason. Should it be a persistent reference? Does the disabling thing have an effect on lights?

yes, that it! I didnt realise you were using getself on the light itself, definately would cause issues if that returning the baseID. make the reference a persistent reference, then give it a reference id (eg MyLightREF) then instead of:

set thing to getself
use
set thing to MyLightREF

on a side note, The enable/disable stuff is only for updating collision, if your light has no collsion then you dont need to disable/enable it.

Link to comment
Share on other sites

scn MovingLight


short timer

float fQuestDelayTime

ref thing


begin GameMode

	set fQuestDelayTime to 1

     set thing to MovingLightCelestial

     set timer to timer + 1

     if ( timer == 3 )

		thing.moveTo TargetArrows1

	else if ( timer == 7 )

          thing.moveTo TargetArrows2

	else if ( timer == 10 )

		thing.moveTo TargetArrows3

	else if ( timer == 13 )

		thing.moveTo TargetArrows4

	else if ( timer == 17 )

		thing.moveTo TargetArrows5

	else if ( timer == 20 )

		thing.moveTo TargetArrows3

	else if ( timer == 23 )

		thing.moveTo TargetArrows1

	else if ( timer == 26 )

		thing.moveTo TargetArrows2

	else if ( timer == 28 )

		thing.moveTo TargetArrows5

	else if ( timer == 30 )

		thing.moveTo TargetArrows4

		set timer to 0

	endif

end

Still doesn't work =/

Link to comment
Share on other sites

is the script ever running?

put a line in at the top of the gamemode block (like right above the set fquestdelaytime line):

message "Im Working!"
if that line isnt appearing then your script inst running, if it is... if that message displays, remove that line and put at the botton of the gamemode block (after all the endif):
MessageBox "Timer = %.0f" timer

each time the code runs through, it will pop up a message displaying the tiemr value, you can then see if its increasing.

Link to comment
Share on other sites

scn MovingLight


short timer

float fQuestDelayTime

ref thing


begin GameMode

     message "Yoyoyo!" <---------WORKS!!!

	set fQuestDelayTime to 1

     set thing to MovingLightCelestial

     set timer to timer + 1

     if ( timer == 3 )

		thing.moveTo TargetArrows1

          message "SUPDOG!!" <----------NEVER SHOWS UP

	else if ( timer == 7 )

          thing.moveTo TargetArrows2

	else if ( timer == 10 )

		thing.moveTo TargetArrows3

	else if ( timer == 13 )

		thing.moveTo TargetArrows4

	else if ( timer == 17 )

		thing.moveTo TargetArrows5

	else if ( timer == 20 )

		thing.moveTo TargetArrows3

	else if ( timer == 23 )

		thing.moveTo TargetArrows1

	else if ( timer == 26 )

		thing.moveTo TargetArrows2

	else if ( timer == 28 )

		thing.moveTo TargetArrows5

	else if ( timer == 30 )

		thing.moveTo TargetArrows4

		set timer to 0

	endif

end

So it's a timer issue. It's not updating correctly.

EDIT:

The timer is incrementing, but once it gets past thirty, it does NOT reset. It continues forever.

Edited by JulianSull
Link to comment
Share on other sites

thought so, fquestdelaytime doesnt work on object scripts...here, i was debugging as if it was a quest script. This script should work. At the moment it will jump straight to the first position, and the timing on some of the movments may be a bit wrong (eg, some have gaps of 4 secs, these might be turned to 3 secs while some of the 3's turned to 4 second gaps), but it should move around now.

scn MovingLight	


float timer

short toggle 

ref thing


begin GameMode

	set thing to MovingLightCelestial

	set timer to timer + GetsecondsPassed

	if ( timer < 3 && toggle == 0)

		thing.moveTo TargetArrows1

		set toggle to 1

	elseif ( timer < 7 && toggle == 1)

		thing.moveTo TargetArrows2

		set toggle to 0

	elseif ( timer < 10 && toggle == 0 )

		thing.moveTo TargetArrows3

		set toggle to 1

	elseif ( timer < 13 && toggle == 1 )

		thing.moveTo TargetArrows4

		set toggle to 0

	elseif ( timer < 17 3 && toggle == 0 )

		thing.moveTo TargetArrows5

		set toggle to 1

	elseif ( timer < 20 && toggle == 1 )

		thing.moveTo TargetArrows3

		set toggle to 0

	elseif ( timer < 23 3 && toggle == 0 )

		thing.moveTo TargetArrows1

		set toggle to 1

	elseif ( timer < 26 && toggle == 1 )

		thing.moveTo TargetArrows2

		set toggle to 0

	elseif ( timer < 28 3 && toggle == 0 )

		thing.moveTo TargetArrows5

		set toggle to 1

	elseif ( timer < 30 3 && toggle == 1 )

		thing.moveTo TargetArrows4

		set toggle to 0

		set timer to 0

	endif



end

Link to comment
Share on other sites

Didn't work =/. Does this auto initialize variables to 0? And at 10 should there be a toggle == 0?

okay, i just went through and found a few mistakes in mine. Just re-writ it so hopefully it should be working now. Also, see my previous post (one after the one with my script), it had some important in it that you might have missed. Also, i took out the thing variable...the more you can elimate when debugging, the closer you get to the problem.

scn MovingLight	


float timer

short toggle 


begin GameMode

	set timer to timer + GetsecondsPassed

	if (timer < 3 && toggle == 0)

		set toggle to 1		

	elseif (timer < 6 && toggle == 1)

		MovingLightCelestial.moveTo TargetArrows1

		set toggle to 1

	elseif (timer < 10 && toggle == 0)

		MovingLightCelestial.moveTo TargetArrows2

		set toggle to 0

	elseif (timer < 13 && toggle == 1)

		MovingLightCelestial.moveTo TargetArrows3

		set toggle to 1

	elseif (timer < 16 && toggle == 0)

		MovingLightCelestial.moveTo TargetArrows4

		set toggle to 0

	elseif (timer < 20 && toggle == 1)

		MovingLightCelestial.moveTo TargetArrows5

		set toggle to 1

	elseif (timer < 23 && toggle == 0)

		MovingLightCelestial.moveTo TargetArrows3

		set toggle to 0

	elseif (timer < 26 && toggle == 1)

		MovingLightCelestial.moveTo TargetArrows1

		set toggle to 1

	elseif (timer < 28 && toggle == 0)

		MovingLightCelestial.moveTo TargetArrows2

		set toggle to 0

	elseif (timer < 30 && toggle == 1)

		MovingLightCelestial.moveTo TargetArrows5

		set toggle to 0

	elseif (timer >= 30 && toggle == 0)

		MovingLightCelestial.moveTo TargetArrows4

		set time to 0

	endif

end

Link to comment
Share on other sites

scn MovingLight 


float timer

short toggle 


begin GameMode

        set timer to timer + GetsecondsPassed

        if (timer < 3 && toggle == 0)

                set toggle to 1         

        		 messagebox "I WORK!...KINDA1"

        elseif (timer < 6 && toggle == 3)

                MovingLightCelestial.moveTo TargetArrows1

                set toggle to 0

        		 messagebox "I WORK!...KINDA6"

        elseif (timer < 10 && toggle == 0)

                MovingLightCelestial.moveTo TargetArrows2

                set toggle to 1

        		 messagebox "I WORK!...KINDA10"

        elseif (timer < 13 && toggle == 1)

                MovingLightCelestial.moveTo TargetArrows3

                set toggle to 0

        		 messagebox "I WORK!...KINDA13"

        elseif (timer < 16 && toggle == 0)

                MovingLightCelestial.moveTo TargetArrows4

                set toggle to 1

        elseif (timer < 20 && toggle == 1)

                MovingLightCelestial.moveTo TargetArrows5

                set toggle to 0

        elseif (timer < 23 && toggle == 0)

                MovingLightCelestial.moveTo TargetArrows3

                set toggle to 1

        elseif (timer < 26 && toggle == 1)

                MovingLightCelestial.moveTo TargetArrows1

                set toggle to 0

        elseif (timer < 28 && toggle == 0)

                MovingLightCelestial.moveTo TargetArrows2

                set toggle to 1

        elseif (timer < 30 && toggle == 1)

                MovingLightCelestial.moveTo TargetArrows5

                set toggle to 0

        elseif (timer >= 30 && toggle == 0)

                MovingLightCelestial.moveTo TargetArrows4

                set timer to 0

        endif

end
I get on and it spams I WORK KINDA1 and I WORK KINDA 13. EDIT: The timer is always zero :D
 scn MovingLight 


float timer

short toggle 


begin GameMode

        set timer to timer + GetSecondsPassed

        if (timer < 3 && toggle == 0)

                set toggle to toggle + 1     

        elseif (timer < 6 && toggle == 1)

                MovingLightCelestial.moveTo TargetArrows1

                set toggle to toggle + 1     

        elseif (timer < 10 && toggle == 2)

                MovingLightCelestial.moveTo TargetArrows2

                set toggle to toggle + 1     

        elseif (timer < 13 && toggle == 3)

                MovingLightCelestial.moveTo TargetArrows3

                set toggle to toggle + 1     

        elseif (timer < 16 && toggle == 4)

                MovingLightCelestial.moveTo TargetArrows4

                set toggle to toggle + 1     

        elseif (timer < 20 && toggle == 5)

                MovingLightCelestial.moveTo TargetArrows5

                set toggle to toggle + 1     

        elseif (timer < 23 && toggle == 6)

                MovingLightCelestial.moveTo TargetArrows3

                set toggle to toggle + 1     

        elseif (timer < 26 && toggle == 7)

                MovingLightCelestial.moveTo TargetArrows1

                set toggle to toggle + 1     

        elseif (timer < 28 && toggle == 8)

                MovingLightCelestial.moveTo TargetArrows2

                set toggle to toggle + 1     

        elseif (timer < 30 && toggle == 9)

                MovingLightCelestial.moveTo TargetArrows5

                set toggle to toggle + 1     

        elseif (timer >= 30 && toggle == 10)

                MovingLightCelestial.moveTo TargetArrows4

                set timer to 0

                set toggle to 0

        endif

        MessageBox "Timer = %.0f" timer

end
This always results in "Timer = 0" and nothing moving.
scn MovingLight 


float timer

float fQuestDelayTime

begin GameMode

        set fQuestDelayTime to 1

        set timer to timer + 1

        Message "Timer = %.0f" timer

        if (timer == 3)

		      MovingLightCelestial.moveTo TargetArrows5

        elseif (timer == 6)

                MovingLightCelestial.moveTo TargetArrows1

        elseif (timer == 9)

                MovingLightCelestial.moveTo TargetArrows2

        elseif (timer == 13)

                MovingLightCelestial.moveTo TargetArrows3

        elseif (timer == 16)

                MovingLightCelestial.moveTo TargetArrows4

        elseif (timer == 20)

                MovingLightCelestial.moveTo TargetArrows5

        elseif (timer == 23)

                MovingLightCelestial.moveTo TargetArrows3

        elseif (timer == 26)

                MovingLightCelestial.moveTo TargetArrows1

        elseif (timer == 28)

                MovingLightCelestial.moveTo TargetArrows2

        elseif (timer == 30)

                MovingLightCelestial.moveTo TargetArrows5

        elseif (timer == 34)

                MovingLightCelestial.moveTo TargetArrows4

                set timer to 0

        endif

end

This is my current code. I put it in it's own quest. The timer updates fine now, but it refuses to move.

Edited by JulianSull
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...