Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Clarabella on Wed 05/08/2009 18:13:22

Title: Random Int called in dialog behave strangely [solved]
Post by: Clarabella on Wed 05/08/2009 18:13:22
Hi everyone!

I put a little function into a dialog, so that when the player asks something to another character (let's call this character Jim), Jim answers with a number which is different at anytime.
To do so, I put this very little function into the dialog_request:

VariableX = Random(200);
cJim.Say("%p", VariableX);

The problem is: when Jim says this number into the game, the number is always formed by 8 characters (so, with 000 at the beginning) and hexadecimal! For example: 0000001E.  ???

Where is my mistake? How can I avoid this and have displayed just a decimal number with no zeros at the beginning?
Thanks!
Title: Re: Random Int called in dialog behave strangely
Post by: monkey0506 on Wed 05/08/2009 18:15:02
String formatting with an int uses "%d". "%p" isn't supported as far as I know for anything.

From the manual, the codes available are:
 Code  Description

%d    Integer (use to display value of int and short variables)

%0Xd  Integer left-padded with up to X zeros

%s    String (use to display string variables)

%c    Character (displays the ASCII character of the supplied value)

%f    Float (displays a float variable)

%.Xf  Float to X decimal places

%%    Display the percent character (ie. no variable)
Title: Re: Random Int called in dialog behave strangely
Post by: Clarabella on Wed 05/08/2009 18:22:59
whops... ehr... I didn't know this! I just thought a random letter would be ok  :P
I knew it was something very very very stupid... and I was right.
Thanks a lot monkey!  :)
Title: Re: Random Int called in dialog behave strangely [solved]
Post by: monkey0506 on Wed 05/08/2009 18:26:29
I must admit you actually sparked my interest with this though...do you know specifically what letter you were using that was generating these hexadecimal values? :D

Anyway glad I got that sorted out for you. And remember, "When in doubt, RTFM!" :=
Title: Re: Random Int called in dialog behave strangely [solved]
Post by: Clarabella on Wed 05/08/2009 18:35:24
Quote from: monkey_05_06 on Wed 05/08/2009 18:26:29
I must admit you actually sparked my interest with this though...do you know specifically what letter you were using that was generating these hexadecimal values? :D

I was using %d
Wow, did I just find a new code to do strange things in ags?  :P

Quote
Anyway glad I got that sorted out for you. And remember, "When in doubt, RTFM!" :=

You're right... I promise I'll study better next time!