Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 12-07-2011, 01:41 AM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
setTimer is frame-based, not time-based.
Reply With Quote
  #17  
Old 12-07-2011, 02:53 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
setTimer works in a DBNPC, are you sure it's frame based?
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #18  
Old 12-07-2011, 02:58 AM
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
Quote:
Originally Posted by Hezzy002 View Post
setTimer is frame-based, not time-based.
It is time-based... a timer of 0.05 triggers every 0.05 seconds. Graal is 20fps, meaning it's running at 20 frames a second, so 1 second / 20 frames = 0.05, or the lowest timeout possible.
Reply With Quote
  #19  
Old 12-07-2011, 03:08 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Gunderak View Post
setTimer works in a DBNPC, are you sure it's frame based?
Frame-based in the sense that the timeout value decreases by (1 / Max FPS). On the server-side the Max FPS is 10, and on the client-side it's 20 (Like Dusty mentioned).

That is why it's useless to set timeouts lower than 0.1 on the server-side and 0.05 on the client-side. (Depending on the application you should be using the highest or no timeout at all if possible).

Play with this script:

Graal Script Code:
function onCreated() {
  
this.test timevar2;
  
this.speed 0.05;
  
setTimer(this.speed);
}

function 
onTimeout() {
  echo(
timevar2 this.test);
  
this.test timevar2;
  
setTimer(this.speed);

Both 0.05 and 0.1 will return similar values.
__________________
Quote:

Last edited by fowlplay4; 12-07-2011 at 03:26 AM..
Reply With Quote
  #20  
Old 12-07-2011, 06:28 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Send a message via Skype™ to Gunderak
Ah I see.
So it's not actually controlled by when the game enters a new frame.
I was confused for a bit there lol.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #21  
Old 12-07-2011, 04:48 PM
Hezzy002 Hezzy002 is offline
Registered User
Join Date: Jul 2011
Posts: 247
Hezzy002 is a jewel in the roughHezzy002 is a jewel in the rough
Quote:
Originally Posted by DustyPorViva View Post
It is time-based... a timer of 0.05 triggers every 0.05 seconds. Graal is 20fps, meaning it's running at 20 frames a second, so 1 second / 20 frames = 0.05, or the lowest timeout possible.
I don't mean frame-based in the sense that you input frame values, I mean that it doesn't compare against the computer's clock; it just subtracts .05 from a value each frame and runs the function when it hits zero, and thus is less reliable for anything that's time-based instead of frame-based.
Reply With Quote
  #22  
Old 12-07-2011, 05:27 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Maybe it┤s just me, but why not use this check?
Graal Script Code:
function onTimeout() {
  if (
this.secondsleft <= 0) {
    
//stuff
  
}
  
settimer(1);

__________________
MEEP!
Reply With Quote
  #23  
Old 12-26-2011, 08:20 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Question, you have 2 timeouts. One for actually counting down, and one for showing the time. Correct me if I am wrong but wouldn't it be better to just calculate the time with timevar/timevar2 in the timeout to show the variable?
Reply With Quote
  #24  
Old 01-24-2012, 04:34 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano can only hope to improve
Quote:
Originally Posted by scriptless View Post
Question, you have 2 timeouts. One for actually counting down, and one for showing the time. Correct me if I am wrong but wouldn't it be better to just calculate the time with timevar/timevar2 in the timeout to show the variable?
Didn't read through the posts, but you can't "count time" inside a timeout anyway, because if you set the timeout to 0.1, it doesn't mean that it will actually be called after 0.1 seconds, it may be called after 0.5 seconds depending on the performance...
Reply With Quote
  #25  
Old 01-24-2012, 04:39 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Pelikano View Post
Didn't read through the posts, but you can't "count time" inside a timeout anyway, because if you set the timeout to 0.1, it doesn't mean that it will actually be called after 0.1 seconds, it may be called after 0.5 seconds depending on the performance...
If you're setting the timer to 0.1, it will be called approximately 0.1 seconds later. You can count time with the use of a timeout, but the longer you are doing this, the less accurate it will get.
__________________
Reply With Quote
  #26  
Old 01-24-2012, 06:57 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano can only hope to improve
Quote:
Originally Posted by Crow View Post
If you're setting the timer to 0.1, it will be called approximately 0.1 seconds later. You can count time with the use of a timeout, but the longer you are doing this, the less accurate it will get.
it will be called @ the next frame when your timer time is over, which means that if a frame takes 0.5 second due to lag or anything your counter will be wrong
Reply With Quote
  #27  
Old 01-24-2012, 08:20 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Pelikano View Post
it will be called @ the next frame when your timer time is over, which means that if a frame takes 0.5 second due to lag or anything your counter will be wrong
Duh.
__________________
Reply With Quote
  #28  
Old 01-24-2012, 09:56 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
Quote:
Originally Posted by Pelikano View Post
Didn't read through the posts, but you can't "count time" inside a timeout anyway, because if you set the timeout to 0.1, it doesn't mean that it will actually be called after 0.1 seconds, it may be called after 0.5 seconds depending on the performance...
You can, but it's not as accurate. That is why I asked, would it not be better to just use timevar/timevar2?
Reply With Quote
  #29  
Old 01-24-2012, 11:49 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
Quote:
Originally Posted by Gunderak View Post
Well I'm going to have to disagree with you there.
"Does not make it harder to read".
If anything it defines what you are assigning the variable to clearer.
And it does not change the way the script functions at all.
is this real life
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 10:39 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.