How about a combination of both?
Like you were saying, you can check the state (the alState parameter) that the lever without having to lock it in place by doing something similar to this:
void LeverFunction(parameters etcetc) //This is the function that is called when you pull the lever
{
if(alState == 1) //Experiment with "1" & "-1". I think 1 is up, and -1 is down.
{
//Code to do here if the lever is pulled to the aforementioned state
}
}
However, you don't want the machine to start if the repairs aren't complete! To solve this, we'll need some code in the lever function will check if everything is complete.
Do you remember how we set those local integers? "Coal" and "Cogs?" We can use them to see if the machine's repairs are finished:
void leverfunction blahblah //Lever callback, sorry for my shorthand =p
{
if(alState == 1) //This checks if the lever is pulled
{
//If it is pulled, checks if repairs are complete
if(GetLocalVarInt("Coal") == 3 && GetLocalVarInt("Cogs") == 3)
{
//This block is executed if everything is complete
//Run your machine startup routine here
}
else
{
//This block executes if something isn't finished
}
}
}
I hope it gives you a general idea. Adjust it to your liking!