Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-13-2005, 06:12 PM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
gs2 obstacles

I am getting the hang of gs2, but there are a couple of situations that I have not been able to find a way around.

(all examples //#CLIENTSIDEd)

Old gscript : you can check for created and playerenters in one line
NPC Code:

if (created || playerenters)
{
loadmap mymap; // or whatever;
}



but how do you check for multiple events with gs2 other than this cumbersome repetition?
NPC Code:

function onCreated()
{
loadmap mymap;
}

function onPlayerenters()
{
loadmap mymap;
}




Also, how do you have two separate timeout loops in one npc that operate intependently depending on a boolean flag (variable that is 1 or 0)

Old gscript example
NPC Code:

if (created)
{
this.on=0;
timeout=.05;
}

if (timeout && this.on==0)
{
if (event happens like a keydown to switch flag to the other loop)
{
this.on=1;
}
timeout=.05;
}

if (timeout && this.on==1)
{
if (event like a different keydown to switch to the initial loop)
{
this.on=0;
}
timeout=.05;
}



This script woked fine, and then it was unchanged when my server was switched to gscript2, then it did not function in switching to the second timeout loop.
I tried switching it to gscript2, even changing the flag to a client.string and breaking the timeout loops into two separate npcs and it still did not work.
Why not???

example of gs2
NPC Code:

function onCreated()
{
this.on=0;
timeout=.05;
}

function onTimeout()
{
if (this.on==0)
{
if (keydown event triggered)
{
this.on=1;
}
}

if (this.on==1)
{
if (keydown event triggered)
{
this.on=0;
}
}
timeout=.05;
}



I also tried it with 2 separate timeout loops

NPC Code:

function onCreated()
{
this.on=0;
timeout=.05;
}

function onTimeout()
{
if (this.on==0)
{
if (keydown event triggered)
{
this.on=1;
}
}
timeout=.05;
}

function onTimeout()
{
if (this.on==1)
{
if (keydown event triggered)
{
this.on=0;
}
}
timeout=.05;
}




and neither one of those worked ... what am I doing wrong???
the first timeout is to see if an "on" key is pressed and to hide images,
The second timeout is to show the images and allow the image positions to be changed through a function if other keys are pressed, and to see if the "off" key is pressed.

Any help would be appreciated
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such

Last edited by prozac424242; 10-13-2005 at 07:44 PM..
Reply With Quote
 


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 09:53 AM.


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