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

FreackSafe - v 0.1

Started by H4X0RZ, 03 July 2013 - 09:54 AM
H4X0RZ #1
Posted 03 July 2013 - 11:54 AM
Hello to FreackSafe!

What is it?
SpoilerA program I've done while I was bored.
It supports numbers from -9 to 9.
You have to "enter" the code with the mouse-wheel.

The code:
Spoiler

local oldPull = os.pullEvent
os.pullEvent = os.pullEventRaw
local nubers = {}
local code {1,2,3}
local visible = {}
local checked = {}
local name = shell.getRunningProgram()
local x,y = term.getSize()
local valid = true
local ascii = [[




               ___________________
              /    Secure Safe    \
             /        ____         \
            |        /    \___      |
            |        | 00 |___|     |
            |        \____/         |
             \                     /
              \___________________/
]]
local currNum = 0
local currPos = 1

term.clear()
term.setCursorPos(1,1)
print(ascii)
while true do
  local sEvent,a1,a2,a3 = os.pullEvent()
  if sEvent == "mouse_scroll" then
    if a1 == 1 then
      if currNum > -9 then
        currNum = currNum - 1
      end
    elseif a1 == -1 then
      if currNum < 9 then
        currNum = currNum + 1
      end
    end
    elseif sEvent == "mouse_click" and a1 == 1 then
      numbers[currPos] = currNum
      visible[currPos] = (currNum .. " ")
      currPos = currPos + 1
    end
    if numbers[#code] ~= nil then
      break
    end
    term.clear()
    term.setCursorPos(1,1)
    print(ascii)
    term.setCursorPos(24,9)
    if currNum < 10 and currNum > -1 then
      write("0"..currNum)
    else
      write(currNum)
    end
    term.setCursorPos((x/2)-(string.len(table.concat(visible))/2),15)
    term.write(table.concat(visible))
end
for i = 1, #code do
  if code[i] == numbers[i] then
    checked[i] = true
  else
    checked[i] = false
  end
end
for i = 1, #checked do
  if checked[i] == false then
    valid = false
    break
  end
end
if not valid then
  term.clear()
  term.setTextColor(colors.red)
  term.setCursorPos((x/2)-string.len("WRONG.)/2,y/2)
  term.write("WRONG.")
  sleep(.25)
  term.setTextColor(colors.white)
  shell.run(name)
end
os.pullEvent = oldPull
term.clear()
term.setCursorPos(1,1)
To change the code, (now) you have to change the code table in the program

Useless facts:
Spoilertotal lines:86

Thx for reading
-Freack100-
Zudo #2
Posted 03 July 2013 - 01:00 PM
What is the purpose of this program?
jesusthekiller #3
Posted 03 July 2013 - 01:12 PM
Useless
H4X0RZ #4
Posted 03 July 2013 - 04:18 PM
Why?
It's a lock screen which wants numbers instead of a password. It's designed for advanced computers.

So, why is it useless? I think there is at least one person who likes/needs this on our world…
TheOddByte #5
Posted 04 July 2013 - 02:32 AM
Useless
You should post somenthing nicer than that and also it's your comment that's useless(One word..)
You should explain what you think is bad etc.
Dave-ee Jones #6
Posted 04 July 2013 - 03:46 AM
I like it. It's a code lock :)/> (Used to lock safes, doors and computers)

The GUI looks alright in the code.
micmou #7
Posted 05 July 2013 - 05:40 AM
EDIT: Also meant for pm.
micmou #8
Posted 05 July 2013 - 05:43 AM
EDIT: Oops meant for a pm accidentally typed in hear instead of pm.
UMayBleed #9
Posted 06 July 2013 - 12:21 AM
It's basically a keypad, I think this is totally useful!
Dave-ee Jones #10
Posted 06 July 2013 - 01:42 AM
Yeah. I think so too :)/> Be awesome to have it protecting a house or safe.
Tjakka5 #11
Posted 06 July 2013 - 03:18 AM
I kind of like it :)/>
scheurneus #12
Posted 10 July 2013 - 06:39 AM
Could you put this in pastebin please?
Engineer #13
Posted 10 July 2013 - 07:12 AM
Could you put this in pastebin please?
Time to head to.. http://pastebin.com !
We can upload it too!

BAM! done!
http://pastebin.com/5K1jBiGb


pastebin get 5K1jBiGb startup
Xenthera #14
Posted 10 July 2013 - 04:14 PM
Ok ok … Am I the only one who actually tested this? The code he gives you wont work, (missing =, inconsistent varnames)

Anyway, I fixed the derps so here's a working version.

http://pastebin.com/f9p65z62
superaxander #15
Posted 10 July 2013 - 06:56 PM
Would be nice on a monitor
H4X0RZ #16
Posted 11 July 2013 - 02:50 AM
Would be nice on a monitor
Okay, I will start working on a monitor version :)/>
Apfeldstrudel #17
Posted 11 July 2013 - 04:18 AM
term.setCursorPos(x/2)-string.len("WRONG.)/2,y/2) you missed a quote(line 9 from bottom)