Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 9f0be30

Browse files
committed
[[ Bug 20046 ]] Add automatic 'apply' step for correct script
This patch uses the new ideScriptEdited message to detect when a script has been correct for a short while and if so, adds an automatic 'Click apply button' step with the apply button highlighted. If the script is further modified, the original step instruction is shown.
1 parent 821c753 commit 9f0be30

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

Toolset/palettes/tutorial/revtutorial.livecodescript

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,8 @@ on revTutorialDoLoad pLesson
21002100
revTutorialRunTutorial tTutorialInfo["course"], tTutorialInfo["tutorial"], pLesson, tTutorialInfo["location"]
21012101
end revTutorialDoLoad
21022102

2103-
on revTutorialSetText pStep
2104-
revTutorialConfigureMessage sSteps[pStep]
2103+
on revTutorialSetText pStep, pTopLeft
2104+
revTutorialConfigureMessage sSteps[pStep], pTopLeft
21052105
end revTutorialSetText
21062106

21072107
on revTutorialConfigureMessage pData, pTopLeft
@@ -2454,6 +2454,7 @@ on revTutorialWaitUntilObjectIsScripted pTaggedObject
24542454
revTutorialSetSEPreference "explicitVariables", false
24552455

24562456
revIDESubscribe "idePropertyChanged", tObjID
2457+
revIDESubscribe "ideScriptEdited"
24572458
end revTutorialWaitUntilObjectIsScripted
24582459

24592460
on revTutorialWaitUntilObjectIsClicked
@@ -3029,6 +3030,52 @@ on idePropertyChanged pObject
30293030
end if
30303031
end idePropertyChanged
30313032

3033+
local sScriptCheck
3034+
on revTutorialCheckScript pScript, pObject
3035+
if revTutorialObjectIsTaggedObject(pObject, sWait["object"]) then
3036+
if sWait["wait condition"] is "state" and \
3037+
sWait["state"] is "scripted" then
3038+
revTutorialCompareScript pScript, sWait["script"]
3039+
lock screen
3040+
if the result is empty and sWait["correct script"] is not true then
3041+
-- If the currently typed script is correct, then
3042+
-- remind about clicking Apply
3043+
-- Remember the chosen location
3044+
put revTutorialGetEffectiveTopLeft() into sScriptCheck["topleft"]
3045+
put true into sScriptCheck["correct script"]
3046+
put "Apply" into sHighlight["object"]
3047+
put "object" into sHighlight["type"]
3048+
local tData
3049+
put "Click 'Apply' to apply the script" into tData["text"]
3050+
revTutorialConfigureMessage tData
3051+
else if sScriptCheck["correct script"] is true then
3052+
-- Otherwise, the script has been changed from the correct one
3053+
put false into sScriptCheck["correct script"]
3054+
-- Reset the highlight
3055+
put "stack" into sHighlight["type"]
3056+
-- Reset the text
3057+
revTutorialSetText sStepName, sScriptCheck["topleft"]
3058+
end if
3059+
unlock screen
3060+
end if
3061+
end if
3062+
end revTutorialCheckScript
3063+
3064+
local sCheckScriptMsg
3065+
constant kCheckBufferMS = 800
3066+
on ideScriptEdited pScript, pObject
3067+
-- In order to mitigate against forgetting to press the
3068+
-- apply button, we subscribe to ideScriptEdited and check
3069+
-- to see if the script entered is correct. However, we
3070+
-- don't want to interrupt the flow of typing, so add a
3071+
-- buffer
3072+
if sCheckScriptMsg is not empty then
3073+
cancel sCheckScriptMsg
3074+
end if
3075+
send "revTutorialCheckScript pScript, pObject" to me in kCheckBufferMS millisecs
3076+
put the result into sCheckScriptMsg
3077+
end ideScriptEdited
3078+
30323079
on ideStackMoved pStack
30333080
local tStack
30343081
put revIDEStackOfObject(pStack) into tStack

notes/bugfix-20046.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Ensure there are separate scripting / apply steps in tutorial

0 commit comments

Comments
 (0)