Posted 23 January 2013 - 08:00 PM
I've been trying to make a menu for a quarry program I'm making but it it's telling me a variable on line 61 is nil.
"onKeyPressed("key", quarryMenu )" is line 61
here's the code so far.
"onKeyPressed("key", quarryMenu )" is line 61
here's the code so far.
local termWidth, termHeight = term.getSize()
local selectedOption = 1
function basicQuarry()
local quarryType = basic
end
function oreQuarry()
local quarryType = ore
end
function goldQuarry()
local quarrytype = gold
end
function diamondQuarry()
local quarrytype = diamond
end
quarryMenu = {
[1] = { text = "Basic Quarry [Your standard Quarry!]", handler = basicQuarry },
[2] = { text = "Ore Quarry [Gathers all Ore!]", handler = oreQuarry },
[3] = { text = "Gold Quarry [Gathers valuable Ores!]", handler = goldQuarry },
[4] = { text = "Diamond Quarry [Focuses on Diamonds/Redstone!]", handler = diamondQuarry }
}
function printMenu( menu )
for i=1, #menu do
if i == selectedOption then
print(">"..menu[i].text)
else
print(" "..menu[i].text)
end
end
end
function onkeyPressed( key, menu )
if key == keys.enter then
onOptionSelected(menu)
elseif key == keys.up then
if selectedOption > 1 then
selectedOption = selectedOption - 1
end
elseif key == keys.down then
if selectedOption < #menu then
selectedOption = selectedOption + 1
end
end
end
function onOptionSelected( menu )
menu[selectedOption].handler()
end
while true do
term.clear()
term.setCursorPos(1,1)
printMenu(quarryMenu)
key = os.pullEvent("key")
onKeyPressed("key", quarryMenu )
end