GetConfigStringKeys() on elements with no key names

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 096.
Note: Core 096 is no longer officially supported.
Post Reply
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

GetConfigStringKeys() on elements with no key names

Post by tekproxy »

Here's my armrzone.cfg (it's unmodified):

Code: Select all

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: Select all

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.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Solution

Post by Austin »

Code: Select all

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
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Re: GetConfigStringKeys() on elements with no key names

Post by tekproxy »

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...
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

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.
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

It's nice to see you posting again. :)
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

Laws of social-physics (taken from dieselsweeties.com)

Addition can be neither created nor destroyed, only changed.

My beer funds are a bit low ¬_¬
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

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.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

There is so much truth in that post.. its scary :-P
Post Reply