Posted 07 January 2013 - 10:53 AM
Ok so when I click on my section for games is give me an error I have spent atleast 2 hours trying to resolve it here is the code for it.
Please Help!!!
–Functions–
local w,h = term.getSize()
local select = 1
———————————
local function printCentered(str, ypos)
term.setCursorPos(w/2 - #str/2, ypos)
term.write(str)
end
local function printRight(str, ypos)
term.setCursorPos(w - #str, ypos)
term.write(str)
end
function drawHeader()
printCentered("AJ's Computer", 1)
printCentered(string.rep("|^|",w), 2)
printRight("By AJ Drew", h)
end
—–Menu Games——
term.clear()
function drawGame()
function drawHeader()
printCentered("Worm", 8)
printCentered("Rpg", 12)
printCentered("Quit", 16)
local ypos = 9
if select == 2 then ypos = 13
elseif select == 3 then ypos = h-1 end
printCentered("<><><><><><>", ypos)
end
————menu2————
local menustate = "game"
local mopt = {
["game"] = {
options = {"rpg", "worm", "quit"}
}
}
——RunMenu2Function——–
function runGame()
while true do
term.clear()
function drawGame()
local id, key = os.pullEvent("key")
–Note– up=200 down=208 enter=28
if key == 200 and select > 1 then select = select-1
elseif key == 208 and select < #mopt[menustate].options then select = select+1
elseif key == 28 then
if mopt[menustate].options[select] == "quit" then shell.run("desktop")
menustate = mopt[menustate].options[select]
elseif mopt[menustate].options[select] == "worm" then term.clear() shell.run("worm")
menustate = mopt[menustate].options[select]
elseif mopt[menustate].options[select] == "rpg" then term.clear() shell.run("rpg")
menustate = mopt[menustate].options[select]
end
end
end
end
end
end
runGame()
Please Help!!!
–Functions–
local w,h = term.getSize()
local select = 1
———————————
local function printCentered(str, ypos)
term.setCursorPos(w/2 - #str/2, ypos)
term.write(str)
end
local function printRight(str, ypos)
term.setCursorPos(w - #str, ypos)
term.write(str)
end
function drawHeader()
printCentered("AJ's Computer", 1)
printCentered(string.rep("|^|",w), 2)
printRight("By AJ Drew", h)
end
—–Menu Games——
term.clear()
function drawGame()
function drawHeader()
printCentered("Worm", 8)
printCentered("Rpg", 12)
printCentered("Quit", 16)
local ypos = 9
if select == 2 then ypos = 13
elseif select == 3 then ypos = h-1 end
printCentered("<><><><><><>", ypos)
end
————menu2————
local menustate = "game"
local mopt = {
["game"] = {
options = {"rpg", "worm", "quit"}
}
}
——RunMenu2Function——–
function runGame()
while true do
term.clear()
function drawGame()
local id, key = os.pullEvent("key")
–Note– up=200 down=208 enter=28
if key == 200 and select > 1 then select = select-1
elseif key == 208 and select < #mopt[menustate].options then select = select+1
elseif key == 28 then
if mopt[menustate].options[select] == "quit" then shell.run("desktop")
menustate = mopt[menustate].options[select]
elseif mopt[menustate].options[select] == "worm" then term.clear() shell.run("worm")
menustate = mopt[menustate].options[select]
elseif mopt[menustate].options[select] == "rpg" then term.clear() shell.run("rpg")
menustate = mopt[menustate].options[select]
end
end
end
end
end
end
runGame()