This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
grand_mind1's profile picture

Potion Shop

Started by grand_mind1, 12 October 2013 - 01:52 PM
grand_mind1 #1
Posted 12 October 2013 - 03:52 PM
I'm working on making a potion shop with computercraft. Right now I'm doing the interface. I'm using this code:
http://pastebin.com/aPteuSAP
And my button API with it:
http://pastebin.com/TmCR7bWX

Everything is working fine except for the part where you chose which potion you want. I'm experiencing something extremely odd and I can't seem to find out what is causing it. If you click on any of the potions that have 3 variations( normal, increased potency and increased duration) then it will show the menu where you chose the variant and then it will immediately proceed to the Order Screen, saying that you've selected "Increased Potency". While this is strange in itself, it is also very random. It will sometimes happen and sometimes not. Selecting the potions and going back in certain orders seems to sometimes fix it. I've absolutely no idea what is going on and if someone could take a look at my code and try to figure out what's wrong, that'd be great.
Help is appreciated!
Thanks! :D/>
Bomb Bloke #2
Posted 12 October 2013 - 07:37 PM
function checkClick(x,y)
        for name, tableData in pairs(button) do
                if tableData["draw"] == true or tableData["draw"] == nil then
                        if x >= tableData["xmin"] and x <= tableData["xmax"] then
                                if y >= tableData["ymin"] and y <= tableData["ymax"] then
                                        tableData["func"](name)
                                end
                        end
                end
        end
end

Once the function within the table has executed more buttons become available, which may also be registered as clicked by the one press because you don't halt the for loop on finding a match. Throw in a "break" under line 79.
grand_mind1 #3
Posted 12 October 2013 - 08:25 PM
Thanks so much! :D/>