Jump to content




Making a Pretty Menu

help computer media

8 replies to this topic

#1 Eagle4Life69

  • Members
  • 13 posts

Posted 13 August 2012 - 10:07 PM

I would love help on creating a pretty menu system for my shopping mall, like an information kiosk.

I am new to Lua and Computer Craft only creating basic programs with basic 2 deep menus. Here is my issue I have a menu and it loads first set fine, then press option 1 it goes into it, but then any button sends it to main menu.

Please help here is my code I have now let me know how to do it better and correctly.

Thanks
bOut = 0
function Main_Menu()
while true do
  term.clear()
  term.setCursorPos(1,1)
  --clearscreen()
  print ( [[
   +********************************+
   |								|
   |	   Information  Kiosk	   |
   |								|
   +--------------------------------+
   |		 Please Choose		  |
   |  1. Store Directory			|
   |  2. How to Buy				 |
   |  3. How to Sell				|
   +********************************+
  ]] )
  os.pullEvent = os.pullEventRaw
  e, p = os.pullEvent()
  if e == "char" then
   if p == "1" then
	Store_Directory()
   elseif p == "2" then
  
   elseif p == "3" then
  
   else
  
   end
  end
end
end
function Store_Directory()
term.clear()
term.setCursorPos(1,1)
print ( [[
  +********************************+
  |								|
  |		Store  Directory		|
  |								|
  +--------------------------------+
  |  A. Fire Items				 |
  |  B.							|
  |  C.							|
  | press 0 to return to main menu |
  +********************************+
]] )
os.pullEvent = os.pullEventRaw
e, p = os.pullEvent()
  if e == "char" then
   if p == "a" then
	term.clear()
	term.setCursorPos(1,1)
	print ( [[
	 +********************************+
	 |								|
	 |		 Fire  Items		  |
	 |								|
	 +--------------------------------+
	 |	You can find Fire Items	 |
	 |		   in store #		   |
	 |			   21			   |
	 |	 Upper level  left side	 |
	 +********************************+
	]] )
	sleep(5)
	Main_Menu()
   elseif p == "b" then
	
   elseif p == "c" then
	
   elseif p == "0" then
	Main_Menu()
   else
	
   end
  end
end
Main_Menu()


#2 cant_delete_account

  • Members
  • 484 posts

Posted 13 August 2012 - 10:13 PM

Check this out:
A quick guide through menu making

#3 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 14 August 2012 - 02:18 AM

You don't need an else
You don't want a "os.pullEvent = os.pullEventRaw" everywhere with the loops
I think the reason you go back is that it ends the loop (due to else) then goes to bottom of code where it resumes Main_Menu()

#4 Eagle4Life69

  • Members
  • 13 posts

Posted 14 August 2012 - 02:23 AM

ok... Is there a way to tell if someone has walked away from the computer and have it reset the menu to the beginning?

#5 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 14 August 2012 - 02:25 AM

No real way to do that
You could make a timer.. If they choose the menu they have a timeout to choose, if they don't choose in time then it'll reset.

#6 Eagle4Life69

  • Members
  • 13 posts

Posted 14 August 2012 - 02:32 AM

ok how to add timer?
would I use os.startTimer

#7 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 14 August 2012 - 02:35 AM

Yes then it throws an event when it timesout.
http://computercraft...le=Os.pullEvent
Scroll to bottom for list of events.

#8 Eagle4Life69

  • Members
  • 13 posts

Posted 14 August 2012 - 02:42 AM

Perfect thanks so much

#9 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 15 August 2012 - 01:26 PM

detect them pressing the escape button to leave





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users