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 07-12-2007, 04:24 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Suggestion!

I remember this from when I was working on a script the last time, and I thought it might benefit the community if it was fixed.


Stefan, make getStringKeys() gs2 compatible!


At the moment (unless it's been fixed already), this works:

PHP Code:
with (findNPC(PartyControll)) echo(getstringkeys("this.")); 
While these doesn't:

PHP Code:
db findNPC(PartyControll);
echo(
db.getstringkeys("this.")); 
PHP Code:
echo(findNPC(PartyControll).getstringkeys("this.")); 
PHP Code:
echo(PartyControll.getstringkeys("this.")); 
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 07-12-2007 at 09:09 PM..
Reply With Quote
  #2  
Old 07-12-2007, 06:53 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
When working with object oriented programming, you don't need to define a separate variable to use findNPC with for getting DB NPCs, since DB NPCs are objects themselves.


PartyControll.getstringkeys(whatever);


should be good enough, though that doesn't mean that it would fix your problem (havn't looked into it, just glanced and noticed you using findNPC and definining a separate variable just to call something inside the DB itself).
Reply With Quote
  #3  
Old 07-12-2007, 09:01 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Gambet, I was merely using EXAMPLES. It doesnt work, period.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #4  
Old 07-13-2007, 01:08 AM
bscharff bscharff is offline
Bloo
bscharff's Avatar
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
bscharff has a little shameless behaviour in the past
Send a message via AIM to bscharff Send a message via MSN to bscharff Send a message via Yahoo to bscharff
I'm Probably No Help But Maybe This Would Work:
with (findNPC(PartyControll)){
echo(getstringkeys("this."));
}
Probably Won't Work But Just Another Way It Could Work
__________________
Trying to be nice now...
Reply With Quote
  #5  
Old 07-13-2007, 01:30 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by xXziroXx View Post
Gambet, I was merely using EXAMPLES. It doesnt work, period.


And your examples were inefficient.

Not to mention you used the same method for each and every example, thus suggesting that you did not know that you could treat DB NPCs directly as objects.


Anyways, it seems like you added on an example after viewing my post. I don't see why you grow so defensive when one has to help you based on what you show them.
Reply With Quote
  #6  
Old 07-13-2007, 01:35 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Gambet View Post
And your examples were inefficient.
It makes no real difference (if any at all) to efficiency and some people prefer to use findnpc or findweapon since you can read the code and instantly go, "aight: that's a dbnpc" and such.
Reply With Quote
  #7  
Old 07-13-2007, 01:40 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Twinny View Post
It makes no real difference (if any at all) to efficiency and some people prefer to use findnpc or findweapon since you can read the code and instantly go, "aight: that's a dbnpc" and such.

That's not the point of object oriented programming. x-x
Reply With Quote
  #8  
Old 07-13-2007, 01:45 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Gambet View Post
That's not the point of object oriented programming. x-x
You didn't seem to care before I showed you. Don't be so patronizing. findnpc("blah").anything is using objects. Much like findplayer("Twinny").addweapon(this);
Reply With Quote
  #9  
Old 07-13-2007, 02:09 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by xXziroXx View Post
Stefan, make getStringKeys() gs2 compatible!
Not to be picky, but if it works at all, it's "compatible". x-x

I don't think getstringkeys() was ever meant to be a method of the TGraalVar object, it's more along the lines of the GS2 version of getstringflags() from GS1 (or whatever that function was), but for backwards compatibility, the name had to be changed. Perhaps a better suggestion would be an extension of getvarnames/getdynamicvarnames to take a parameter and return only those variables with names that start with the parameter.

I am also curious to see if perhaps getstringkeys("DB."); works.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #10  
Old 07-13-2007, 02:15 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Twinny View Post
You didn't seem to care before I showed you. Don't be so patronizing. findnpc("blah").anything is using objects. Much like findplayer("Twinny").addweapon(this);


I havn't talked to you about scripting in ages so if you did, then it was a while back.

And do you hold this same crap against every person that you teach anything too? Because if you do, I'd hate for you to teach anyone in fear that the next time they try to correct someone with something you taught them that you'd jump in and criticize them because at ONE POINT in their life they themselves didn't know about it.


And you do findPlayer("accountname").function(); because you can't do accountname.function(); -_-
Reply With Quote
  #11  
Old 07-13-2007, 02:40 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
the point is, findnpc() returns an object. temp.db = findnpc("Hax"); would make temp.db the Hax object. It still uses objects. It is still as efficient as Hax. blah. Scripts are optimised when made into bytecode anyways so you don't have to jump at people for doing there way when it doesn't conform to yours.
Reply With Quote
  #12  
