Help With Fuction item_amount

So, I have used this function countless times and never has it acted in this way. I have a simple item amount check and if it returns true, do something with it. Here is the code
if (item_amount($item[prussian cathouse]) == 4);
			cli_execute("drink 4 prussian cathouse");

As far as I understand, it should just check to see if you have that amount of item in your inventory and if you do return true, if not return false. Instead, it is trying to craft the drinks, which I do not want. It asks if I want to spend adventures crafting and if I say yes it starts searching for the ingredients and buying stuff and then fails because it couldn't obtain one of the ingredients. Is it suppose to act in this way and I just never noticed?


Staff member
That semicolon after the if statement's condition looks like it's causing you all sorts of grief.


Staff member
Yeah, that cli_execute() is not part of the if block in your code.

You don't have to use { and } for if statements that only have a single line in them, but it can help with readability. If you used those, then the semicolon would have given a script parsing error instead of doing something different than what you wanted.

On the other hand, maybe that code should give an error anyway with the semicolon there.

On another note, you probably want to check that you have >= 4 instead of == 4, so that it will work if you have 20 of them for some reason.
Wow I feel really stupid for missing that xD. Thanks guys. Yeah lost, except its in SC ascension so I am assuming people won't be magically gaining Prussian cat houses, although I guess they could have manually crafted some...


it should just check to see if you have that amount of item in your inventory
Keep in mind that it checks to see if you have exactly that amount in your inventory. If you simply want to check if you have enough to drink four, you could use ">= 4".

EDIT: reading other's posts to the end would avoid this kind of embarrassment.
Last edited: