Hi,
I have a little code that does things a little differently.
First I set up two toggle buttons, one ON/OFF and one FWD/REV. Note there is no need to put them in the signal library, they can be attached direct to an input signal,
I chose ISIG_INPUT10 and ISIG_INPUT11 respectively and these can in turn be assigned to a pin which is hooked to your external toggle switches.
There a four fragments of code, an 'up' script and a 'down' script for each button. I arbitrarily chose OSIG_OUTPUT4 for spindleON/spindleOFF and OSIG_OUTPUT5 for FWD/REV
ON/OFF up script:
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT4)
mc.mcSignalSetState(hsig,1)
ON/OFF down script:
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT4)
mc.mcSignalSetState(hsig,0)
FWD/REV up script:
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT5)
mc.mcSignalSetState(hsig,1)
FWD/REV down script:
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT5)
mc.mcSignalSetState(hsig,0)
Achieves the same result but uses the properties of the screen toggle button. Note if you want to be super code efficient you can attach an output directly to a toggle button so you don't even
have to write any scripts. I know.....where's the fun in that!
Craig