Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Feature request
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-03-2010, 09:49 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Lightbulb SetTimer<#>(<#>);

Examples: SetTimer1(0.05); SetTimer2(1); SetTimer3(this.timer); etc.

then either something like this:
PHP Code:
function onTimeout1(){blahblah;}
function 
onTimeout2(){blahblah;}
function 
onTimeout3(){blahblah;} 
etc.

or something like this:
PHP Code:
function onTimeout(1){blahblah;}
function 
onTimeout(2){blahblah;}
function 
onTimeout(3){blahblah;} 
whichever works. setTimer(); would still be usable.
unless someone knows a better way to do this already, i've often found myself splitting up weapons into multiple weapons because i couldnt redefine onTimeout in one if(){;} and have another in an elseif(){;} (example, having my jump script change itself to a gravity script if the level is a sidescrolling level. but i couldnt do that so now i have a jump script that disables itself if its a sidescrolling level and a gravity script that activates if its a sidescrolling level. which seems like more than i needed to have.)

then, whenever i need multiple timers and cant split up the script, i also find myself doing something crude like this:

PHP Code:
function onTimeout(){

   if(
this.timer1 >= 0.05){
      
this.timer1 -= 0.05;
    }
     else {
this.timer1 1;}

   if(
this.timer2 >= 0.05){
      
this.timer2 -= 0.05;
    }
     else {
this.timer2 0.5;}

}

setTimer(0.05); 
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #2  
Old 05-03-2010, 10:00 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
First of all, nothing should go outside of function definitions (brackets).

There is also scheduleevent(time, eventname, params...).

So if you do scheduleevent(1, "Pancake", null), then function onPancake() will be called in one second. I imagine this is not quite as efficient as a timeout, so use the timeout for stuff that is 0.05.

Edit:

Also your script should have been looping at 0.5 since that is the smallest timer rather than 0.05.
__________________
Reply With Quote
  #3  
Old 05-03-2010, 10:02 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
If you wanna do what you were asking for:

scheduleevent(timer, "Timeout1", null);
Reply With Quote
  #4  
Old 05-03-2010, 10:04 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by DustyPorViva View Post
If you wanna do what you were asking for:

scheduleevent(timer, "Timeout1", null);
Yep, example:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
onTimeout1();
}
function 
onTimeout1() {
  
// do stuff
  
scheduleevent(1"Timeout1"null);

I tend to avoid calling event functions directly though.
__________________
Reply With Quote
  #5  
Old 05-03-2010, 10:06 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Inverness View Post
I tend to avoid calling event functions directly though.
Proper way to stay in the event model would be
PHP Code:
this.trigger("Timeout1"null); 
Reply With Quote
  #6  
Old 05-03-2010, 11:43 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Woah. a lot of interesting stuff here. thanks guys, I'll play around with them and see if i cant figure them out
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.