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.

Android / [SOLVED] Learning to Code

User Offline
Joined: 5th Jun 2018
Posted: 5th Jun 2018 02:49
Hello everyone, long time viewer first time poster.

I am attempting to write a piece of code which will do the following.

Step One: Make a clickable area preferably a circle.
Step Two: Upon user click, within the circle, it will generate a random number between 1 - 3 (if player clicks outside circle nothing happens)
Step Three: Using a nesting if statement assign an action to each random number generated.

Sadly the nesting if statements are giving me a serious migraine. Is anyone able to assist?

Thanks in advance...


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

Go to answer

Valued Member
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 6th Jun 2018 19:35

have you thought about using Select / Case?

Coders don't die, they just gosub without return
User Offline
Joined: 6th Jan 2018
Posted: 11th Jun 2018 14:02
This post has been marked by the post author as the answer.
Without seeing any code, it is difficult to determine what you are doing wrong. If you are trying to pick a different action based on the random selection, you should use one of the following structures.

Alternatively, you can use Select/Case

The nice thing about Select/Case is that you can combine results. So if choice 1 and 3 have the same outcome, you can do
Case 1, 3
AGK Tool Maker
Years of Service
User Offline
Joined: 9th Mar 2015
Location: Londinium
Posted: 16th Jun 2018 12:12
Quote: "The nice thing about Select/Case is that you can combine results."

yes, its very helpful, I also like you can fold case sections, unfolded if-else-endif make messy code and hurt my eyes! lol
Years of Service
User Offline
Joined: 3rd Feb 2017
Posted: 29th Jun 2018 12:18
You can alternatively structure the options in Types and iterate beween them. This avoids excessive conditionals.

Login to post a reply

Server time is: 2018-12-10 04:53:23
Your offset time is: 2018-12-10 04:53:23