Posted 17 May 2014 - 05:30 PM
Hello im current experiencing an error in a program that i designed a while ago however never finished the program errors on line 46 giving the error lua:46: attempt to concatenate string and nil and line 46 is rednet.send(1, "auth") so i dont understand how this is erroring any help would be much appreciated
p.s there proberly is alot more errors in this code as im currently debugging and finalizing it for release
p.s there proberly is alot more errors in this code as im currently debugging and finalizing it for release
Spoiler
function load()
print("load")
rednet.open("back")
print("activating server")
get()
end
function get()
--[[
var1 = 0
var2 = 0
var3 = 0
var4 = 0
var5 = 0
var6 = 0
var7 = 0
var8 = 0
var9 = 0
var10 = 0
var11 = 0
var12 = 0
var13 = 0
var14 = 0
var15 = 0
]]
print("get")
var1, var2, var3 = rednet.receive()
print(tostring(var1)..tostring(var2)..tostring(var3))
if var2 == "request" then request() else deny()
end
end
function request()
print("request")
var4, var5, var6 = rednet.receive()
print(tostring(var4)..tostring(var5))
if fs.exists("usernames/"..tostring(var5)) == true then
pin()
else
deny()
end
end
function pin()
print("pin")
rednet.send(1, "auth")
print("s")
var7, var8 = rednet.receive()
print(var7..var8)
h = fs.open("userpins/"..tostring(var5).."/pin", "r")
pinno = h.readAll()
h.close()
if var8 == pinno then auth() else deny()
end
end
function auth()
print("auth")
rednet.send(var7,"auth")
command()
end
function command()
state = true
print("command")
while state == true do
var10, var11, var12 = rednet.receive()
print(tostring(var10)..tostring(var11)..tostring(var12))
if var11 == "check balance" then checkbalance()
elseif var11 == "withdraw" then withdraw()
elseif var11 == "transfer" then transfer()
elseif var11 == "logout" then logout()
end
end
end
function checkbalance()
print("checkbalance")
h = fs.open("userbalance/"..tostring(var5).."/balance", "r")
bal = h.readAll()
rednet.send(var10, bal)
command()
end
function withdraw()
print("withdraw")
h = fs.open("userbalance/"..tostring(var5).."/balance", "r")
bal = h.readAll()
h.close()
var13, var14, var15 = rednet.receive()
print(tostring(var13)..tostring(var14)..tostring(var15))
curbal = bal - var14
h = fs.open("userbalance/"..tostring(var5).."/balance", "w")
h.write(tostring(curbal))
h.close()
rednet.send(tostring(var13), tostring(var14).." has been deducted you current balance is "..tostring(curbal))
end
function transfer()
print("transfer")
end
function logout()
print("logout")
state = false
get()
end
function deny()
print("deny")
rednet.send(var1, "denied")
end
load()
Edited on 17 May 2014 - 03:31 PM