Easy, just use a global variable. Initialize it once in the beginning.Like MONEY=10:POTIONS=0. In your shop loop just do this IF MONEY>=3 THEN INC POTIONS; MONEY=MONEY-3;WAIT 5 after selecting item.