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

Optional help within the program itself

Started by Aceofrogues, 18 June 2013 - 08:46 AM
Aceofrogues #1
Posted 18 June 2013 - 10:46 AM
Hello guys

I have a really terrible memory. So when i come back to my old programs, i simply can't remember the "bonuses" i have coded. Therefore i would like to include an optional help function. English isn't my primary language, so i will give a practical example, as i feel that will explain it better than i can.

Example:
I have a program that will dig a 3x3x3 hole. I use it to dig up quicksand. It has the option to fill the hole afterwards, so i am not leaving holes around the world. It automatically detects if the blocks needed are there, and if they are, it will use them.

A week from now i won't remember having the option. Therefore i would like option to for example type <Nameofprogram> help. In my case "Quicksand help". If help isn't typed it will run without giving the helpful text, or at least that's what i want it to do.

I have included the program used as an example, so it's there if needed.

Quicksand digging program:
http://pastebin.com/uV4CFydZ
CoderPuppy #2
Posted 18 June 2013 - 12:21 PM
Just put this at the top:

if ({...})[1] == 'help' then
-- Print usage message here
return
end

EDIT: Made it just return the help
Aceofrogues #3
Posted 18 June 2013 - 12:35 PM
[EDIT] The new code is working beautifully. Thank you this will really help me going forward!