Applied the renames for "minimum buttons pressed", "minimum buttons inputted".

This commit is contained in:
brandonevans 2012-04-25 04:35:27 +00:00
parent 82999aa2a9
commit 32a7970a99
1 changed files with 122 additions and 122 deletions

View File

@ -6,10 +6,10 @@ local controllers = 2
local x = 0
local y = 8
local holds = 0
local players = {}
local presses = 0
local states = {}
local pressed = 0
local inputted = 0
function table.copy(t)
local t2 = {}
@ -20,23 +20,23 @@ function table.copy(t)
end
function counts()
--Display the counts of the holds and the presses.
gui.text(x, y, 'Holds: ' .. holds)
gui.text(x, y + 8, 'Presses: ' .. presses)
--Display the counts of the buttons pressed and inputted.
gui.text(x, y, 'Pressed: ' .. pressed)
gui.text(x, y + 8, 'Inputted: ' .. inputted)
end
function load(slot)
--As Lua starts counting from 1, and there may be a slot 0, increment.
slot = slot + 1
if not states[slot] or not states[slot].holds then
if not states[slot] or states[slot].inputted == nil then
gui.text(x, y + 16, 'No data loaded from slot ' .. tostring(slot - 1))
counts()
return
end
--Load the data if there is any available for this slot.
holds = states[slot].holds
players = table.copy(states[slot].players)
presses = states[slot].presses
pressed = states[slot].pressed
inputted = states[slot].inputted
gui.text(x, y + 16, 'Data loaded from slot ' .. tostring(slot - 1))
counts()
end
@ -79,13 +79,13 @@ function parse()
button = button + 1
--Check if this button is pressed.
if text ~= ' ' and text ~= '.' then
holds = holds + 1
inputted = inputted + 1
--If the button was not previously pressed,
--increment.
if table.maxn(last) < player or not last[player][
match[button]
] then
presses = presses + 1
pressed = pressed + 1
end
if table.maxn(players) < player then
table.insert(players, {})
@ -110,9 +110,9 @@ function save(slot)
table.insert(states, {})
end
--Mark the current data as the data for this slot.
states[slot].holds = holds
states[slot].players = table.copy(players)
states[slot].presses = presses
states[slot].pressed = pressed
states[slot].inputted = inputted
gui.text(x, y + 16, 'Data saved to slot ' .. tostring(slot - 1))
counts()
end
@ -130,19 +130,19 @@ end
while true do
--If this is the first frame, reset the data.
if emu.framecount() == 0 then
holds = 0
players = {}
presses = 0
pressed = 0
inputted = 0
end
--Check players one and two.
for player = 1, controllers do
local buttons = joypad.getdown(player)
--Run through all of the pressed buttons.
for i, v in pairs(buttons) do
holds = holds + 1
inputted = inputted + 1
--If in the previous frame the button was not pressed, increment.
if table.maxn(players) >= player and not players[player][i] then
presses = presses + 1
pressed = pressed + 1
end
end
if table.maxn(players) < player then