
-----------------------------------
kythoon
Wed May 21, 2003 5:21 pm

timer to call procedure
-----------------------------------
Is there a way to make a timer, that isn't show, that when it hits zero it calls a certain procedure?

-----------------------------------
Solo
Wed May 21, 2003 5:29 pm

Timer
-----------------------------------

process Timer (tim : int) %Time in seconds you want to delay
    loop
        delay (tim * 1000)
        %Put the proc you wanna run in here
        %Also prolly wanna stick an exit condition in here
    end loop
end Timer


fork Timer (50) %Runs the procedure every 50 seconds


Remember, if you use this method, you need to make a different time for every procedure you want to use a timer with.

-----------------------------------
nate
Wed May 21, 2003 5:29 pm


-----------------------------------
procedure done
put "Done"
end done

for i:1..10
       delay (1000)
            if i = 10 then
                  done
             end if
end for
*This is the same as timing for 10 seconds
When it reaches 10 or basically 0 if you counted down

it runs the procedure!

-Nate

-----------------------------------
Solo
Wed May 21, 2003 5:37 pm

Timer again
-----------------------------------
Yes, that technically does a timer function, but also that stops the program at that place, usually a timer needs to be running simotaniusly with the rest of the program, i suggest using the process so you can have it running in the background.

-----------------------------------
kythoon
Wed May 21, 2003 5:55 pm


-----------------------------------
ic what you mean but how would you use it with it were in a loop, this is for if a character was moving around, and say after 5 seconds a monster poped up, using the procedure. How would you do that? 

with fork?

-----------------------------------
Catalyst
Wed May 21, 2003 5:56 pm


-----------------------------------
dont use processes 
cant stress that enough

-----------------------------------
Solo
Wed May 21, 2003 6:08 pm

Why not?
-----------------------------------
If you want to make a monster pop up every 5 seconds, you would do something like this :

process Timer (tim : int) %Time in seconds you want to delay
    loop
        delay (tim * 1000)
        monsterePop
        exit when gamequit
    end loop
end Timer


fork Timer (50)

loop %mainloop
     All your stuff in here
end loop



And why not use processes? as long as you have a good understanding of how they work, even in turing they can be put to good use. Especially in graphics applications.

-----------------------------------
kythoon
Wed May 21, 2003 6:09 pm


-----------------------------------
why not?

then how?  :?:

-----------------------------------
Solo
Wed May 21, 2003 6:14 pm

Hehehe :)
-----------------------------------
Sometimes i think faster than i type, hehe. I meant to ask Catalyst why not to use processes, but then i just answered your question first :)

-----------------------------------
Tony
Wed May 21, 2003 6:27 pm


-----------------------------------
well we had a discussion about that already... more then once I think...

basically processes dont run parallel to the program... its more like a random choice between which procedure to run in what order... if you look in the help file, they actually make a process racing game where they run 10 identical processes at same time and whichever comes to a sertain count first wins... you'll be surpriced at the difference in results  :shock: 

it will also mess up your global values and potentially can cause the program to crash or not run properly

-----------------------------------
kythoon
Wed May 21, 2003 6:28 pm


-----------------------------------
ok thanks

-----------------------------------
Solo
Wed May 21, 2003 6:30 pm

Never had a problem.
-----------------------------------
I have actually not had much problem with them, I dont think Mazer has either, infact his game (Evasive manuvers) is basically completely processes.

When I get to school tommorrow i will post my Matrix program that draws pictures in different coloured matrix symbols, it is completly done in processes.

-----------------------------------
Catalyst
Wed May 21, 2003 6:35 pm


-----------------------------------
bottom line processes are messy and anything that you can do with them, you can do without them
