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 08-28-2008, 03:56 PM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
getstringkeys() and loadvars()

I'm not sure how to use the 2 together.

PHP Code:
function onCreated()
{
  
temp.gang.loadvars("gangs/Los Carteles.txt");
  for (
temp.igetstringkeys("rights-"))
  {
  }

It's hard to put in words, but I know in a database you can do
PHP Code:
with (findNPC("database stuff"))
{
  for (
temp.igetstringkeys("stuff"))
  {
  }

which will get the strings in the database.
I'm just not sure how to get the strings in the text file.
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #2  
Old 08-28-2008, 03:59 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
I'm not terribly familiar with this, but...
PHP Code:
function onCreated()
{
  
temp.gang.loadvars("gangs/Los Carteles.txt");
  for (
temp.itemp.gang.getstringkeys("rights-"))
  {
  }

?
Reply With Quote
  #3  
Old 08-28-2008, 04:00 PM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
I've tried that

Script: Function gang.getstringkeys not found at line 69 in script of *Frankie
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #4  
Old 08-28-2008, 04:11 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
getstringkeys() can't but used directly on an object (obj.getstringkeys())
Use it inside a with() scope.

And, for the files, use obj.getDynamicVarNames();

PHP Code:
function onCreated() {
  
temp.file.loadvars("gangs/PizzaClan.txt");
  
  
temp.gang_PizzaClan = new TStaticVar();

  for(
temp.var : temp.file.getDynamicVarNames()) {
    
temp.gang_PizzaClan.(@var) = temp.file.(@var);
  }

  
temp.keys 0;
  
with(temp.gang_PizzaClan) {
    
temp.keys getstringkeys("variable_prefix");
  }

Just a fast mockup, but something like that would work I guess
__________________
Reply With Quote
  #5  
Old 08-28-2008, 04:20 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 Chompy View Post
getstringkeys() can't but used directly on an object (obj.getstringkeys())
Use it inside a with() scope.
No.

PHP Code:
temp.string_foobar "lawl";
temp.string_lolwat "baz";
for (
temp.foogetstringkeys("temp.string_")) {
  echo(
foo SPC "[" makevar("temp.string_" foo) @ "]");

Result:

PHP Code:
foobar [lawl]
lolwat [baz
__________________
Follow my work on social media post-Graal:Updated august 2025.

Last edited by xXziroXx; 08-28-2008 at 04:40 PM..
Reply With Quote
  #6  
Old 08-28-2008, 04:29 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 xXziroXx View Post
No.

PHP Code:
... 
Result:

PHP Code:
... 
Where in your script are you doing object.getstringkeys() though? ;o

I might of worded it wrong, as my vocabulary isn't that big in English
But I did put 'obj.getstringkeys()' in parenthesises
__________________
Reply With Quote
  #7  
Old 08-28-2008, 04:40 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
If I wanted to do it with an object, I would do:


PHP Code:
temp.obj findNPC("foobarbaz");
obj.string_foobar "lawl";  // Just to show a string example.
obj.string_lolwat "baz";  // Just to show a string example.
for (temp.foogetstringkeys("obj.string_")) {
  echo(
foo SPC "[" makevar("obj.string_" foo) @ "]");

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #8  
Old 08-28-2008, 04:43 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 xXziroXx View Post
If I wanted to do it with an object, I would do:


PHP Code:
temp.obj findNPC("foobarbaz");
obj.string_foobar "lawl";  // Just to show a string example.
obj.string_lolwat "baz";  // Just to show a string example.
for (temp.foogetstringkeys("obj.string_")) {
  echo(
foo SPC "[" makevar("obj.string_" foo) @ "]");

Hmm, you're right, but you can't do obj.getstringkeys()

But yeah.. I probably read through your script to fast
__________________
Reply With Quote
  #9  
Old 08-28-2008, 04:45 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 Chompy View Post
Hmm, you're right, but you can't do obj.getstringkeys()
Agreed. I also didn't read your post too well, I was under the impression that you meant something like this for a while:

PHP Code:
with (getstringkeys("foobar")) {
...

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 08-28-2008, 05:02 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 xXziroXx View Post
Agreed. I also didn't read your post too well, I was under the impression that you meant something like this for a while:

PHP Code:
... 
hehe
__________________
Reply With Quote
  #11  
Old 08-28-2008, 07:30 PM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Booyah!

PHP Code:
function onCreated() {
  
this.test();
}
public function 
test() {
  
temp.file = new TStaticVar();
  
temp.file.var_1 "moo";
  
temp.file.var_2 46;
  
  
with (temp.file) {
    
temp.keys getstringkeys("this.var_");
  }
  echo(
"Keys: " temp.keys);

Reply With Quote
  #12  
Old 08-28-2008, 09:28 PM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
PHP Code:
function onCreated() {
  
this.test();
}
public function 
test() {
  
temp.file = new TStaticVar();
  
temp.file.loadvars("gangs/Los Carteles.txt");
  
  
with (temp.file) {
    
temp.keys getstringkeys("this.rights-");
    
    for (
temp.itemp.keys)
    {
      if (
this.("rights-" temp.i)[7] == 1)
      {
        echo(
temp.i);
      }
    }
  }

basically I was trying to cycle through all the accounts and their rights and find out if they had a specific right (leader right)

thanks
__________________
*Sum41Freeeeek
*Frankie
Reply With Quote
  #13  
Old 08-28-2008, 09:39 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 Frankie View Post
PHP Code:
... 
basically I was trying to cycle through all the accounts and their rights and find out if they had a specific right (leader right)

thanks
Also, loops inside with() aren't optimized Just thought you would want to know =p
__________________
Reply With Quote
  #14  
Old 08-28-2008, 09:43 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
makevar("this.rights-" @ temp.i) instead of this.("rights-" @ temp.i)
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 08-28-2008, 11:30 PM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
Quote:
Originally Posted by Chompy View Post
Also, loops inside with() aren't optimized Just thought you would want to know =p
it doesn't work if I take the for() loop out of the with()
__________________
*Sum41Freeeeek
*Frankie
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:01 AM.


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