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

Menu with options

Started by vinvis, 04 May 2012 - 06:41 PM
vinvis #1
Posted 04 May 2012 - 08:41 PM
Hi guys,

I recently installed computercraft along with some other mods, and I am fascinated by the countless possibilities and such that can be reached within this mod. I wanted to program this computer on my server as an administrative one: a menu, with three or four options in the center, and when clicked, each of these runs a program: deploy starterkit from hatch, access to player register, etc.
I tried and searched really hard, and I found various menu tutorials, but I never reached my goal. The problems were:
1: I couldn't get an option to run a program (noob as I am)
2: I couldn't get the options in the center with a nice little ASCII border around it
3: since it was going to be administrative, one or two options should lead to a program with editable text, with maybe a fixed, preset chart.

I experimented with a lot of code found on the internet, but I did not manage to do all this.
I do not want to wake the presumption that I am being lazy: I looked in various places, but I just couldn't get it to work
What would of course really help me out is for someone to code it all for me and hand me the startup.lua file…
but if that is too much work, please help me out by providing an example with 4 options, each of them which runs a program.
If that is too much, then do what you want, but the risk of me not understanding anything will be high!
It would be clear to me if you said exactly what I could replace by my own names and programs in the script, and maybe where I can place text for it to be visible for example above the options.(in short, What where how to replace with my own stuff(programs, names))


so it would look like this:
---------------------------------------
		Main  Terminal
	please select an option:
	  [ADMINISTRATION]
			 [STARTERKIT]
			   [PROJECTS]
				  [SERVER]
--------------------------------------------
select-able with up/ down, etc.
and each leading to its own program
and it would run at the start up

also,(side subject) how would one make a preset, fixed chart with ASCII, where one can fill in player names for example? is that possible?
and if I would like to split Administration into two more options, how would one do that?

Thank you for reading this, and thank you even more if you're going to help me out!
I do not expect anyone to help me, but it would be greatly appreciated.
also, you do not have to answer all of my questions.
Take this in Mind!

Regards
Vinvis
OmegaVest #2
Posted 04 May 2012 - 09:33 PM
So, first section.
1: shell.run("program", "args1", "arg2", etc)
2: x, y = term.getSize(). Get the length of the string with a # at its front then subtract half string length from half x.
3: You'll want to look at os.pullEvent(), specifically the "key" and "char" events, along with read()

For the side subject, use the above term.getSize(), but situate a start point and make all names have a set maximum size, then use | 's.

Also, probably the easiest way to make certain options only accessible to admins is so make a 3-dimensional table. That is a bit complicated, and I don't presently have time to walk through it, but there should be a Lua tutorial if you search google for it.
Luanub #3
Posted 04 May 2012 - 10:01 PM
There is a really good tutorial on menu making I suggest taking a look at it http://www.computercraft.info/forums2/index.php?/topic/744-a-quick-guide-through-menu-making/
vinvis #4
Posted 05 May 2012 - 07:07 AM
There is a really good tutorial on menu making I suggest taking a look at it http://www.computercraft.info/forums2/index.php?/topic/744-a-quick-guide-through-menu-making/
ah, yes, I found that one as wel|. But how do I run a program from an option, and where would I need to paste such content in the code?
vinvis #5
Posted 05 May 2012 - 07:10 AM
So, first section.
1: shell.run("program", "args1", "arg2", etc)
2: x, y = term.getSize(). Get the length of the string with a # at its front then subtract half string length from half x.
3: You'll want to look at os.pullEvent(), specifically the "key" and "char" events, along with read()

For the side subject, use the above term.getSize(), but situate a start point and make all names have a set maximum size, then use | 's.

Also, probably the easiest way to make certain options only accessible to admins is so make a 3-dimensional table. That is a bit complicated, and I don't presently have time to walk through it, but there should be a Lua tutorial if you search google for it.
Thanks! I'll try to figure it out, and I'll Paste the code here when finished