current face = (1-1) mod 4 = 0div4 = 0, ok good so far
target face = (3-1) mod 4 = 2div4= 0, remainder of 0.5 = 1? (partial remainder?), answer should be 2 though, correct?
Close but no cigar.
The mod(ulus) is the remainder after division
forget fractional numbers for the moment because we're not using them.
if both operands are integers then the division and result are integer also. so....
current face = (1-1) mod 4 = 0/4 = 0 with 0 remainder
target face = (3-1) mod 4 = 2/4 = 0 with 2 remainder
mod is the classic mechanism for handling rollovers.
copy and paste this code exactly as is into your M6Start.m1s and do a few toolchanges and get back
selectedTool = getSelectedTool()
currentTool = getCurrentTool()
currentFace = (currentTool - 1) Mod 4
targetFace = (selectedTool - 1) Mod 4
clicks = (targetFace - currentFace + 4) Mod 4
MsgBox "Selected Tool=" & selectedTool & _
" Current Tool=" & currentTool & _
" Current Face=" & currentFace & _
" Target Face=" & targetFace & _
" Clicks=" & clicks
SetCurrentTool selectedTool