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: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
  #5  
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
  #6  
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
  #7  
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
  #8  
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
  #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, 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
  #11  
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
  #12  
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
  #13  
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
  #14  
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
  #15  
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
  #16  
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
  #17  
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
  #18  
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
  #19  
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
  #20  
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
  #21  
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 06:39 AM.


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