Posted 14 October 2014 - 08:53 PM
I'm trying to make a typing program that will take user input and place it into a table for later use. Everything works fine until I press backspace. I have the backspace placed into the function to remove the last item placed into the table, but I get the error [string "test"]:20: table index is nil.
function draw(dx1,dy1,dx2,dy2,dcol)
for a=dx1,dx2 do
for b=dy1,dy2 do
term.setCursorPos(a,B)/>/>
term.setBackgroundColor(dcol)
term.write(" ")
end
end
end
repeat
input={}
inputnum=0
event={os.pullEvent()}
if event[1]=='char' then
term.write(event[2])
table.insert(input,event[2])
inputnum=inputnum+1
elseif event[1]=='key' and event[2]==14 then
input[i]=nil
inputnum=inputnum-1
ix=inputnum+17
draw(ix,12,ix,12,colors.white)
end
until event[1]=='key' and event[2]==28