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 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
  #2  
Old 10-13-2005, 07:06 PM
Silent Silent is offline
<3
Silent's Avatar
Join Date: Mar 2005
Location: England
Posts: 132
Silent is on a distinguished road
Send a message via AIM to Silent Send a message via MSN to Silent
Quote:
Originally Posted by prozac424242
NPC Code:

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



but how do you check for multiple events with gs2 other than this cumbersome repetition?
PHP Code:
function onCreated () {
  
doloadmap();
}

function 
onPlayerenters() {
  
doloadmap();
}

function 
doloadmap() {
  
loadmap("mymap");

I hope this isn't a literal example though - you only need to load the map once
__________________
Quote:
Originally Posted by MilkyWay0016
The Bible also says things like...

"Stone disobedient children" (Deuteronomy 21:18-21)
Quote:
Originally Posted by Loriel
Disobedient children are likely enough to get stoned already, I think.
Reply With Quote
  #3  
Old 10-13-2005, 07:19 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Silent
PHP Code:
function onCreated () {
  
doloadmap();
}

function 
onPlayerenters() {
  
doloadmap();
}

function 
doloadmap() {
  
loadmap("mymap");

I hope this isn't a literal example though - you only need to load the map once
Can also try something like:
PHP Code:
function onCreated()
{
  
loadMap("myMap");
}

function 
onPlayerEnters()
{
  
onCreated();

As for the timeouts, those aren't really 'loops', as you don't have 'timeout = 0.05;' or setTimer(0.05);
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #4  
Old 10-13-2005, 07:46 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
oops - forgot to add the timeout reset!
re-read the code above, it now shows the timeouts as loops where appropriate.
__________________

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
Reply With Quote
  #5  
Old 10-13-2005, 08:39 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
HTML Code:
//#CLIENTSIDE
function onCreated()
{
  this.on = false;
  this.setTimer(0.05);
}

function onTimeout()
{
  if (this.on == false)
  {
    if (someCheck())
    {
      this.on = true;
    }
  }
  else
  {
    if (someOtherCheck())
    {
      this.on = false;
    }
  }
  
  this.setTimer(0.05);
}
Reply With Quote
  #6  
Old 10-14-2005, 04:08 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Just a general question...

Is it bad if you don't use this.setTimer(float)?
(ex: setTimer(float)

I'm guessing that it wouldn't be, since commands without the "this." prefix are already being called to the current 'object'?
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.

Last edited by napo_p2p; 10-14-2005 at 04:25 AM..
Reply With Quote
  #7  
Old 10-14-2005, 07:45 AM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Quote:
Originally Posted by napo_p2p
Just a general question...

Is it bad if you don't use this.setTimer(float)?
(ex: setTimer(float)

I'm guessing that it wouldn't be, since commands without the "this." prefix are already being called to the current 'object'?
Correct.

I do it in accordance to Era's Scripting Guidelines.
Reply With Quote
  #8  
Old 10-15-2005, 03:01 AM
ChibiChibiLuc ChibiChibiLuc is offline
Cookie Monster. :3
Join Date: Jan 2005
Location: Nova Scotia, Canada
Posts: 111
ChibiChibiLuc is on a distinguished road
Send a message via AIM to ChibiChibiLuc Send a message via MSN to ChibiChibiLuc
object.catchevent(name,event,newevent);

It calls 'newevent' every time 'event' is called.
It's main use is in GUI Controls, when you use a for() to create multiple buttons. You can use a catchevent to make clicking each button call the same event.

npc.catchevent(#N,"onPlayerEnters","onCreated");
This calls 'onCreated' each time 'onPlayerEnters' is called.

By the way, I only think npc. is required when it's used in an NPC Weapon. I don't know for sure, as I haven't tried it without the npc. prefix.
Reply With Quote
  #9  
Old 10-15-2005, 06:16 AM
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
New question: I have tried for hours to get a very simple thing to work:
when you enter a level, your y is set to 0 and is increased through a timeout.
this part works fine.
What I can't get to work is when the playery is greater than 55 it warps the player to another level.

Since the timeout and playery manipulation is clientside,
and setlevel2 is serverside, I need a triggeraction, right?
I have tried to no avail:
-putting the whole script as a serverside event
-doing a triggeraction in the npc that is in the level on the npc's x and y, and above the clientside line in the npc, placing the actionserverside and setlevel commands
-leaving the triggeraction in the npc in the level but moving the action part into a weapon npc with a unique action name
-moving the entire script into the weapon npc and the level adds the weapon npc when you enter the level
-adding a warp box at the bottom of the level

nothing works!!! the player goes from the top to the bottom of the level (y increases) but it will not warp the player - the triggeraction never gets to the serverside command regardless of where the setlevel2 command is.

please help!
__________________

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
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 02:14 PM.


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