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

Debit card system

Started by bobmandude9889, 22 December 2013 - 10:16 PM
bobmandude9889 #1
Posted 22 December 2013 - 11:16 PM
So I've been making a debit card system for a private server I play on but I keep getting this error when I try to withdraw


startup:30:attempt to index ? (a nil value)

That is on the server computer that holds the information.

here is the code for the ATM:
http://pastebin.com/xYh6Vyaq

here is the code for the server:
http://pastebin.com/1CFfDF3T

Thank you! :)/>
Edited on 22 December 2013 - 10:16 PM
awsmazinggenius #2
Posted 22 December 2013 - 11:19 PM
Lemme check out your code. The error means you are trying to index a key in a table that is nil.

EDIT: Why are you unserializing a string? (readAll returns a string)

EDIT 2: That might actually be the issue. I only took a brief look at the code, though. Did you mean to serialize it instead?

EDIT 3: The error should be on line 30, inside the checkPin() function.
Edited on 22 December 2013 - 10:22 PM
bobmandude9889 #3
Posted 22 December 2013 - 11:36 PM
I am unserializing it to get it back to table form
Goof #4
Posted 23 December 2013 - 06:50 PM
Errm…

You dont declare the "ids" table before you're calling them.

check this for an example:


before the if statement:

while true do
local reply,command,distance = rednet.receive()
print(command)

after:


elseif command == "change_balance" then
		sleep(1)
		rednet.send(reply,"id:pin:amount")
		local i,m,d = rednet.receive()
		local id = m:sub(1,5)
		local pin = m:sub(7,10)
		local amount = m:sub(12,#m)
		loadIds()
		sleep(1)
		checkPin(reply,id,pin,updateBalance,id,amount)


REST OF THE CODE...


so to fix this, you must declare a table with the name of "ids"


I hope that fixed it.
Edited on 23 December 2013 - 05:51 PM
awsmazinggenius #5
Posted 23 December 2013 - 07:10 PM
I am unserializing it to get it back to table form
Yeah, that would be mixing up the two functions again. Sorry for that :(/>.