"how many of <item> exist" function?

razorboy

Member
I'm trying to script some daily food/drink crafting, but I would like to run a little "how many of these ingredients do i have" function beforehand that will error out and tell me what pieces I'm missing.

I was trying to use gcli commands, but I can't seem to find one that will return how many of an item I have in my inventory. Also, can I put that into a variable using gcli commands, or should I just start working on an ash script?
 

razorboy

Member
Of course I find it immediately after I post. Always.

Still, the second question remains, can you pipe "inv <whatever>" to a variable?

I'm thinking like "if inv MSG > 5 then asplode" ... uh, I guess I don't know how to echo anything, either.
 

razorboy

Member
This thing won't let me edit my post. Blek.

I'm thinking like 'if inv MSG > 5 then echo " you only have" inv MSG "MSG, which is not enough" '
(Yeah, I know that doesn't work. But the idea is there.)
 

razorboy

Member
EDIT, nm me, I fail at comparators.

I got it to work with an ash script.

if (item_amount ($item[MSG]) < 5) print("You don't have enough MSG", "red");
 
Last edited:

StDoodle

Minion
I'd go with ash; I don't know for sure, but while you can use control structures to some degree on the gCLI, I don't think you're going to be able to get the return values in a meaningful way to do what you want.

In the meantime, maybe try (on the gCLI)
Code:
ash int mcnt = item_amount($item[MSG]); if(mcnt < 5) print("You don't have enough MSG (" + mcnt + " in inventory)");

Edit to add: Your problem may well be that your sign is reversed!
 

razorboy

Member
Thanks, I figured most of it out, but I was struggling on the damn print syntax.

Is there a good ash tutorial or guide out there? I was thinking it was the same as unix shell scripts, but they don't seem to be the same.
 
Top