It is currently Fri Nov 21, 2008 3:28 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: GetConfigStringKeys() on elements with no key names
PostPosted: Fri May 05, 2006 2:59 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
Here's my armrzone.cfg (it's unmodified):
Code:
ArmorZone
{
   Name   Body
   Chance   44
   Layer   13
   Layer   20
   Layer   22
   Layer   5
   Layer   17
}

ArmorZone
{
   Name   Arms
   Chance   14
   Layer   19
}

ArmorZone
{
   Name   Head
   Chance   14
   Layer   6
}

ArmorZone
{
   Name   Legs/feet
   Chance   14
   Layer   4
   Layer   3
   Layer   24
}

ArmorZone
{
   Name   Neck
   Chance   7
   Layer   10
}

ArmorZone
{
   Name   Hands
   Chance   7
   Layer   7
}


Here's a test text command that should print out the number of armor zones and a list of all of the zone names:
Code:
use uo;
use os;
use cfgfile;

program TestRead(character, textcmd)
   var cfg_file := ReadConfigFile("::armrzone");
   var cfg_keys := GetConfigStringKeys(cfg_file);

   // Only prints out 1!
   SendSysMessage(character, "Armor zones: " + cfg_keys.size());
   
   var zones := "";
   
   foreach zone in cfg_keys
      zones := zones + " " + cfg_file[zone].Name;
   endforeach

   // Only prints out "Body"!   
   SendSysMessage(character, "Zones:" + zones);
endprogram



Only the first zone is loaded, and the rest are ignored. However, it works fine if I give the elements names. Why not simply load all of the elements with "" for their name instead of only loading the first one?

By the way, this took me a LONG time to figure out. :( I almost died.


Top
 Profile  
 
 Post subject: Solution
PostPosted: Fri May 05, 2006 3:05 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 428
Location: San Diego, California
Code:
ArmorZone Body
{
   Name   Body
   Chance   44
   Layer   13
   Layer   20
   Layer   22
   Layer   5
   Layer   17
}

ArmorZone Arms
{
   Name   Arms
   Chance   14
   Layer   19
}

ArmorZone Head
{
   Name   Head
   Chance   14
   Layer   6
}

ArmorZone Legs/Feet
{
   Name   Legs/feet
   Chance   14
   Layer   4
   Layer   3
   Layer   24
}

ArmorZone Neck
{
   Name   Neck
   Chance   7
   Layer   10
}

ArmorZone Hands
{
   Name   Hands
   Chance   7
   Layer   7
}


ROCKET SCIENCE

_________________
-Austin


Top
 Profile  
 
 Post subject: Re: GetConfigStringKeys() on elements with no key names
PostPosted: Fri May 05, 2006 4:43 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
tekproxy wrote:
However, it works fine if I give the elements names.


Hmmm. There's no need to get mad. It's just sort of an odd behavior to only return ONE element. I'd rather it give an error or return all elements...


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 5:06 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 428
Location: San Diego, California
Not mad, just being a smart-ass.

It just finds the first match. It isnt gonna return them all.
Likewise say you have four instances of

Elem MyElem
{
}
Elem MyElem
{
}

Itll give you the first one.

So... name the elems.

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 6:00 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
It's nice to see you posting again. :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 6:49 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 428
Location: San Diego, California
Laws of social-physics (taken from dieselsweeties.com)

Addition can be neither created nor destroyed, only changed.

My beer funds are a bit low ¬_¬

_________________
-Austin


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 7:55 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
Maybe if they didn't end all days with "y", eh? I think if you took beer out of the world, 80-90% of all open source projects would be finished in about a week.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 07, 2006 3:40 pm 
Offline
POL Developer
User avatar

Joined: Wed Jan 25, 2006 2:30 am
Posts: 428
Location: San Diego, California
There is so much truth in that post.. its scary :-P

_________________
-Austin


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl