Posted 08 August 2012 - 01:56 AM
I was following some directions from Here, and I received an error.
I just tried to use the code for the multiple options, and got an error: test:3: attempt to get length of nil.
Here's how I used it:
I just tried to use the code for the multiple options, and got an error: test:3: attempt to get length of nil.
Here's how I used it:
function opt(m) --renamed just for sake of ease on my part.
n=1
l=#m
while true do
term.clear()
term.setCursorPos(1,2)
for i=1, l, 1 do
if i==n then print(i, " ["..m[i].."]") else print(i, " ", m[i]) end
end
print("Select a number[arrow up/arrow down]")
a, b= os.pullEventRaw()
if a == "key" then
if b==200 and n>1 then n=n-1 end
if b==208 and n<=l then n=n+1 end
if b==28 then break end
end
end
term.clear() term.setCursorPos(1,1)
return n
end
I also used the table like this:
local options={
"Redstone/Red alloy wire",
"White",
"Orange",
"Magenta",
"Light Blue",
"Yellow",
"Lime",
"Pink",
"Gray",
"Light Gray",
"Cyan",
"Purple",
"Blue",
"Brown",
"Green",
"Red",
"Black"
}
Is there supposed to be something that goes in the () when calling it?