Old 07-13-2007, 02:47 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Twinny View Post
the point is, findnpc() returns an object. temp.db = findnpc("Hax"); would make temp.db the Hax object. It still uses objects. It is still as efficient as Hax. blah. Scripts are optimised when made into bytecode anyways so you don't have to jump at people for doing there way when it doesn't conform to yours.

It returns an object but it's unecessary considering you don't need the object to be returned in this case to access the function. You can call the database directly via obj.function();
Reply With Quote
  #13  
Old 07-13-2007, 02:50 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Gambet View Post
It returns an object but it's unecessary considering you don't need the object to be returned in this case to access the function. You can call the database directly via obj.function();
Which in the end is no different to doing obj.var since the language needs to find the object and return it anyways. In the end, findnpc() allows for a certain level of self documentation. It doesn't effect efficiency though.
Reply With Quote
  #14  
Old 07-13-2007, 06:15 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Get out of the scripting forum with your bad attitude Gambet. No one cares how you think it is inefficient. Go make me a npc called Chat and try echo Chat.objecttype(). It's pretty obvious why it wouldn't work.

Ziro:
Try doing:
PHP Code:
echo(getstringkeys("PartyControll.")); 
__________________
Do it with a DON!
Reply With Quote
  #15  
Old 07-13-2007, 06:29 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
PHP Code:
with (Object)
  
tempvar getstringkeys("this.keyname"); 
Thats how I do it.
__________________
Reply With Quote
  #16  
Old 07-13-2007, 06:31 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by zokemon View Post
Get out of the scripting forum with your bad attitude Gambet. No one cares how you think it is inefficient. Go make me a npc called Chat and try echo Chat.objecttype(). It's pretty obvious why it wouldn't work.

Ziro:
Try doing:
PHP Code:
echo(getstringkeys("PartyControll.")); 
If Chat was a DBNPC then it would echo the correct type
Reply With Quote
  #17  
Old 07-13-2007, 06:41 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by zokemon View Post
Get out of the scripting forum with your bad attitude Gambet. No one cares how you think it is inefficient. Go make me a npc called Chat and try echo Chat.objecttype(). It's pretty obvious why it wouldn't work.

Quote:
Originally Posted by Twinny View Post
If Chat was a DBNPC then it would echo the correct type

Yeah, TServerNPC, thanks.


Quote:
Originally Posted by zokemon View Post
Ziro:
Try doing:
PHP Code:
echo(getstringkeys("PartyControll.")); 

It's already been suggested:

Quote:
Originally Posted by Tolnaftate2004 View Post
I am also curious to see if perhaps getstringkeys("DB."); works.


Oh, and I'll let you know when I'm in a bad mood, thanks.

Last edited by Gambet; 07-13-2007 at 07:11 AM..
Reply With Quote
  #18  
Old 07-13-2007, 06:47 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Perhaps you people are not understanding that getstringkeys() does not work with Object.varname as thats not GS1, unless that was suddenly changed from when Stefan stated it. It will only work with things that worked in GS1.
__________________
Reply With Quote
  #19  
Old 07-13-2007, 06:57 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Inverness View Post
Perhaps you people are not understanding that getstringkeys() does not work with Object.varname as thats not GS1, unless that was suddenly changed from when Stefan stated it. It will only work with things that worked in GS1.


I havn't tried it, but I think pfa said something similar so I'll take your word for it.
Reply With Quote
  #20  
Old 07-13-2007, 12:38 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by Tolnaftate2004 View Post
Not to be picky, but if it works at all, it's "compatible". x-x
No, it's not. Right now, it works exactly like it did in GS1 - nothing further.

I tried to do getstringkeys("DBNameHere.") without any success.


And on a side note to Gambet; stop lecturing me when I know EXACTLY what I'm talking about. In my pre-edit of the first post, I had this at the top of all my 3 non-working examples:

PHP Code:
db findNPC(PartyControll); 
But those of you who claim to be able to script, should most likely know that that line of code did NOTHING when my examples was:

PHP Code:
db findNPC(PartyControll);
echo(
findNPC(PartyControll).getstringkeys("this.")); 
Wanna know why? Cause in my echo(), "db." is not mentioned ANYWHERE. 'Nuff said.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #21  
Old 07-13-2007, 03:46 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Twinny View Post
If Chat was a DBNPC then it would echo the correct type
Uhh, I did it and it echoed the npc's chat that I called it from actually...
__________________
Do it with a DON!
Reply With Quote
  #22  
