Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - LUAnoob

Pages: [1]
1
Lua / Error: Attempt to index local 'gc' (a nil value)
« on: January 31, 2012, 11:30:42 am »
Hey guys,

i got the problem, that i wanna made a game for me and my classmates, in which you can get money and fame :D

That's my source yet:


Spoiler For Spoiler:
Code: [Select]
money=0
energy=100
fame=0


function on.paint(gc)



gc:setFont("sansserif","b",15)
gc:drawString("Pennergame",0,0,"top")
gc:setFont("sansserif","b",12)
gc:drawString("1.Arbeiten (Bringt Geld)",0,80,"top")
gc:drawString("2.Ausruhen (Bringt Energie)",0,100,"top")
gc:drawString("3.Sachen kaufen (Bringt Fame)",0,120,"top")
gc:setFont("sansserif","r",6)
gc:drawString("Money: "..tostring(money),250,0,"top")
gc:drawString("Energie: "..tostring(energy),250,10,"top")
gc:drawString("Fame: "..tostring(fame),250,20,"top")
gc:setFont("sansserif","b",8)
gc:drawString("(C)Tim Krase",0,200,"top")




end

function on.charIn(ch)
if ch=="1" then
drawArbeiten(gc)
elseif ch==2 then
elseif ch==3 then


end
end

function drawArbeiten(gc)

gc:setFont("sansserif","b",15)
gc:drawString("1.Pflaschensammeln - 10",0,80,"top")

end

function arbeiteneingabe(ch)
if ch==1 then
money = money + 10
fame = fame - 5
end
end

And that's the error:

line 41: attempt to index local 'gc'(a nil value)

Line 41 is the line which "gc:setFont("sansserif","b",15)" includes.

Greetz,

LUAnoob


Pages: [1]