Jump to content

Optional help within the program itself

help lua

2 replies to this topic

#1 Aceofrogues

  • Members
  • 5 posts

Posted 18 June 2013 - 09: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.

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:

#2 CoderPuppy

  • Members
  • 121 posts

Posted 18 June 2013 - 11:21 AM

Just put this at the top:
if ({...})[1] == 'help' then
-- Print usage message here

EDIT: Made it just return the help

#3 Aceofrogues

  • Members
  • 5 posts

Posted 18 June 2013 - 11:35 AM

[EDIT] The new code is working beautifully. Thank you this will really help me going forward!

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users