Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-24-2009, 01:20 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
if (timeout)

PHP Code:
function onBla() {
if (
timeout) {
bla!
 }

why this isnt working?
for example:
PHP Code:
//#CLIENTSIDE
function onPlayerChats() {
 if (
player.chat == "Test") {
  
onTestTime();
  
settimer(0.05);
 }
}

function 
onTimeout() {
settimer(.05);
}

function 
onTestTime() {
  
sendtorc("works?");
 if (
timeout) {
  
settimer(.05);
  
sendtorc("timeout?");
 }
  
onTestTime();
  
settimer(0.05);

I know, the script itself is useless, but it MUST have a timeout, doesnt it? So, it sends the "works?" like a spam, but NO "timeout?"

someone can explain why?
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #2  
Old 04-24-2009, 02:25 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
if (timeout) {}

equals

function onTimeout() {}

when using the timeout event
__________________
Reply With Quote
  #3  
Old 04-24-2009, 03:37 PM
Schetti Schetti is offline
SC2 Player
Schetti's Avatar
Join Date: Nov 2008
Location: Austria
Posts: 269
Schetti is on a distinguished road
I know that, but I am wondering why if (timeout) {} isnt working
__________________
“Peace cannot be kept by force. It can only be achieved by understanding.” – Albert Einstein
Reply With Quote
  #4  
Old 04-24-2009, 03:50 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Schetti View Post
I know that, but I am wondering why if (timeout) {} isnt working
Because...


1) You're overwriting it with function onTimeOut()

2) You shouldn't place events inside other events. Even though GS1 allowed it for the most part, it's really bad practice.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 04-24-2009, 04:04 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Schetti View Post
I know, the script itself is useless, but it MUST have a timeout, doesnt it? So, it sends the "works?" like a spam, but NO "timeout?"

someone can explain why?
onTestTime gets first executed without a timeout set, so there is no chance that "if (timeout)" is true at that point. So the settimer inside the if-block is not being executed either. Consequently the recursive call to onTestTime also happens without a timeout being active, and we basically start from the beginning over and over again until you run out of stack space and the recursion terminates. At that point, the script might either error out or go to the next statement, not sure. If the latter is the case, you will finally set your timer and onTimeout() will be called 0.05 seconds later, setting the timer again and continuing the timeout loop. Since onTimeout is not calling onTestTime, your "if (timeout)" check is not going to be executed anymore and the sendtorc still does not happen.

Your expectation that something different happens implies that you think there is some magic going on that is not actually there.

Last edited by Loriel; 04-24-2009 at 04:16 PM..
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 11:48 PM.


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