I have been trying to make an atm system but uh the code gets the error:
bad argument #1 (string expected, got nil):
stack traceback:
[C]: in function 'error'
machine:1045: in function <machine:1042>
(...tail calls...)
/home/create:41 in main chunk
(...tail calls...)
[C]: in function 'xpcall'
machine:799: in global 'xpcall'
/lib/process.lua:63: in function </lib/process.lua:59>
here is the code:
local event = require("event")
local component = require("component")
local internet = component.internet
local cardwriter = component.os_cardwriter
local keypad = component.os_keypad
local args = {...}
local pin = ""
do
keypad.setDisplay("Your PIN")
while true do
local action, _, _, char = event.pull()
if action == "keypad" then
if char == "#" then
keypad.setDisplay("Ok")
os.sleep(1)
keypad.setDisplay("")
break
elseif char == "*" then
keypad.setDisplay("Reseted")
pin = ""
os.sleep(1)
keypad.setDisplay("Your PIN")
else
pin = pin .. char
end
end
end
end
local request = "username=" .. args[1] .. "&pin=" .. pin
local response = internet.request("http://localhost/create", request)
local id
while true do
local tmp = response.read()
if not (tmp == "") then
id = tmp
break
end
end
response.close()
cardwriter.write(id, "Bankcard", false)
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
I have been trying to make an atm system but uh the code gets the error:
bad argument #1 (string expected, got nil):
stack traceback:
[C]: in function 'error'
machine:1045: in function <machine:1042>
(...tail calls...)
/home/create:41 in main chunk
(...tail calls...)
[C]: in function 'xpcall'
machine:799: in global 'xpcall'
/lib/process.lua:63: in function </lib/process.lua:59>
here is the code:
local event = require("event")
local component = require("component")
local internet = component.internet
local cardwriter = component.os_cardwriter
local keypad = component.os_keypad
local args = {...}
local pin = ""
do
keypad.setDisplay("Your PIN")
while true do
local action, _, _, char = event.pull()
if action == "keypad" then
if char == "#" then
keypad.setDisplay("Ok")
os.sleep(1)
keypad.setDisplay("")
break
elseif char == "*" then
keypad.setDisplay("Reseted")
pin = ""
os.sleep(1)
keypad.setDisplay("Your PIN")
else
pin = pin .. char
end
end
end
end
local request = "username=" .. args[1] .. "&pin=" .. pin
local response = internet.request("http://localhost/create", request)
local id
while true do
local tmp = response.read()
if not (tmp == "") then
id = tmp
break
end
end
response.close()
cardwriter.write(id, "Bankcard", false)
any insight?
Link to post
Share on other sites