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 / Bug with evaluating a constant?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Nov 2021 20:09
Not sure if considered a bug or just how the system works, but either way it's just yet another annoyance I have with how constants work in AGK.
Essentially, when you use a constant it doesn't hold any value at all but is a placeholder for whatever is assigned to it. In my function below, it doesn't see 0.2 (1280/6400), it literally inserts 1280 / 6400 into the middle of the equation, which unless I wrap RATIO_X in parenthesis, throws off the whole value.




[/code]
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

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

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Nov 2021 20:16
Here's another problem.

#CONSTANT SCREEN_WIDTH = 1280
#CONSTANT RATIO_X = SCREEN_WIDTH / 6400.0

Any place I try to use RATIO_X tells me screen_width is being used without being defined or initialized.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

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

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Nov 2021 21:14
We have been over this a few times in the last few months, it must defined with a constant static value ie, a number or a literal string, the pre-processor does not replace macros inside other macros, to get around this pipe your division through a function



This will force the pre-processor to replace the macro
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 11th Nov 2021 22:19
But then it's doing the calculation every time I use the constant. It's just annoying when the entire language passes things by value except for this one case. I just said screw it and used globals for everything, which I hate doing but at least they work as one would expect.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

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

PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 11th Nov 2021 23:12
If the macro worked as intended it would also be doing the calculation every time its used, the macro is basic search and replace, the only way to not have the calculation run every time is store the result in a global
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 11th Nov 2021 23:40 Edited at: 11th Nov 2021 23:40

Login to post a reply

Server time is: 2024-04-19 10:15:55
Your offset time is: 2024-04-19 10:15:55