Posted 19 August 2014 - 08:34 PM
Hello,
I'm actually encountering a problem with the detection of an event (biolock of gopher)
Here's the code (subtitled in english ;)/>):
So here's the point:
According to my code, the computer needs to detect when I print my fist on the biolock.
It do when I register a new user (with the
but when I start the computer and try to detect right on, it doesn't work.
But the detection of the [*](key 55) works perfectly…
I really don't know where's the mistake…
Furest
I'm actually encountering a problem with the detection of an event (biolock of gopher)
Here's the code (subtitled in english ;)/>):
--peripheriques
-- p = peripheral.wrap("back")
--lecture de la table
local handle = assert(fs.open("list", "r"), "desole, je n' ai pas pu lire la table") --sorry, can't read the table
local fichier = handle.readAll()
if fichier == "" then
print("table vide") --table is empty
noms = ""
else
noms = textutils.unserialize(fichier)
end
handle.close()
-- check si l'empreinte existe
function checkexist(info)
if noms == "" then
print("vide") --empty
return false
else
for nom, code in pairs(noms) do
if code == info then
return true
else
return false
end
end
end
end
--inscrit la nouvelle carte
function newprint()
term.clear()
term.setCursorPos(1,1)
print("Veuillez entrer le nom de la personne:") -- enter the name of the player plz
term.setCursorPos(1,2)
nomC = read()
print("Veuillez scanner votre main svp...") --scan your fist plz
local event, info = os.pullEvent()
if event == "key" and info ==55 then
os.reboot()
elseif event == "biolock" then
if checkexist(info) == true then
term.clear()
term.setCursorPos(1,1)
print("Utilisateur deja enregistre") --user already registered
else
print("Nom inconnu... Ajout a la base") --unknown name. added to the database
if noms == "" then
noms = {}
end
noms[nomC] = info
print("Nom inscrit") --name registered
local output = textutils.serialize(noms)
local handle = assert(fs.open("list", "w"), "desole, je n'ai pas pu lire la table") --sorry, can't read the table
handle.write(output)
handle.close()
print("Donnees enregistrees") --data registered
end
end
end
--Attente de la lecture ou de l'étoile
while true do
print("Lecture prête") --ready to read
local event, info = os.pullEvent()
print("event detecte") --event detected
if event == "key" and info == 55 then
print("test")
newprint()
sleep(2)
os.reboot()
elseif event == "biolock" then --PROBLEM HAPPENS HERE!!! (cf next lines after the code)
print("Empreinte detectee") --print detected
if rs.getInput("front") == true then
print("pas au centre") --you're not centered
os.reboot()
else
print("empreinte lue") -- print read
if checkexist(info) then
print("ouvreporte") --opening door
rs.setOutput("left", true)
rs.setOutput("bottom", true)
os.reboot()
else
print("ce joueur n'existe pas...") --this player doesn't exists
sleep(5)
os.reboot()
end
end
end
end
So here's the point:
According to my code, the computer needs to detect when I print my fist on the biolock.
It do when I register a new user (with the
elseif event == "biolock" then
)but when I start the computer and try to detect right on, it doesn't work.
But the detection of the [*](key 55) works perfectly…
I really don't know where's the mistake…
Furest
Edited on 19 August 2014 - 06:39 PM