Its probably not the best implementation but it saves time and code so... here it is.
Here is an example of how to use it. Make sure oldpad is at the bottom of your index.lua or whatever you are running. Also make sure pad is at the top.
--Init oldpad = Controls.read() while true do pad = Controls.read() .. if cp(start) then break end .. oldpad = pad end
Heres the function so you can push a button once. A good use of this would be for menus and stuff like that.
triangle = 1 square = 2 cross = 3 circle = 4 up = 5 down = 6 left = 7 right = 8 r = 9 l = 10 function cp(cpad) if cpad == triangle then if pad:triangle() and oldpad:triangle() ~= pad:triangle() then return true end elseif cpad == square then if pad:square() and oldpad:square() ~= pad:square() then return true end elseif cpad == cross then if pad:cross() and oldpad:cross() ~= pad:cross() then return true end elseif cpad == circle then if pad:circle() and oldpad:circle() ~= pad:circle() then return true end elseif cpad == up then if pad:up() and oldpad:up() ~= pad:up() then return true end elseif cpad == down then if pad:down() and oldpad:down() ~= pad:down() then return true end elseif cpad == left then if pad:left() and oldpad:left() ~= pad:left() then return true end elseif cpad == right then if pad:right() and oldpad:right() ~= pad:right() then return true end elseif cpad == r then if pad:r() and oldpad:r() ~= pad:r() then return true end elseif cpad == l then if pad:l() and oldpad:l() ~= pad:l() then return true end else return false end end