Old 07-13-2007, 04:17 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by zokemon View Post
Uhh, I did it and it echoed the npc's chat that I called it from actually...
The heck? If you have a DBNPC, just do echo(dbnpc.objecttype()) and you will get TServerNPC
Reply With Quote
  #23  
Old 07-13-2007, 05:08 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Gambet View Post
It returns an object but it's unecessary considering you don't need the object to be returned in this case to access the function. You can call the database directly via obj.function();
As twinny said, since it is compiled into bytecode, there is no inefficiency in terms of runtime, so the only thing you can be complaining about is perhaps, at most, saving typing.

So you would do like
dbnpcname.var1 = hi;
dbnpcname.var2 = cool;
dbnpcname.var3 = "sweet";
dbnpcname.var4 = 4;
dbnpcname.var5 = 6;

Since you are all about typing it directly
but oh man check it
n = findnpc("dbnpcname");
n.var1 = hi;
n.var2 = cool;
n.var3 = "sweet";
n.var4 = 4;
n.var5 = 6;
__________________

Last edited by Skyld; 07-13-2007 at 06:04 PM..
Reply With Quote
  #24  
Old 07-13-2007, 06:10 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by Kristi View Post
As twinny said, since it is compiled into bytecode, there is no inefficiency in terms of runtime, so the only thing you can be complaining about is perhaps, at most, saving typing.

So you would do like
dbnpcname.var1 = hi;
dbnpcname.var2 = cool;
dbnpcname.var3 = "sweet";
dbnpcname.var4 = 4;
dbnpcname.var5 = 6;

Since you are all about typing it directly
but oh man check it
n = findnpc("dbnpcname");
n.var1 = hi;
n.var2 = cool;
n.var3 = "sweet";
n.var4 = 4;
n.var5 = 6;
Script efficiency is the most important efficiency here. Other forms hardly matter in the end.
Reply With Quote
  #25  
Old 07-13-2007, 06:13 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Kristi View Post
As twinny said, since it is compiled into bytecode, there is no inefficiency in terms of runtime, so the only thing you can be complaining about is perhaps, at most, saving typing.

That falls under convenience, which falls under my two categories of efficiency:


Adequacy and convenience.


I'm not talking about runtime here, for it shouldn't affect runtime.


But, like everything else, it all depends on the situation. If for some bizarre reason you have a DB NPC with an extremely long name, then it would be beneficial to assign a shorter variable to be read as that database.
Reply With Quote
  #26  
Old 07-13-2007, 06:23 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
If you are going to use any dbnpc for prolonged periods of time and really care about the coding,

PHP Code:
temp.dbnpc;
e.var = "blah";
e.var2 "hax?";
e.var3 e.var1;
e.hax(); 
Reply With Quote
  #27  
Old 07-13-2007, 06:25 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Twinny View Post
If you are going to use any dbnpc for prolonged periods of time and really care about the coding,

Quote:
Originally Posted by Gambet View Post
But, like everything else, it all depends on the situation. If for some bizarre reason you have a DB NPC with an extremely long name, then it would be beneficial to assign a shorter variable to be read as that database.


Already addressed that.
Reply With Quote
  #28  
Old 07-13-2007, 08:05 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by Kristi View Post
n = findnpc("dbnpcname");
n.var1 = hi;
n.var2 = cool;
n.var3 = "sweet";
n.var4 = 4;
n.var5 = 6;
When I need to address several vars, I do:

PHP Code:
with (findNPC("dbnpcname")) {
  
var1 hi;
  
var2 cool;
  
var3 "sweet";
  
var4 4;
  
var5 6;

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #29  
Old 07-14-2007, 08:08 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by xXziroXx View Post
No, it's not. Right now, it works exactly like it did in GS1 - nothing further.
getstringkeys was not available in GS1.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #30  
Old 07-15-2007, 05:07 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Twinny View Post
The heck? If you have a DBNPC, just do echo(dbnpc.objecttype()) and you will get TServerNPC
I made a mistake when I said it would echo the npc's chat. I forgot that I had said objecttype(). Basically, the chat variable is already a pre-defined variable in the npc so you wouldn't by calling the function from the Chat npc. I'm just pointing out to Gambet that findnpc() isn't completely useless although his arrogance is.
__________________
Do it with a DON!
Reply With Quote
  #31  
Old 07-15-2007, 05:19 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
Quote:
Originally Posted by Tolnaftate2004 View Post
getstringkeys was not available in GS1.
I thought I could swear that we used it on Maloria to find out all the players items. Perhaps it wasn't called "getstringkeys", but something like it existed.
__________________
Follow my work on social media post-Graal:Updated august 2025.
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 11:46 PM.


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