Hi,
you have a number of syntax errors:
hReg, rc = mc.mcIoGetHandle(inst, OSIG_OUTPUT0);
Should be:
hReg,rc=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT0)
because OSIG_OUTPUT0 is a signal not an IO and mc.OSIG_OUTPUT0 correctly identifies the signal within Machs core.
BoolPointValue = mc.mcIoGetState(hReg);
Should be:
BoolPointValue=mc.mcSignalGetState(hReg)
if (OSIG_OUTPUT0 == 0) then ---- SE è SPENTO
Should be:
if(BoolPointValue==0) then
Because OSIG_OUTPUT0 is only a human readable representation of a signal, its true identity during this instance of Mach is hReg and you have enquired
and got its state and copied it to a variable BoolPointValue.
One other point is that Machs Lua interpreter always reduces uppercase function names to lowercase and strips out leading zeros and spaces.
Thus your M101 is seen by Mach as m101.
M0101 would be seen as m101
M 101 would be seen as m101
In most cases Mach will correctly indentify and use the code you intended but it can go wrong sometimes. Do yourself a favour use lowercase without leading zeros or spaces,
you'll have fewer mistakes.
Look in Mach4Hobby/Docs for Mach4CoreAPI.chm and ScriptingManual.pdf, they will help a lot.
Craig