@SkyTheCoder, I made a few small changes to the code in main (and a few in Passdrag class just to change look a bit).
I took out a lot of the stuff in the output window and moved it to the screen. I also removed showing the pass because someone could just look over and see it. And same reason for removing the saved pass (plus you can overwrite it easily)
Here it is:
--The MIT License (MIT)
--
--Copyright (c) 2014 SkyTheCoder
--
--Permission is hereby granted, free of charge, to any person obtaining a copy
--of this software and associated documentation files (the "Software"), to deal
--in the Software without restriction, including without limitation the rights
--to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
--copies of the Software, and to permit persons to whom the Software is
--furnished to do so, subject to the following conditions:
--
--The above copyright notice and this permission notice shall be included in all
--copies or substantial portions of the Software.
--
--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
--IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
--FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
--AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
--LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
--OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
--SOFTWARE.
function setup()
print()
pd = Passdrag(WIDTH / 2, HEIGHT / 2, 175)
styles = {"Nature", "Light", "Dark", "Retro", "Sky"}
parameter.integer("Style", 1, #styles, 1)
parameter.action("Save Passdrag", function()
savePassdrag()
output.clear()
print()
tween.delay(0.1, function()
output.clear()
print()
print("Passdrag saved")
end)
end)
end
function draw()
pd:setStyle(styles[Style])
background(pd.styles[pd.style].bg)
pd:draw()
font("HelveticaNeue-Light")
fontSize(48)
fill(pd.styles[pd.style].txt)
text("Passdrag", WIDTH / 2, HEIGHT - HEIGHT / 16)
fontSize(24)
text("Theme: " .. styles[Style], WIDTH / 2, HEIGHT - HEIGHT / 8)
text("Drag Length: " .. pd.sequence:len(), WIDTH / 2, HEIGHT - HEIGHT / 6)
text("Matches Saved: " .. boolToStr(checkPassdrag()), WIDTH / 2, HEIGHT / 6)
end
function touched(touch)
pd:touched(touch)
end
function savePassdrag()
local fileName = "passdrag.txt"
local file = os.getenv("HOME") .. "/Documents/" .. fileName
local wFd = io.open(file, "w")
wFd:write(pd.sequence)
wFd:close()
end
function readPassdrag()
local fileName = "passdrag.txt"
local file = os.getenv("HOME") .. "/Documents/" .. fileName
local rFd = io.open(file, "r")
local v = ""
if rFd ~= nil then
for i in rFd:lines() do
v = v .. i
end
end
if rFd ~= nil then
rFd:close()
end
return v
end
function checkPassdrag()
return pd.sequence == readPassdrag()
end
function boolToStr(bool)
local str = "false"
if bool == true then
str = "true"
end
return str
end