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

Lymia's Misc. Programs

Started by Lymia Aluysia, 28 January 2012 - 08:32 AM
Lymia Aluysia #1
Posted 28 January 2012 - 09:32 AM
Basic Keycard Lock
This is a pretty simple keycard program. It allows you to set a file name, and a password. If a file with that name containing the password is on the floppy disk you insert, this program will send a 4 second redstone pulse to a configurable side of the computer.

Spoiler
-- Basic keycard lock by Lymia
-- Released to the public domain
 
-- Clears the terminal
term.clear()
term.setCursorPos(1,1)
 
-- What file to look for the password in
local keyFile = "lockFile"
-- The password to look for
local keyContents = "12345"
-- What side to output the door signal to
local outputSide = "left"
 
while true do
    -- Get raw event data
    local rawEvent = {coroutine.yield()}
    local event = rawEvent[1]
    if event == "disk" then
        local side = rawEvent[2]
 
        -- Check if this is a data disk
        if disk.isPresent(side) and disk.hasData(side) then
            -- And if so, try to open the lock file
            local file = "/"..disk.getMountPath(side).."/"..keyFile
            file = fs.open(file,"r")
            if file then
                file = file.readAll()
 
                if file == keyContents then
                    print("Keyfile accepted!")
                    -- Send the door signal...
                    rs.setOutput(outputSide,true)
                    -- Send a "timer" event after 4 seconds
                    -- I could use sleep here, but, this way, I can still process disk
                    -- events while the redstone signal is on.
                    os.startTimer(4)
                else
                    print("Invalid keyfile")
                end
            else
                -- Guess the lockfile's not there
                print("Keyfile not found")
            end
        else
            print("Keyfile not found")
        end
 
        -- And now, eject the disk
        disk.eject(side)
    elseif event == "timer" then      
        -- This follows the timer set up in the lock checking code.
        -- Unset the door signal.
        rs.setOutput(outputSide,false)
    elseif event == "terminate" then
        -- Prevents Ctrl-T (It would be ignored otherwise anyways, but...)
        print("[termination intercepted]")
    end
end

Other programs
chroot - sandboxing and custom rom launching utility
Casper7526 #2
Posted 28 January 2012 - 10:17 AM
Root your root then root the rooted root possible?
Lymia Aluysia #3
Posted 28 January 2012 - 10:45 AM
Root your root then root the rooted root possible?
………???
FuzzyPurp #4
Posted 28 January 2012 - 10:52 AM
chroot chroot train.
Lymia Aluysia #5
Posted 28 January 2012 - 11:01 AM
chroot chroot train.
The chroot enviroment wouldn't be very good if you couldn't do that.
Rodizipa #6
Posted 14 February 2012 - 11:31 AM
SO, i have to create one file in card named "keyfile" with the pass inside right ? Wonderful XD
Selkitty #7
Posted 14 February 2012 - 04:56 PM
SO, i have to create one file in card named "keyfile" with the pass inside right ? Wonderful XD

A Floppy, yes. put a blank floppy into a terminal and type edit disk/keyfile (or cd disk then edit keyfile) and int he editor type the pass then save and exit, simple as that x3 *is using this lock program for everything from elevators to deadly laser fields*… XD
Rodizipa #8
Posted 14 February 2012 - 10:14 PM
i haven't made it. I opened the data file of floopy disk and i copied the code (and edit the pass with notepad) for a file without extension.
Selkitty #9
Posted 15 February 2012 - 05:23 AM
i haven't made it. I opened the data file of floopy disk and i copied the code (and edit the pass with notepad) for a file without extension.

huh? the program doesnt go on the floppy, just the password; the program goes on the terminal and is run there
Rodizipa #10
Posted 15 February 2012 - 01:56 PM
)_) save/computer/id of computer/programs > the code
in floppy > create a file named keyfile with your pass
Selkitty #11
Posted 16 February 2012 - 01:34 AM
Yea o.o;
plazter #12
Posted 14 March 2012 - 08:35 AM
Basic Keycard Lock This is a pretty simple keycard program. It allows you to set a file name, and a password. If a file with that name containing the password is on the floppy disk you insert, this program will send a 4 second redstone pulse to a configurable side of the computer.
Spoiler
-- Basic keycard lock by Lymia -- Released to the public domain -- Clears the terminal term.clear() term.setCursorPos(1,1) -- What file to look for the password in local keyFile = "lockFile" -- The password to look for local keyContents = "12345" -- What side to output the door signal to local outputSide = "left" while true do -- Get raw event data local rawEvent = {coroutine.yield()} local event = rawEvent[1] if event == "disk" then local side = rawEvent[2] -- Check if this is a data disk if disk.isPresent(side) and disk.hasData(side) then -- And if so, try to open the lock file local file = "/"..disk.getMountPath(side).."/"..keyFile file = fs.open(file,"r") if file then file = file.readAll() if file == keyContents then print("Keyfile accepted!") -- Send the door signal... rs.setOutput(outputSide,true) -- Send a "timer" event after 4 seconds -- I could use sleep here, but, this way, I can still process disk -- events while the redstone signal is on. os.startTimer(4) else print("Invalid keyfile") end else -- Guess the lockfile's not there print("Keyfile not found") end else print("Keyfile not found") end -- And now, eject the disk disk.eject(side) elseif event == "timer" then -- This follows the timer set up in the lock checking code. -- Unset the door signal. rs.setOutput(outputSide,false) elseif event == "terminate" then -- Prevents Ctrl-T (It would be ignored otherwise anyways, but...) print("[termination intercepted]") end end
Other programs chroot - sandboxing and custom rom launching utility

when i copy paste it as you have the code right here.. its says
"bions:206: [string "lol"]:12: '=' expected"
.. why? :/