# How do I create a buy max option.

0 Favourites
• 5 posts
• I have something that goes

Click on egg to get 1 egg

Buy baby chick for 10 eggs (makes 1 egg per second)

Buy chicken for 100 baby chicks (makes 1 baby chick per second)

Buy pen house for 1000 chickens (makes 1 chicken per second)

and so on...

But very fast I run into a problem where its impossible to spend all my eggs. How would I go about creating a buy max option.

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• math

...lol

--Add to "baby chick" floor(eggs/10) (eggs divided by price)

--Subtract from "eggs" floor(eggs/10)*10

Or (if they are sprites not variables)

-Repeat floor(eggs/10) times

--Create chick

--Subtract 10 from eggs

Floor() simply rounds down. So if you had 95 eggs, floor(eggs/10) would result in 9 (9.5 rounded down)

Edit: Whoops, had some stuff backwards

• Edited — had a bunch of mistakes

• Man you make it look easy :p Is there a way I can set it to buy only 10 instead of 10.2454578784?

How long have you been using construct ?

• Man you make it look easy :p Is there a way I can set it to buy only 10 instead of 10.2454578784?

How long have you been using construct ?

My profile says for just over a yearâ€”but I think it was a little longer than that. There is a ton I don't know but I just try to answer the questions in areas that I know.

Did you use the floor()? Because floor(10.2454578784) = 10

round() - rounds to nearest integer

floor() - rounds down

ceil() - rounds up

Once you start learning the commonly used expressions and such it will start to snowball. These are a couple pages to visit often:

https://www.scirra.com/manual/126/system-expressions

https://www.scirra.com/tutorials/77/nat ... onstruct-2

Then whenever you use something new to you visit the page in the manual so you know the conditions, actions, and expressions. Things that seem complicated may already be built inâ€”you just have to know what is available