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
  #46  
Old 04-29-2009, 03:52 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Chompy View Post
You'd have to join that class to use it's content.

Lets say this is a class called fibonacci:

PHP Code:
function fib(n) {
  return (((
1+5^0.5)/2)^- ((1-5^0.5)/2)^n)/(5^0.5)


To use that function, I would have to do:

PHP Code:
function onCreated() {
  
join("fibonacci");

  echo(
fib(7)); // 13

Ok, thanks.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #47  
Old 04-29-2009, 05:11 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
one thing i always wondered when it comes to join(),
should i join it on serverside or clientside?
or even both?
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #48  
Old 04-29-2009, 05:19 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
Quote:
Originally Posted by Deas_Voice View Post
one thing i always wondered when it comes to join(),
should i join it on serverside or clientside?
or even both?
Depends on where you'll be using the class' content.
__________________
Reply With Quote
  #49  
Old 04-29-2009, 05:42 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by Chompy View Post
Depends on where you'll be using the class' content.
both sides.
sometimes clientside or serverside.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #50  
Old 04-29-2009, 07:25 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 Deas_Voice View Post
both sides.
sometimes clientside or serverside.
If you join it serverside, then both clientside and serverside parts of the class will work. If you join it clientisde, then only the clientside part of the class will work.
__________________
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
  #51  
Old 04-29-2009, 08:53 PM
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
I've noticed on the clientside if you join a class clientside you can't use the functions from the class right away.

ex:

PHP Code:
//class: whatever
//#CLIENTSIDE
function somefunc() {
  echo(
"!");

Then doing following..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("whatever");
  
somefunc(); // the somefunc in the class would not actually be called..
  
this.trigger("WildEvent"""); // so I would use a trigger..
}

function 
onWildEvent() {
  
somefunc(); // and ! would be displayed in F2

__________________
Quote:
Reply With Quote
  #52  
Old 04-29-2009, 09:16 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 fowlplay4 View Post
I've noticed on the clientside if you join a class clientside you can't use the functions from the class right away.

ex:

PHP Code:
//class: whatever
//#CLIENTSIDE
function somefunc() {
  echo(
"!");

Then doing following..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("whatever");
  
somefunc(); // the somefunc in the class would not actually be called..
  
this.trigger("WildEvent"""); // so I would use a trigger..
}

function 
onWildEvent() {
  
somefunc(); // and ! would be displayed in F2

That's weird. Have you tried:
PHP Code:
whatever::somefunc(); 
??
__________________
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
  #53  
Old 04-29-2009, 09:21 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
It might take a minute to join, I've had trouble with that before as well.
__________________
Reply With Quote
  #54  
Old 04-30-2009, 12:28 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 napo_p2p View Post
That's weird. Have you tried:
PHP Code:
whatever::somefunc(); 
??
Just tried it, it only happens when you login/connect though, not when you update the script.

My above script didn't work with the trigger, however this worked fine and isn't noticable.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
join("whatever");
  
whatever::somefunc(); // the somefunc in the class would not actually be called..
  
this.scheduleevent(0.1"WildEvent"""); // so I would use a trigger..
}

function 
onWildEvent() {
  
somefunc(); // and ! would be displayed in F2

So I'd recommend joining serverside if you don't want to deal with the workaround above..

PHP Code:
function onCreated() {
  
join("whatever");
}
//#CLIENTSIDE
function onCreated() { 
  
somefunc(); // the somefunc in the class is called.

__________________
Quote:
Reply With Quote
  #55  
Old 04-30-2009, 12:43 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
You know, now that I think of it, it's requesting the script from the server when you call join(), which results in a small delay.

So, yea. It's easiest just to do all joins serverside.
__________________
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
  #56  
Old 04-30-2009, 12:38 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
Jerret, you're actually missing something.

It's not being updated on clientside when you join it clientsided, true. But it's also not updated clientsided if you join it serversided. Note that sometimes both works, sometimes they don't - and when it doesn't work, it's updated if you reconnect with your client.

This is why I never "release" an updated clientsided class before manually reconnecting all current clients to ensure that they all got the update.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #57  
Old 04-30-2009, 08:26 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ok, maybe I should ask this differently.. I wrote these scripts in GS1, but now I want to put them on my server, so can they be converted to GS2 easier with syntax changes? Or do I have to re-write them entirely?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #58  
Old 04-30-2009, 08:51 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 Raelyn View Post
Ok, maybe I should ask this differently.. I wrote these scripts in GS1, but now I want to put them on my server, so can they be converted to GS2 easier with syntax changes? Or do I have to re-write them entirely?
You might get away with just putting the GS1 script up, but it's good practice to use only GS2 online.

You can mostly go line-by-line and make a direct change from GS1->GS2.

If you haven't checked it out already:
http://wiki.graal.net/index.php/Creation/Dev/GS1_To_GS2

That article gives a pretty good overview of the types of changes you need to make.
__________________
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
  #59  
Old 04-30-2009, 09:27 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by napo_p2p View Post
You might get away with just putting the GS1 script up, but it's good practice to use only GS2 online.

You can mostly go line-by-line and make a direct change from GS1->GS2.

If you haven't checked it out already:
http://wiki.graal.net/index.php/Creation/Dev/GS1_To_GS2

That article gives a pretty good overview of the types of changes you need to make.
Ok, well for displaying showtext I presume this is the GS2 equivalent of what I have done for my hud.

PHP Code:
function onCreated() {
  
temp.= {55};
  
  
temp.txt "HP:" clientr.player_hp "/" clientr.player_hpmax;
  
temp.showtext(200temp.p[0], temp.p[1], "Arial""b"temp.txt);
  
temp.i.layer 4;

  
temp.txt "MP:" clientr.player_mp "/" clientr.player_mpmax;
  
temp.showtext(201temp.p[0], temp.p[1] + 20"Arial""b"temp.txt);
  
temp.i.layer 4;

As far as I can tell, this works the same, but I don't understand "temp.p" and "temp.i", "temp.i.layer". I presume temp.i.layer is the same as changeimgvis, but what I don't understand is why the text being on layer 4 works, when I thought only 5 and up works for the screen instead of the playing field?

This script is something another scripter made/posted on my RC and I'm trying to learn off it and/or convert it to match what I have done in GS1, since it seems nearly identical but with strange syntax differences.

This really confuses me as to why everyone says "GS2 is easier to understand" or "GS2 makes more sense" because GS1 makes sense to me, but looking at this stuff, I am like.. what?!
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #60  
Old 04-30-2009, 09:35 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Chompy View Post
You'd have to join that class to use it's content.

Lets say this is a class called fibonacci:

PHP Code:
function fib(n) {
  return (((
1+5^0.5)/2)^- ((1-5^0.5)/2)^n)/(5^0.5)


To use that function, I would have to do:

PHP Code:
function onCreated() {
  
join("fibonacci");

  echo(
fib(7)); // 13

Ok, so if I take all my functions from my base system script, and make the classes all functions, I can just go through and replace all the functions listed in the script with:

PHP Code:
function onCreated() {
join("class_name");

Is that right? What is the echo? And will GS1 and GS2 mix? It seems like they mix, but only that GS2 doesn't work offline.. is that right?
__________________
*Don't let the door hit you on the way out.*
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 03:38 AM.


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