Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / How to convert a integer to a string?

Author
Message
Mark Garrett
Reviewed AGK on Steam
19
Years of Service
User Offline
Joined: 10th Jul 2005
Location: California, US
Posted: 6th Aug 2017 03:39 Edited at: 6th Aug 2017 03:52
In my game I want to let the player know how much points he has. But I don't know how to do it.
Here is one of my latest attempts to do it. Anyone know how to do it ?

In the game, I use the integer 'points' because I need to add more points to it each round of the game. And, of course, using an integer is the easiest way to do this.

Then, hopefully, I can put the new total in by using 'SetTextString' somehow,... but how? First I need to convert the integer 'points' into a string, but how does a person do that?




I get this error message- Incompatible types "String" and "Integer"
.
Sph!nx
15
Years of Service
User Offline
Joined: 3rd Dec 2008
Location: The Netherlands
Posted: 6th Aug 2017 04:03
Last line should be:

SetTextString (3, "Word points = " + str(points))
Regards Sph!nx
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 6th Aug 2017 04:05
Str
Description
Converts a value into a string, if you are calling this command from tier 2 this string must be deleted when you are done with it.
Definition

string Str( valueFloat )
string Str( valueFloat, decimals )
string Str( valueInt )

in your example
SetTextString (3, "Word points =  " +str(points))

or you could make a$="Word points =  " +str(points)
SetTextString (3, a$)
fubar

Login to post a reply

Server time is: 2024-09-30 05:32:22
Your offset time is: 2024-09-30 05:32:22