Hi,
Bill_O is right, you really must learn the basics of Lua, when you do you'll realise just how powerful it is and therefore how powerful Mach4 is.
There are several areas which form the learning curve.
The first tip is to use various scripts and macros that are shipped with Mach4....they are examples of how things work. Often its a matter of selecting
one or more chunks of code and combining and editing them to meet your own particular need.
First there is Lua itself....and that is best researched and understood with this:
https://www.lua.org/manual/5.3/Take particular attention of the 'scope' of a function or variable, the principle of a 'function as a first class value', and the structure and use of
tables in Lua. Lua has ONLY one data structure, the table, and despite its apparent simplicity it can be extended to do things that are difficult
to do in much more powerful languages like C. A perfect example of this is the text functions of Lua. Most computer languages use some
variant of POSIX compliant text functions, whereas Lua has an apparently small set of such functions. Despite that you can combine what Lua functions
there are to achieve anything a POSIX compliant text function set can do, but instead of being 5Mbyte of code Lua's code is less than 500kByte.
'Function as a First Class variable' is another critically important concept, and is very cleverly used in Mach4. In addition it allows you to make a state
variable function, which is bloody hard to do in many other supposedly better languages.
The next area that might at first seem strange is Machs API, the full listing is in Mach4Hobby/Docs/MachCore4API.chm. Using the APIs contained therein you can
do almost anything in Mach. The APIs are each the means that a user can direct Machs core to do certain things......no SDK or other BS, just one complete
API. Note that all APIs have at least one output called 'rc' or return code, and that will signal the success or otherwise of the function (API) call.
It's tedious to test each and every rc but MAN does it help track down code bugs!
As an example take this API:
LUA Syntax:
value, rc = mc.mcCntlGetValue(
number mInst,
number valId,
number param)
Description:
Get the value of a core variable.
Note that the function has two outputs, 'value' and 'rc'. If you follow the Lua reference manual you'll see that multiple outputs of a function come
about because the function itself is a table. Notice also that the syntax of ALL APIs is prepended by a 'mc.', so ALL Machs APIs, ENUMS and more
are ALL entries in a mega table called 'mc'. Very clever indeed.
There are other namespaces like 'scr.' meaning screen, which is another table of function related to the screen GUI. Its not one I use a great deal,
there are usually superior mc. APIs that achieve the same goal.
There is one namespace or table that you will over time have to come to terms with and thats the 'wx.' table, short for wxWidgets. Its responsible for
all the screen text boxes, file dialogs and so on. I personally find wxWidgets to be difficult to follow. The reference manual is here:
https://www.wxwidgets.org/docs/Its written by geeks, for geeks and written in geekese, despite being complete and accurate! I have found this is where I use built-in Mach scripts
to learn and understand wxWidgets. Another good tool is wxFormBuilder, its a software suite that allows you to generate good wxWidget code and
if you invest the hours you will come to appreciate its power and flexibility.
I thank you for your advice, unfortunately I am not able, I work metal, I am not a programmer.
You may not think of yourself as a programmer....that's why Lua was chosen as a scripting language....so that metal workers, and hey, metal workers
are skillful even if they don't believe in their own abilities as programmers, can customise their machine to do anything they want. If you choose NOT to learn
the rudiments of Lua, Machs API and structure you'll severely limit what Mach4 can do for you.
Craig