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 Studio Chat / Including leading zeros in numerical strings

Author
Message
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 26th Dec 2022 04:33 Edited at: 26th Dec 2022 04:37
In a current game project I wanted to show leading zeros when the scoreboard isn't filled up, I also wanted to crop it to a given number of spaces while still preserving the rightmost digit. I looked through the documents in AppGameKit Studio for a function for doing this and couldn't find one, so I brewed my own. I assume this should also work in AGK-2. I have also submitted this to the codebase.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Dec 2022 18:11
Here's a simplified way.

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 26th Dec 2022 18:49 Edited at: 26th Dec 2022 18:51
@Phaelax

I just tried your way, it won't compile. It seems to work this way though. Thanks for putting me on the right track.


Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 26th Dec 2022 19:35
How I never spotted the obvious in the first place puzzles me, it must be brain rot setting in.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Dec 2022 16:27
You must have explicit variables set in your IDE.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 28th Dec 2022 03:32
I worked out why the error eventually, there was an invalid character just before r$ = right("0000000"+str(num), 7)

I removed the spaces and then gave it new tabs and then it compiled, it must've been something to do with the text formatting on this forum.

Login to post a reply

Server time is: 2024-04-25 17:43:49
Your offset time is: 2024-04-25 17:43:49