Posted 08 July 2014 - 04:25 PM
Hello guys and I came here to obviously ask a question about tables. Now I have been developing a small program for virtual currency where basically there is the computer from which you pay and the server of the bank. I have coded both but seem to get something wrong with the table (I suck at using tables). So here is the code for the server:
When I run this it gives me the following error after a small delay:
startup:10: attempt to index ? (a nil value)
Here is the code for the computer in case it helps:
--Setting up Host
rednet.open("right")
rednet.host("bankServer", "MineBank")
customers = {{0, 1000}, {1, 550}}
while true do
--Gets Intel
sender, ID = rednet.receive()
sender, amount = rednet.receive()
for i = 0, #customers do
if customers[i][0] == ID then
if customers[i][1] >= amount then
rednet.send(sender, "Done")
customer[i][1] = customer[i][1] - amount
else
rednet.send(sender, "Not Done")
end
end
end
end
When I run this it gives me the following error after a small delay:
startup:10: attempt to index ? (a nil value)
Here is the code for the computer in case it helps:
amount = 100
--Setting up
rednet.open("right")
--Finding bank and disk ID
bankServer = rednet.lookup("bankServer")
payerID = disk.getID("bottom")
--Sending Request
rednet.send(bankServer, payerID)
rednet.send(bankServer, amount)
bank, message = rednet.receive()
if message == "Done" then
print("Transaction Complete")
else
print("Transaction Failed")
end