@@ -2104,7 +2104,7 @@ on revTutorialSetText pStep
21042104 revTutorialConfigureMessage sSteps [pStep ]
21052105end revTutorialSetText
21062106
2107- on revTutorialConfigureMessage pData
2107+ on revTutorialConfigureMessage pData, pTopLeft
21082108 local tWidthOverride
21092109 put kMessageWidth into tWidthOverride
21102110 set the width of field "Message" of stack "revTutorial" to kMessageWidth
@@ -2159,7 +2159,7 @@ on revTutorialConfigureMessage pData
21592159 end if
21602160 end if
21612161
2162- revTutorialPositionStack "" , "" , tWidthOverride , false
2162+ revTutorialPositionStackForHighlight pTopLeft , tWidthOverride
21632163end revTutorialConfigureMessage
21642164
21652165function revTutorialScriptRetry pCurrent
@@ -2413,21 +2413,26 @@ function revTutorialCheckWaitCondition pActionData
24132413 end if
24142414 break
24152415 case "scripted"
2416- # If the script hasn't changed then don't do anything.
2417- if revTutorialScriptIs(the script of tObject , sWait ["current script" ]) then
2416+ # This code path is triggered by any propertyChanged message,
2417+ # so if the script hasn't changed then don't do anything.
2418+ local tScript
2419+ put the script of tObject into tScript
2420+ if tScript is sWait ["current script" ] then
24182421 break
24192422 end if
2420- if revTutorialObjectPropertyIsValue(tObject , "script" , pActionData ["script" ], false ) then
2423+ local tMistake
2424+ revTutorialCompareScript tScript , pActionData ["script" ]
2425+ put the result into tMistake
2426+ if tMistake is empty then
24212427 return true
2422- else if sWait ["current script" ] is not empty then
2423- add 1 to sWait ["incorrect attempts" ]
2424- put the script of tObject into sWait ["current script" ]
2425- # Show the current script and the target script in the tip stack
2426- local tData
2427- put revTutorialScriptRetry(sWait ["current script" ]) into tData ["text" ]
2428- put pActionData ["script" ] into tData ["script" ]
2429- revTutorialConfigureMessage tData
24302428 end if
2429+ put tScript into sWait ["current script" ]
2430+ add 1 to sWait ["incorrect attempts" ]
2431+ # Show the current script and the target script in the tip stack
2432+ local tData
2433+ put revTutorialScriptRetry(tMistake ) into tData ["text" ]
2434+ put pActionData ["script" ] into tData ["script" ]
2435+ revTutorialConfigureMessage tData , revTutorialGetEffectiveTopLeft()
24312436 break
24322437 end switch
24332438 break
@@ -3311,32 +3316,32 @@ function revTutorialObjectIsHighlighted pObject
33113316 return false
33123317end revTutorialObjectIsHighlighted
33133318
3314- on revTutorialPositionStackForHighlight pTopLeft
3319+ on revTutorialPositionStackForHighlight pTopLeft, pWidthOverride
33153320 lock screen
33163321 switch sHighlight ["type" ]
33173322 case "guide"
3318- revTutorialPositionStack "" , sGuides [sHighlight ["guide" ]], "" , "" , pTopLeft
3323+ revTutorialPositionStack "" , sGuides [sHighlight ["guide" ]], pWidthOverride , "" , pTopLeft
33193324 break
33203325 case "property"
3321- revTutorialPositionStack "inspector" , sHighlight , "" , "" , pTopLeft
3326+ revTutorialPositionStack "inspector" , sHighlight , pWidthOverride , "" , pTopLeft
33223327 break
33233328 case "menu"
3324- revTutorialPositionStack "menubar" , sHighlight ["menu" ], "" , "" , pTopLeft
3329+ revTutorialPositionStack "menubar" , sHighlight ["menu" ], pWidthOverride , "" , pTopLeft
33253330 break
33263331 case "toolbar"
3327- revTutorialPositionStack "menubar" , sHighlight ["item" ], "" , "" , pTopLeft
3332+ revTutorialPositionStack "menubar" , sHighlight ["item" ], pWidthOverride , "" , pTopLeft
33283333 break
33293334 case "tool"
3330- revTutorialPositionStack "tools" , sHighlight ["tool" ], "" , "" , pTopLeft
3335+ revTutorialPositionStack "tools" , sHighlight ["tool" ], pWidthOverride , "" , pTopLeft
33313336 break
33323337 case "object"
3333- revTutorialPositionStack sHighlight ["stack" ], sHighlight ["object" ], "" , sHighlight ["line" ] is not empty , pTopLeft
3338+ revTutorialPositionStack sHighlight ["stack" ], sHighlight ["object" ], pWidthOverride , sHighlight ["line" ] is not empty , pTopLeft
33343339 break
33353340 case "stack"
3336- revTutorialPositionStack sHighlight ["stack" ], "" , "" , "" , pTopLeft
3341+ revTutorialPositionStack sHighlight ["stack" ], "" , pWidthOverride , "" , pTopLeft
33373342 break
33383343 default
3339- revTutorialPositionStack "" , "" , "" , "" , pTopLeft
3344+ revTutorialPositionStack "" , "" , pWidthOverride , "" , pTopLeft
33403345 break
33413346 end switch
33423347 unlock screen
@@ -3476,7 +3481,8 @@ function revTutorialObjectPropertyIsValue pObjectIDs, pProperty, pValue, pIsNot
34763481 return false
34773482 end if
34783483 else if pProperty is "script" then
3479- if revTutorialScriptIs(the script of tObject , pValue ) is pIsNot then
3484+ revTutorialCompareScript the script of tObject , pValue
3485+ if (the result is empty ) is pIsNot then
34803486 return false
34813487 end if
34823488 else if pProperty is "name" then
@@ -3537,19 +3543,61 @@ on revTutorialSnapObjectToGuide pObject, pGuide
35373543 unlock screen
35383544end revTutorialSnapObjectToGuide
35393545
3546+ private function revTutorialGetMistake pObjScript, pTokenNum, pReadToken, pTargetToken
3547+ lock messages
3548+ local tDefaultStack
3549+ put the defaultStack into tDefaultStack
3550+ set the defaultStack to "revTutorial"
3551+ create invisible field "script_tester"
3552+ put pObjScript into field "script_tester"
3553+
3554+ local tCharIndex , tLineIndex , tLineChars
3555+ put the lineIndex of token pTokenNum of field "script_tester" into tLineIndex
3556+ put the charIndex of token pTokenNum of field "script_tester" into tCharIndex
3557+ put the number of chars in line 0 to tLineIndex - 1 \
3558+ of field "script_tester" into tLineChars
3559+ subtract tLineChars from tCharIndex
3560+
3561+ local tMistake
3562+ if pTargetToken is not empty then
3563+ put merge (quote & "[[pReadToken]]" & quote && \
3564+ "instead of" && quote & "[[pTargetToken]]" & quote && \
3565+ "at char [[tCharIndex]] of line [[tLineIndex]]" ) into tMistake
3566+ else
3567+ put merge ("Unexpected additional script" && \
3568+ quote & "[[pReadToken]]" & quote && \
3569+ "at char [[tCharIndex]] of line [[tLineIndex]]" ) into tMistake
3570+ end if
3571+ delete field "script_tester"
3572+ set the defaultStack to tDefaultStack
3573+ unlock messages
3574+ return tMistake
3575+ end revTutorialGetMistake
3576+
35403577// In the future we might want to add a bit more "approximity" to this.
3541- function revTutorialScriptIs pObjScript, pTargetScript
3542- local tObjTokens , tTargetTokens
3543- repeat for each token tToken in pObjScript
3544- put tToken & " " after tObjTokens
3578+ command revTutorialCompareScript pObjScript, pTargetScript
3579+ local tTokenNum , tMistake , tToken
3580+ repeat for each token tTargetToken in pTargetScript
3581+ add 1 to tTokenNum
3582+ put token tTokenNum of pObjScript into tToken
3583+ if tTargetToken is not tToken then
3584+ put revTutorialGetMistake(pObjScript , tTokenNum , tToken , tTargetToken ) \
3585+ into tMistake
3586+ exit repeat
3587+ end if
35453588 end repeat
35463589
3547- repeat for each token tToken in pTargetScript
3548- put tToken & " " after tTargetTokens
3549- end repeat
3590+ if tMistake is empty then
3591+ add 1 to tTokenNum
3592+ put token tTokenNum of pObjScript into tToken
3593+ if tToken is not empty then
3594+ put revTutorialGetMistake(pObjScript , tTokenNum , tToken , empty ) \
3595+ into tMistake
3596+ end if
3597+ end if
35503598
3551- return tObjTokens is tTargetTokens
3552- end revTutorialScriptIs
3599+ return tMistake
3600+ end revTutorialCompareScript
35533601
35543602constant kColorTolerance = 10
35553603function revTutorialColorIs pColor, pTarget
0 commit comments