Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-06-2009, 10:53 PM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Timeout problem

I'm doing a simple Levitation script just for fun.
For some reason, everything except the timeout works.
Even when I change the name of the timeout to something like "onAir" and use "scheduleEvent(0.05,"Air",null);" or changing the name of the timeout to "Air" and using "sleep(0.05); Air();" it just won't work.
Here's what I've got. Also, I don't care if you use this on your own server, just give me credit.
PHP Code:
//Scripted by Novice
//#CLIENTSIDE
function onCreated() {
  
this.rep = {"walk","grab","pull","push","sit"};
  
this.air 0;
  
player.0;
  
setTimer(0.05);
}

function 
onWeaponFired() {
  if (
this.air == 0) {
    
this.air 1;
    for (
i=0i<this.rep.size(); i++)
      
replaceAni(this.rep[i],"idle");
  }
  else if (
this.air in {1,2}) {
    
this.air 0;
    for (
i=0i<this.rep.size(); i++)
      
replaceAni(this.rep[i],this.rep[i]);
  }
}

function 
onTimeOut() {
  if (
player.== && this.air != 0)
    
this.air 2;
  if (
player.== && this.air != 0)
    
this.air 1;
  if (
this.air == 1)
    
player.+= 0.05;
  else if (
this.air == 2)
    
player.-= 0.05;
  else if (
this.air == && player.0)
    
player.-= 0.05;
  
setTimer(0.05);

Is there anything that looks wrong in there?

Last edited by Novice; 03-06-2009 at 11:24 PM..
Reply With Quote
  #2  
Old 03-06-2009, 11:13 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
I don't see this.stage being defined anywhere, yet it's in two of your conditional checks. So, I took it out, and the effect is a small up-and-down movement.

PHP Code:
function onTimeout() {
  if (
player.== 2)
    
this.air 2;
  if (
player.== 1)
    
this.air 1;
  if (
this.air == 1)
    
player.+= 0.05;
  else if (
this.air == 2)
    
player.-= 0.05;
  else if (
this.air == && player.0)
    
player.-= 0.05;
  
setTimer(0.05);

__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #3  
Old 03-06-2009, 11:23 PM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Quote:
Originally Posted by LoneAngelIbesu View Post
I don't see this.stage being defined anywhere, yet it's in two of your conditional checks. So, I took it out, and the effect is a small up-and-down movement.

PHP Code:
function onTimeout() {
  if (
player.== 2)
    
this.air 2;
  if (
player.== 1)
    
this.air 1;
  if (
this.air == 1)
    
player.+= 0.05;
  else if (
this.air == 2)
    
player.-= 0.05;
  else if (
this.air == && player.0)
    
player.-= 0.05;
  
setTimer(0.05);

Ah, I had this.stage from an earlier version.
Even with that changed, it still won't work.
Reply With Quote
  #4  
Old 03-06-2009, 11:25 PM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Novice View Post
Ah, I had this.stage from an earlier version.
Even with that changed, it still won't work.
The only other thing I changed was the deployment method. I used onPlayerChats(), because the onWeaponFired() key in being used on Valikorlia, already.

So, it could possibly be a problem with the way you are deploying. Have you tried using onKeyPressed()?
__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote
  #5  
Old 03-06-2009, 11:35 PM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Quote:
Originally Posted by LoneAngelIbesu View Post
The only other thing I changed was the deployment method. I used onPlayerChats(), because the onWeaponFired() key in being used on Valikorlia, already.

So, it could possibly be a problem with the way you are deploying. Have you tried using onKeyPressed()?
I had put up a check system with setting player's chat after setting this.air , "player.chat = this.air;" seemed to work setting your chat to "0" or "1".
Reply With Quote
  #6  
Old 03-06-2009, 11:42 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
I don't see why you need an always running timeout loop.

You should make a check so it only runs while active/levitating, and doesn't run at all when not active/levitating. Just a tip.
__________________
Reply With Quote
  #7  
Old 03-07-2009, 07:26 PM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Fixed the problem: GServer needed to restart
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 07:16 PM.


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