Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

What do I wrong? Help with error

edited June 2015 in Questions Posts: 8

Hello community! What do I wrong with the following code? I get always following error message: error: [string "loginScreen=class()..."]:18: bad argument #2 to 'request' (expected a function)

The code:


loginScreen=class() function loginScreen:init() end function loginScreen:draw() background(30,30,0,255) fontSize(40) text("Welcome",200, 700) stroke(255) fill(255) if show==1 then http.request('http://ni208411_2.vweb15.nitrado.net/ai2/userscsv.php' , getShowData, notGetShowData) end strokeWidth(6) fontSize(20) buttonLogin:draw() buttonShow:draw() buttonRegister:draw() if loginStatus==1 then fill(0, 255, 3, 255) text("Logged in",450,550) state="loggedin" else if loginStatus==0 then fill(255,0,0,255) text("Logged out",450,550) else if loginStatus==2 then fill(255,0,0,255) text("Unknown Username, Try again", 450,550) else if loginStatus==3 then fill(255,0,0,255) text("Wrong Password, Try again",450,550) end end end end for a,b in pairs(userTab) do fill(255, 0, 0, 255) if a==selectedUser then fill(128,0,0,255) if userStat==1 then strUserTab[a] = keyboardBuffer() end end rect(b.x,b.y,b.z,b.w) fill(255) text(strUserTab[a],b.x,b.y) end for e, f in pairs(passTab) do fill(255, 0, 0, 255) if e==selectedPass then fill(128,0,0,255) if passStat==1 then strPassTab[e] = keyboardBuffer() end end rect(f.x,f.y,f.z,f.w) fill(255) text(strPassTab[e],f.x,f.y) end end function loginScreen:touched() if buttonLogin:touched(touch) then print("Login pressed") if readProjectData(strUserTab[selectedUser])==strPassTab[selectedPass] then loginStatus=1 else if readProjectData(strUserTab[selectedUser],"wrong")=="wrong" then fill(255, 0, 0, 255) loginStatus=2 else fill(255,0,0,255) loginStatus=3 end end end if buttonShow:touched(touch) then print("Succesful showed") show=1 end if buttonRegister:touched(touch) then print("Switch to registerScreen") state="register" end for a,b in pairs(userTab) do if CurrentTouch.x > b.x-b.z/2 and CurrentTouch.x < b.x+b.z/2 and CurrentTouch.y > b.y-b.w/2 and CurrentTouch.y < b.y+b.w/2 then passStat=0 userStat=1 selectedUser=a if isKeyboardShowing() then hideKeyboard() showKeyboard() else showKeyboard() a="" end end end for e,f in pairs(passTab) do if CurrentTouch.x > f.x-f.z/2 and CurrentTouch.x < f.x+f.z/2 and CurrentTouch.y > f.y-f.w/2 and CurrentTouch.y < f.y+f.w/2 then userStat= 0 passStat= 1 selectedPass=e if isKeyboardShowing() then hideKeyboard() showKeyboard() else showKeyboard() end e="" end end end function loginScreen:keyboard(key) if key == RETURN then print(strUserTab[selectedUser]) print(strPassTab[selectedPass]) selectedUser=0 selectedPass=0 hideKeyboard() end -- Our callback function function getShowData( data, status, headers ) print( status..' : '..data ) end -- Our failure function function notGetShowData( error ) print( "Failed to get data. Error:" ) print( error ) end end

Comments

  • dave1707dave1707 Mod
    edited June 2015 Posts: 8,182

    You're missing an end statement for the function loginScreen:keyboard(key) . The getShowData and notGetShowData are included in loginScreen:keyboard by mistake.
    EDIT: You'll also have to remove the last end statement.

Sign In or Register to comment.