PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
GetConfigStringKeys() on elements with no key names

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> General Help 096
Display posts from previous:   

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Fri May 05, 2006 6:59 pm    Post subject: GetConfigStringKeys() on elements with no key names Reply with quote

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. Sad I almost died.

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Fri May 05, 2006 7:05 pm    Post subject: Solution Reply with quote

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

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Fri May 05, 2006 8:43 pm    Post subject: Re: GetConfigStringKeys() on elements with no key names Reply with quote

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

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Fri May 05, 2006 9:06 pm    Post subject: Reply with quote

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.

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Fri May 05, 2006 10:00 pm    Post subject: Reply with quote

It's nice to see you posting again. Smile

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Fri May 05, 2006 10:49 pm    Post subject: Reply with quote

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

Addition can be neither created nor destroyed, only changed.

My beer funds are a bit low ¬_¬

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Fri May 05, 2006 11:55 pm    Post subject: Reply with quote

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.

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Sun May 07, 2006 7:40 pm    Post subject: Reply with quote

There is so much truth in that post.. its scary Razz

Post new topic   Reply to topic    PenUltima Online Forum Index -> General Help 096 All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty