Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Suggestion! (https://forums.graalonline.com/forums/showthread.php?t=75270)

xXziroXx 07-12-2007 04:24 PM

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.")); 


Gambet 07-12-2007 06:53 PM

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).

xXziroXx 07-12-2007 09:01 PM

Gambet, I was merely using EXAMPLES. It doesnt work, period.

bscharff 07-13-2007 01:08 AM

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 :)

Gambet 07-13-2007 01:30 AM

Quote:

Originally Posted by xXziroXx (Post 1328638)
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.

Twinny 07-13-2007 01:35 AM

Quote:

Originally Posted by Gambet (Post 1328775)
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.

Gambet 07-13-2007 01:40 AM

Quote:

Originally Posted by Twinny (Post 1328778)
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

Twinny 07-13-2007 01:45 AM

Quote:

Originally Posted by Gambet (Post 1328779)
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);

Tolnaftate2004 07-13-2007 02:09 AM

Quote:

Originally Posted by xXziroXx (Post 1328555)
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.

Gambet 07-13-2007 02:15 AM

Quote:

Originally Posted by Twinny (Post 1328782)
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(); -_-

Twinny 07-13-2007 02:40 AM

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.

Gambet 07-13-2007 02:47 AM

Quote:

Originally Posted by Twinny (Post 1328805)
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();

Twinny 07-13-2007 02:50 AM

Quote:

Originally Posted by Gambet (Post 1328810)
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.

zokemon 07-13-2007 06:15 AM

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.")); 


Inverness 07-13-2007 06:29 AM

PHP Code:

with (Object)
  
tempvar getstringkeys("this.keyname"); 

Thats how I do it.

Twinny 07-13-2007 06:31 AM

Quote:

Originally Posted by zokemon (Post 1328880)
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 x_x

Gambet 07-13-2007 06:41 AM

Quote:

Originally Posted by zokemon (Post 1328880)
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 (Post 1328885)
If Chat was a DBNPC then it would echo the correct type x_x


Yeah, TServerNPC, thanks. :rolleyes:


Quote:

Originally Posted by zokemon (Post 1328880)
Ziro:
Try doing:
PHP Code:

echo(getstringkeys("PartyControll.")); 



It's already been suggested:

Quote:

Originally Posted by Tolnaftate2004 (Post 1328791)
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.

Inverness 07-13-2007 06:47 AM

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.

Gambet 07-13-2007 06:57 AM

Quote:

Originally Posted by Inverness (Post 1328889)
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.

xXziroXx 07-13-2007 12:38 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1328791)
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.

zokemon 07-13-2007 03:46 PM

Quote:

Originally Posted by Twinny (Post 1328885)
If Chat was a DBNPC then it would echo the correct type x_x

Uhh, I did it and it echoed the npc's chat that I called it from actually...

Twinny 07-13-2007 04:17 PM

Quote:

Originally Posted by zokemon (Post 1329012)
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

Kristi 07-13-2007 05:08 PM

Quote:

Originally Posted by Gambet (Post 1328810)
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;

Twinny 07-13-2007 06:10 PM

Quote:

Originally Posted by Kristi (Post 1329060)
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.

Gambet 07-13-2007 06:13 PM

Quote:

Originally Posted by Kristi (Post 1329060)
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.

Twinny 07-13-2007 06:23 PM

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(); 


Gambet 07-13-2007 06:25 PM

Quote:

Originally Posted by Twinny (Post 1329084)
If you are going to use any dbnpc for prolonged periods of time and really care about the coding,


Quote:

Originally Posted by Gambet (Post 1329081)
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.

xXziroXx 07-13-2007 08:05 PM

Quote:

Originally Posted by Kristi (Post 1329060)
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;



Tolnaftate2004 07-14-2007 08:08 PM

Quote:

Originally Posted by xXziroXx (Post 1328943)
No, it's not. Right now, it works exactly like it did in GS1 - nothing further.

getstringkeys was not available in GS1. :confused:

zokemon 07-15-2007 05:07 AM

Quote:

Originally Posted by Twinny (Post 1329034)
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.

xXziroXx 07-15-2007 05:19 AM

Quote:

Originally Posted by Tolnaftate2004 (Post 1330151)
getstringkeys was not available in GS1. :confused:

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.


All times are GMT +2. The time now is 01:28 PM.

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