timer script

Post » Fri Feb 18, 2011 11:41 pm

hey,

I'm having trouble with this timer script.

scn blah

(floats and the like here( variables) )

begin gamemode

set fQuestDelayTime 0.001


if ( DoOnce01 )
return
elseif ( timer == 1 )
set timer to timer + getsecondspassed
else
set cityofsoulsAI to 1
AASkeletonSpawn.placeatme AASkeletonSoldier, 1
SoulStorage.additem Soul, 1
set DoOnce01 to 1
endif
endif
if ( DoOnce02 )
return
elseif ( timer == 4 )
set timer to timer + getsecondspassed
else
AASkeletonSpawn.placeatme AASkeletonSoldier, 1
SoulStorage.additem Soul, 1
set DoOnce02 to 1
endif
endif


if ( DoOnce03 )
return
elseif ( timer == 6 )
set timer to timer + getsecondspassed
else
SoulStorage.additem Soul, 1
set DoOnce03 to 1
endif
endif


if ( DoOnce05 )
return
elseif ( timer == 8 )
set timer to timer + getsecondspassed
else
SoulStorage.additem Soul, 1
set DoOnce05 to 1
endif
endif

if ( DoOnce06 )
return
elseif ( timer == 10 )
set timer to timer + getsecondspassed
else
SoulStorage.additem Soul, 1
set DoOnce06 to 1
endif
endif

if ( DoOnce07 )
return
elseif ( timer == 12 )
set timer to timer + getsecondspassed
else
SoulStorage.additem Soul, 1
set DoOnce07 to 1
endif
endif

end

The problem is that it adds all the "Souls" into the container at the moment the conditions begin ( note, I didn't put those if statments into this thread) rather then just one then wait two seconds then add another etc. Any help would be helpful!

Sil
User avatar
Sarah Unwin
 
Posts: 3413
Joined: Tue Aug 01, 2006 10:31 pm

Post » Fri Feb 18, 2011 7:57 pm

Try posting your script in [ codebox ] [ /codebox ] tags (without those extra spaces). Your indentation will be preserved, making your script easier to read, making it more likely you'll get help.
User avatar
yessenia hermosillo
 
Posts: 3545
Joined: Sat Aug 18, 2007 1:31 pm

Post » Sat Feb 19, 2011 3:55 am

Jeez.... where to begin....
ok, first of all I doubt that would even compile, you have an extra endif at the end of each block. Second what that script is doing is adding 7 souls in the container, practically at the same time. You are checking for the wrong things and in the wrong order. Besides setting fQuestDelayTime to such a low number is not necessary. fQuestDelayTime= .1 should be more than enough.

Now, This is what is really going on:

;The engine executes each instruction one by one.if (doOnce0X)							;is there something in doOnceX	- noelseif (timer == X)   				 		;is timer == X			- noelse								;then do thisset cityofsoulsAI to 1						;store the number 1 into the variable "cityofsoulsAI"	AASkeletonSpawn.placeatme AASkeletonSoldier, 1			;place 1 "AASkeletonSoldier" where "AASkeletonSpawn" isSoulStorage.additem Soul, 1					;add one soul to SoulStorage	set DoOnce01 to 1						;store the number 1 into the variable "cdoOnceX" 	;;And this goes on 7 times,  then,  on the second iteration the script won't anything else, it will go like this:if (doOnce0X)			;is there something in doOnceX  -this time the answer is yesreturn				;then exit


I don't really know what you are trying to do, but according to what the script is doing and what you say, we got this:

scn blahshort doOnceshort timerBegin GameMode	if (doOnce == 0)		set fQuestDelayTime 0.1		set doOnce to 1	endif	if ( timer >= 2 )		set cityofsoulsAI to 1		AASkeletonSpawn.placeatme AASkeletonSoldier, 1		SoulStorage.additem Soul, 1		set timer to 0	else		set timer to timer + getsecondspassed		endif		End 


Assuming cityofsoulsAI is a global, this should work. However,it will add the souls into the container every 2 seconds, constantly, forever, it will never stop. If you want to control when to add them and when to stop you need to set another condition, or even better change the begin block to something other than gameMode, preferably OnActivate and then attach the script to an object. It all depends on what you are trying to do
User avatar
vicki kitterman
 
Posts: 3494
Joined: Mon Aug 07, 2006 11:58 am


Return to IV - Oblivion