Page 1 of 1

097 Newbie Question

Posted: Wed May 30, 2007 11:22 pm
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.

Posted: Wed May 30, 2007 11:54 pm
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...

Posted: Wed May 30, 2007 11:59 pm
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.

Posted: Thu May 31, 2007 1:01 am
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 :/

Posted: Thu May 31, 2007 4:48 am
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

Posted: Thu May 31, 2007 5:22 am
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.

Posted: Thu May 31, 2007 7:49 pm
by Yukiko
Good thing to remember Austin.

Thanks.