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.

Newcomers AppGameKit Corner / [SOLVED] Experimenting with Expressions-AGK Help

Author
Message
apocnhorsemen
8
Years of Service
User Offline
Joined: 30th Dec 2015
Location:
Posted: 14th Dec 2023 18:53
Good day

I'm following a tutorial that has me stuck. The online manual gives an example of working with expressions. When I follow the example code, no images show on the screen as well as I receive the following error message: "Integer division by 0 in main.agc at line 40". Can someone direct me to the correct fix to this tutorial? The line in question is :
Thank you in advance for any help. I also included the code in attached file.

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 14th Dec 2023 19:54
This post has been marked by the post author as the answer.
You need to add the # to your x, y, z and angle variables in the loop, since you've declared them as:





You never declared x, y or z to be floats (x# and x are different variables) so they're being treated as integers. Integers can't hold decimals, so that's why you're getting a divide by zero error.
apocnhorsemen
8
Years of Service
User Offline
Joined: 30th Dec 2015
Location:
Posted: 14th Dec 2023 19:58
I appreciate the response. Funny that makes sense because I just copied and pasted the code from the site, and it works. Operator error, I guess.
hendron
8
Years of Service
User Offline
Joined: 20th Dec 2015
Location:
Posted: 14th Dec 2023 20:10
No problem. One way to avoid this kind of problem altogether is to use #option_explicit. It can be a pain having to declare every variable, but it will prevent potentially hard to find bugs.

Login to post a reply

Server time is: 2024-11-21 08:47:18
Your offset time is: 2024-11-21 08:47:18