097 Newbie Question

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
thedaler44
New User
Posts: 1
Joined: Wed May 30, 2007 11:15 pm

097 Newbie Question

Post by thedaler44 »

So I'm trying to get any value to return from GetAttribute(), but it seems to not be working. I'm basically just trying to test it out, so I made a textcmd with this.

use uo;
use attributes;
//c:\pol097\scripts\textcmd\player\oosh.src

program textcmd_oosh( character )


PrintTextAbove(character, "TEST");
PrintTextAbove(character, GetAttribute(character, "stealing"));
PrintTextAbove(character, GetAttribute(character, "skill 33"));
PrintTextAbove(character, GetAttribute(character, "skill 27"));
PrintTextAbove(character, GetAttribute(character, "Tactics"));
PrintTextAbove(character, GetAttribute(character, "tactics"));

endprogram

I was basically trying anything I could find that would identify the skill, but the only thing that will pop up is TEST over my character. I'm not sure what I'm doing wrong...I read that there is supposed to be an attributes.cfg or UOskills.cfg in the updates .txt, but I do not have either. All I have in my config folder is skills.cfg. I appreciate any help.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

Not quite sure why it's not printing anything but the literal string "TEST" but I will tell you that what you need in the GetAttribute for an attribute parameter is the string value (name) of the attribute i.e. "alchemy", "anatomy", etc. not a skill number.

FYI I didn't get anything but TEST either so it isn't just you. It should be returning the effective skill as an integer.

Very strange...
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

OK did a bit more testing. It seems that you have to wrap the GetAttribute function call inside the CStr() function as in:
PrintTextAbove(character, CStr(GetAttribute(character, "stealing")));

I don't ever remember having to convert integers to strings to get them to print before.
mr bubbles
Grandmaster Poster
Posts: 120
Joined: Thu Jan 18, 2007 2:34 am

Post by mr bubbles »

Yeh, always had to convert to string unless you use Print(). I'm in the habbit of converting even when using Print() now :/
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

Post by Austin »

If you ever have weirdness with a core function... try something like this:

var result := PrintTextAbove(character, GetAttribute(character, "tactics"));
if ( result.errortext )
PrintTextAbove(character, "Result error = "+result.errortext);
endif
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

I CStr everything even if I have some weird things going on since if you CStr an error, you'll still get the errortext.
Yukiko
Distro Developer
Posts: 2826
Joined: Thu Feb 02, 2006 1:41 pm

Post by Yukiko »

Good thing to remember Austin.

Thanks.
Post Reply