Jump to content




Help from the menu


7 replies to this topic

#1 Ka6a400kg

  • New Members
  • 5 posts
  • LocationUkraine

Posted 18 March 2012 - 11:14 AM

Hi all!
Help make a light menu for ComputerCraft please. :D/>

#2 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 18 March 2012 - 11:49 AM

See this for some help on making a menu http://www.computerc...ua-cc-menu-how/

#3 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 18 March 2012 - 12:03 PM

i think i am going to write a tutorial about it. there certainly is a need for it :D/>

#4 Ka6a400kg

  • New Members
  • 5 posts
  • LocationUkraine

Posted 18 March 2012 - 01:13 PM

You can write the menu at least 6-choice? :D/>
If you can please write. :)/>

#5 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 18 March 2012 - 01:20 PM

function CUI(m)
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
supply this code with a table (e.g. {"a","b"}) of options and it returns the number of the chosen one. I will feature it in a tutorial later on.

#6 Ka6a400kg

  • New Members
  • 5 posts
  • LocationUkraine

Posted 18 March 2012 - 01:30 PM

/

#7 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 18 March 2012 - 10:50 PM

To give you something simple to start with you can make a simple menu like using print and if elseif statements..

print ("1) Option 1")
print ("2) Option 2")
print ("3) Option 3")
print ("4) Option 4")
print ("5) Option 5")
print ("6) Option 6")
print()
write ("Enter your selection: ")
local input = read()
if read == 1 then
-- do option 1 stuffs
elseif read == 2 then
-- do option 2 stuffs
-- and so on..
else
print ("invalid option selected")
end


#8 Ka6a400kg

  • New Members
  • 5 posts
  • LocationUkraine

Posted 19 March 2012 - 01:35 PM

Menu created liraal better because you choose the arrow up / down. :D/>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users