This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
makerimages's profile picture

apis and disk menus

Started by makerimages, 13 August 2012 - 06:53 AM
makerimages #1
Posted 13 August 2012 - 08:53 AM
hi, i have a disk that has a api and startup in the main dir.

api looks like this

function inMenu(menu)
term.setCursorPos(1,1)
print("Would you like to Install makerOS?")
term.setCursorPos(1,9)
write("Selection: ")
end
function selection()
print("1. Yes")
print("2. No")
term.setCursorPos(11,9)
end

and startup looks like this:



term.clear(menu)
textutils.slowPrint("-----------",10)
term.clear()
print("Dear user, welcome to the installation process of makerOS!")
sleep(5)
print("You will now bw guided trough the installation process of your brand new makerOS release!")
sleep(5)
term.clear()
os.loadAPI("/disk/installmenu")
inMenu()
selection()
local input = read() 
if input == "1" then 
os.reboot()
elseif input == "2" then
print("Installation cancelled by user,rebooting")
os.reboot()
else
  print("Invalid selection, please try again")
  sleep(1)
  os.reboot() 
end

its supposed to display text and a menu but it gives me this errorafter showing the text: startup:10 attempt to call nil.

how do i get this working??
ardera #2
Posted 13 August 2012 - 10:02 AM
because the functions inMenu() and selection() aren't included in the _G table, they are included in the _G.installmenu table, so you have to use
installmenu.inMenu() and installmenu.selection()
makerimages #3
Posted 13 August 2012 - 10:09 AM
how stupid of me… that worked. thanks
ardera #4
Posted 13 August 2012 - 10:58 AM
np :P/>/>