Deprecated: Assigning the return value of new by reference is deprecated in /var/www/psdevWiki/inc/parserutils.php on line 161

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/psdevWiki/inc/parserutils.php on line 164

Deprecated: Assigning the return value of new by reference is deprecated in /var/www/psdevWiki/inc/parserutils.php on line 294

Deprecated: Function split() is deprecated in /var/www/psdevWiki/inc/auth.php on line 97

Warning: Cannot modify header information - headers already sent by (output started at /var/www/psdevWiki/inc/parserutils.php:161) in /var/www/psdevWiki/inc/auth.php on line 180

Deprecated: Function split() is deprecated in /var/www/psdevWiki/inc/common.php on line 552

Warning: Cannot modify header information - headers already sent by (output started at /var/www/psdevWiki/inc/parserutils.php:161) in /var/www/psdevWiki/inc/actions.php on line 71
psp:lua_player:pickdat:buttononce [psDevWiki]
Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /var/www/psdevWiki/inc/template.php on line 154
 

Hit button once

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
 

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead in /var/www/psdevWiki/inc/template.php on line 523
psp/lua_player/pickdat/buttononce.txt · Last modified: 2008/05/15 00:07
 
Recent changes RSS feed Creative Commons License Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki