Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
N4no57

ATM system doesn't work

Question

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

1 answer to this question

Recommended Posts

Join the conversation

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.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.