Posted 30 January 2014 - 06:33 AM
So I've been planning to work on a simple banking program, with a server and client setup to practice with tables, and rednet protcol. I was making a bit of test code, and I've seem to have come across an issue working on it. I'm trying to have a table named after the account that would hold, pin numbers, account ids, and account names, be added to the main table or "database". It seems no matter how much I messed with the broken line of code it wouldn't work. I already manually added in a default user into the table to play around with it, and table.insert would just add another user into the banking server "database". I'm newer to tables, and need a way to make this work correctly.
Pastebin: http://pastebin.com/whU97UiN
Pastebin: http://pastebin.com/whU97UiN
t = {
Firestorm002 = {pin = 1234, accid = 123456789, usrname = "Firestorm002"}
}
term.clear()
term.setCursorPos(1,1)
sleep(1)
term.write("Pin#: ")
local pinnumber = read()--Pin number would be entered through an input.
local accid = math.random(1,16)
local NewUser = "Bob"
--Throws Error Code:<bios:339: [string "tables]:16: ')' expected>
---[[
table.insert(t, NewUser = {pin = pinnumber, accid = accountid, name = NewUser})
--]]
h = fs.open("table.db","w")
sTable = textutils.serialize(t)
h.write(sTable)
h.close()
Edited on 31 January 2014 - 02:09 AM