Still not completely sure, but looks like you are trying to use setinterval, not the timer.
So what timer does is this: (Im not sure this works, as this is just theoretical)
Code: Select all
Starttimer(1)
...
do stuff
...
a = Gettimer(1)
print(a)
results in for example number 100 printed out, supposing it took 100 milliseconds to run it.
Idea in this example is, that you are like having one of those stopwatches they use in sports to measure how long it took for someone to run the distance. This stopwatch you have is numbered as number 1. When you use command "Starttimer(1)" it tells hollywood to push the button of stopwatch number 1, which means that the number on that watchclock starts increasing.
Then you do what ever stuff you do, and finally you use command "Gettimer(1)" to get the time that watchclock number 1 is at that moment showing.
So if it took runner 10 seconds to run the 100 meters, then the stopwatch will be showing 10 seconds in it.
Bu using "resettimer(1)" it will tell to reset the stopwatch number 1 back to 0 and start its timing from beginning.
But what I believe you are after is following:
Code: Select all
Function MyFunc()
debugprint("hello world")
EndFunction
setinterval(1, MyFunc, 1000)
WaitEvent
What this code does in practice, is to print "Hello World" once a second.
Idea is that code is halter until some event happens. As there is no event to happen, this code will continue for ever.
However, before "WaitEvent" happens, I have used "Setinterval" command to set something to happen while waiting for that event to happen.
SetInterval has three arguments. First one is the ID for this interval (soon more about that), second argument tells which function should be the function to be executed while waiting for event to happen. and third one tells how often this function should be executed, where 1 000 is same as once in 1 000 milliseconds = once per second.
If you put third argument as 1, then that function will be executed once per millisecond, which is very fast.
Notice, that although you might want something to be executed once per millisecond, it might not in practice be executed that fast. For the point with that number is that Hollywood tries to execute it that fast, but might be you computer is not fast enough to do that function once every millisecond, in which case it will simply be executed as often as possible.
To get back to ID part, you can have several intervals executed while WaitEvent is happening:
Code: Select all
Function MyFirstFunc()
debugprint("hello world")
EndFunction
Function MySecondFunc()
debugprint("Second funtion")
EndFunction
setinterval(1, MyFirstFunc, 1000)
SetInterval(2, MySecondFunc, 500)
WaitEvent
This would result in something like:
Second Function
Second function
Hello World
Second Funtion
Second function
Hello world
second funtion
second funtion
hello world
...
Reason for this is that it tells to execute MySecondFunc every half a second, which results in debugprinting "second function" while executing MyFirstFunc only once per second.
Notice that these both have own ID, this means that if there would come "ClearInterval(2)" then after that point, MySecondFunc wouldnt be executed anymore at waitevent, but only MyFirstFunc which has ID 1 would be exexcuted anymore.
To achieve what I think you are looking to achieve, It seems solution would be something like this:
Code: Select all
a=0
Function p_ChangePicture
A=A + 1
IF A=30 then A = 0
DisplayBrush(A, 0, 0)
EndFunction
SetInterval(1, p_ChangePicture, 400)
waitevent()
Now it would keep displaying different picture every 400 milliseconds (2.5 times per second). If you wish the change take longer, just change the 400 to something bigger.
Idea is that you will be having variable A which would be storing a number. At beginning you set it to 0.
Each time this p_ChangePicture function is executed variable A is increased by 1. In case variable A reaches number 30 (you said 30 pictures), then it is changed back to 0.
After this variable A is used in displaying brush, which means it will be different brush each time, since A will be different each time.
Was this what you needed?