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 06-04-2006, 08:22 PM
KuJi KuJi is offline
Banned
Join Date: Apr 2004
Location: Staten Island, New York
Posts: 2,202
KuJi will become famous soon enough
Send a message via ICQ to KuJi Send a message via AIM to KuJi Send a message via MSN to KuJi Send a message via Yahoo to KuJi
Passing Objects

How can you pass an object from clientside to serverside and serverside to client?

IE:
hotel.test=wow
hotel.test2=wow2
hotel.test3=wow3

How could I send the hotel object to serverside aswell as clientside
Reply With Quote
  #2  
Old 06-04-2006, 08:43 PM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
I do not think there is a way as of yet.. perhaps try setting it to an attribute? ie:
NPC Code:

this.attr[20]=hotel;

Reply With Quote
  #3  
Old 06-04-2006, 09:32 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by Warcaptain
I do not think there is a way as of yet.. perhaps try setting it to an attribute? ie:
NPC Code:

this.attr[20]=hotel;

I tried setting a client.var to an object, it didn't work. I could do like client.obj = obj; and then sendtonc("Blah: " @ client.obj.var); and it would work, but it didn't actually set it on the client because if I tried to use it elsewhere or view it in my attributes it pulled up nothing. This is the very reason why I've decided not to come back to Graal. I used to think that the language was pretty versatile, but it really doesn't much in the way of data handling. Don't get me wrong, it has a great API in accordance with the game itself, but it doesn't handle data very well =(
__________________
Who has time for life these days?
Reply With Quote
  #4  
Old 06-04-2006, 11:05 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
There is no way to pass them via triggeractions, but I did come up with a little way to avoid that.

To send it:
PHP Code:
temp.object = new TStaticVar();
temp.object.test "Testing 123";

temp.arrayholder NULL
for(temp.vnametemp.object.getdynamicvarnames()) {
  
temp.arrayholder.add(temp.vname "=" temp.object.(@temp.vname));
}

triggerserver("gui"this.name"sendobject"temp.arrayholder); 
To receive it:
PHP Code:
function onActionServerside() {
  if(
params[0] == "sendobject") {
    
temp.object.loadvarsfromarray(params[1]);
    echo(
temp.object.test);
  }

__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 06-04-2006, 11:08 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by ApothiX
There is no way to pass them via triggeractions, but I did come up with a little way to avoid that.

To send it:
PHP Code:
temp.object = new TStaticVar();
temp.object.test "Testing 123";

temp.arrayholder NULL
for(temp.vnametemp.object.getdynamicvarnames()) {
  
temp.arrayholder.add(temp.vname "=" temp.object.(@temp.vname));
}

triggerserver("gui"this.name"sendobject"temp.arrayholder); 
To receive it:
PHP Code:
function onActionServerside() {
  if(
params[0] == "sendobject") {
    
temp.object.loadvarsfromarray(params[1]);
    echo(
temp.object.test);
  }

But that wouldn't accept multilevel vars though would it?
__________________
Who has time for life these days?
Reply With Quote
  #6  
Old 06-04-2006, 11:12 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Projectshifter
But that wouldn't accept multilevel vars though would it?
Probably not. Not sure if you do something like:

temp.array = { "foo.bar.baz = 10" };
temp.obj.loadvarsfromarray(temp.array);

if it will load the temp.foo.bar.baz or not. If it does function that way, it wouldn't be hard to modify my code to support multiple-levels.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 06-04-2006, 11:39 PM
Projectshifter Projectshifter is offline
The David
Projectshifter's Avatar
Join Date: Apr 2002
Location: USA
Posts: 912
Projectshifter is an unknown quantity at this point
Send a message via ICQ to Projectshifter Send a message via AIM to Projectshifter Send a message via MSN to Projectshifter Send a message via Yahoo to Projectshifter
Quote:
Originally Posted by ApothiX
Probably not. Not sure if you do something like:

temp.array = { "foo.bar.baz = 10" };
temp.obj.loadvarsfromarray(temp.array);

if it will load the temp.foo.bar.baz or not. If it does function that way, it wouldn't be hard to modify my code to support multiple-levels.
But it would be a pain in the ass if you didn't know how many levels there were and it could be up to 10 or so x.x
__________________
Who has time for life these days?
Reply With Quote
  #8  
Old 06-05-2006, 04:01 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Projectshifter
But it would be a pain in the ass if you didn't know how many levels there were and it could be up to 10 or so x.x
Not really. if(makevar("temp.varname." @ temp.levels).getdynamicvarnames() >= 2 /* or whatever the minimum is; always includes some timeout and scriptlogfunctions or something */) { in some sort of for loop iterating through the levels.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #9  
Old 06-05-2006, 06:05 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
I didn't bother to read anything, so I'm just throwing in some (hopefully) related information.
On my server, I reserve attr[2] to attr[5] of every NPC for specific things.
attr[4] is the NPC's identifier; it's a value based on the NPC's index. If I want to refer the serverside to a specific NPC found on the clientside, it uses this to figure out which NPC I want.
It's basically a way for me to pass a reference to this NPC from the clientside to the serverside, or vice-versa.
Reply With Quote
  #10  
Old 06-05-2006, 03:13 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
Why dont you guys just use the inbuilt save[] functions..?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #11  
Old 06-05-2006, 07:23 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by xXziroXx
Why dont you guys just use the inbuilt save[] functions..?
They are variables, not functions. Can you use even them as objects?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #12  
Old 06-05-2006, 08:40 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
Ah sorries, didnt read everything
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #13  
Old 06-10-2006, 06:52 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally Posted by ApothiX
There is no way to pass them via triggeractions, but I did come up with a little way to avoid that.

To send it:
PHP Code:
temp.object = new TStaticVar();
temp.object.test "Testing 123";

temp.arrayholder NULL
for(temp.vnametemp.object.getdynamicvarnames()) {
  
temp.arrayholder.add(temp.vname "=" temp.object.(@temp.vname));
}

triggerserver("gui"this.name"sendobject"temp.arrayholder); 
To receive it:
PHP Code:
function onActionServerside() {
  if(
params[0] == "sendobject") {
    
temp.object.loadvarsfromarray(params[1]);
    echo(
temp.object.test);
  }

You know there is a built-in savevarstoarray function

HTML Code:
temp.object = new TStaticVar();
temp.object.test = "test";
temp.object.test.bar = "test2";

temp.arrayholder = temp.object.savevarstoarray(false);
echo(temp.arrayholder) outputs
HTML Code:
scriptlogmissingfunctions=false,timeout=0,joinedclasses=,test=test,test.bar=test2
http://wiki.graal.net/index.php/Crea...lVar#Functions
Reply With Quote
  #14  
Old 06-12-2006, 05:31 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Riot
You know there is a built-in savevarstoarray function

HTML Code:
temp.object = new TStaticVar();
temp.object.test = "test";
temp.object.test.bar = "test2";

temp.arrayholder = temp.object.savevarstoarray(false);
echo(temp.arrayholder) outputs
HTML Code:
scriptlogmissingfunctions=false,timeout=0,joinedclasses=,test=test,test.bar=test2
http://wiki.graal.net/index.php/Crea...lVar#Functions
Ah, nice. I couldn't find a function like that when I originally wrote that code. It was probably there, I just wasn't looking hard enough.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 09:10 PM.


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