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

Commit c2d9d94

Browse files
committed
[[ Tutorial ]] Add 'property ... is changed' condition
This patch enables a tutorial step to instruct that a property of an object be changed to some unspecified value different from its value at the start of the step. A default value must be specified so that the step is still skippable.
1 parent a38a01d commit c2d9d94

2 files changed

Lines changed: 34 additions & 13 deletions

File tree

Documentation/specs/tutorial-syntax.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ satisfied before continuing.
133133
| <Target: Object> "fits" "guide" <Guide: STRING> [ "with" "tolerance" <Tolerance: INTEGER> ]
134134
| "there" "is" ( "a" | "an" ) <Target: Palette>
135135
| "there" "is" ( "a" | "an" ) <Target: ObjPalette> "for" <TargetObject: Object>
136-
| <Target: Object> “is” (“clicked” | “selected” | “scripted” | “focused” | "grouped")
137-
| “the” “tool” “is” (“edit” | “run” | “graphic”)
138-
| “the” <Property: PROPERTY> “of” <Target: Object> “is” <Value: STRING>
139-
| <Target: Object> “pops” “up” “answer” “dialog”
140-
| "this" "card" "is" <Card: STRING>
136+
| <Target: Object> "is" ("clicked" | "selected" | "scripted" | "focused" | "grouped")
137+
| "the" "tool" "is" ("edit" | "run" | "graphic")
138+
| "the" <Property: PROPERTY> "of" <Target: Object> "is" <Value: STRING>
139+
| "the" <Property: PROPERTY> "of" <Target: Object> "is" "changed" "with" "default" <Value: STRING>
140+
| <Target: Object> "pops" "up" "answer" "dialog"
141+
| "this" "card" "is" <Card: STRING>

Toolset/palettes/tutorial/revtutorial.livecodescript

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,26 @@ on revTutorialParseWait pTokens, @rData
674674
return empty
675675
end if
676676

677+
revTutorialParseSubexpression "the <token> of <object> is changed with default <token>", pTokens, tToken, tCondition
678+
679+
if the result is empty then
680+
put "property" into rData["wait condition"]
681+
put tCondition[1] into rData["property"]
682+
put tCondition[2] into rData["object"]
683+
put tCondition[3] into rData["default"]
684+
put true into rData["is not"]
685+
return empty
686+
end if
687+
677688
revTutorialParseSubexpression "the <token> of <object> is <value>", pTokens, tToken, tCondition
678689

679690
if the result is empty then
680691
put "property" into rData["wait condition"]
681692
put tCondition[1] into rData["property"]
682693
put tCondition[2] into rData["object"]
683694
put tCondition[3] into rData["value"]
695+
put false into rData["is not"]
696+
return empty
684697
end if
685698

686699
return the result
@@ -2049,7 +2062,7 @@ function revTutorialCheckWaitCondition pActionData
20492062
put pActionData["value"] into tValue
20502063
end if
20512064

2052-
if revTutorialObjectPropertyIsValue(tObject, pActionData["property"], tValue) then
2065+
if revTutorialObjectPropertyIsValue(tObject, pActionData["property"], tValue, pActionData["is not"]) then
20532066
return true
20542067
end if
20552068
break
@@ -2163,6 +2176,9 @@ end revTutorialWaitUntilTheToolIs
21632176
on revTutorialWaitUntilObjectPropertyHasValue pTaggedObject
21642177
local tObjID
21652178
put revTutorialResolveObjectToLongID(pTaggedObject) into tObjID
2179+
if sWait["is not"] then
2180+
put the sWait["property"] of tObjID into sWait["value"]
2181+
end if
21662182
revIDESubscribe "idePropertyChanged", tObjID
21672183
end revTutorialWaitUntilObjectPropertyHasValue
21682184

@@ -3031,22 +3047,22 @@ function revTutorialThereIsAPalette pPalette
30313047
return false
30323048
end revTutorialThereIsAPalette
30333049

3034-
function revTutorialObjectPropertyIsValue pObjectIDs, pProperty, pValue
3050+
function revTutorialObjectPropertyIsValue pObjectIDs, pProperty, pValue, pIsNot
30353051
repeat for each line tObject in pObjectIDs
30363052
if pProperty ends with "color" then
3037-
if revTutorialColorIs(the pProperty of tObject, pValue) is false then
3053+
if revTutorialColorIs(the pProperty of tObject, pValue) is pIsNot then
30383054
return false
30393055
end if
30403056
else if pProperty is "script" then
3041-
if revTutorialScriptIs(the script of tObject, pValue) is false then
3057+
if revTutorialScriptIs(the script of tObject, pValue) is pIsNot then
30423058
return false
30433059
end if
30443060
else if pProperty is "name" then
3045-
if the short name of tObject is not pValue then
3061+
if (the short name of tObject is pValue) is pIsNot then
30463062
return false
30473063
end if
30483064
else
3049-
if the pProperty of tObject is not pValue then
3065+
if (the pProperty of tObject is pValue) is pIsNot then
30503066
return false
30513067
end if
30523068
end if
@@ -3228,7 +3244,7 @@ on revTutorialRunAction pActionData
32283244
break
32293245
case "property"
32303246
# Set the property of the objects
3231-
revTutorialSetPropertyOfObjects revTutorialResolveObjectToLongID(tWaitData["object"]), tWaitData["property"], tWaitData["value"]
3247+
revTutorialSetPropertyOfObjects revTutorialResolveObjectToLongID(tWaitData["object"]), tWaitData["property"], tWaitData["value"], tWaitData["is not"], tWaitData["default"]
32323248
break
32333249
case "fits"
32343250
# Set the rect of the objects
@@ -3367,12 +3383,16 @@ on revTutorialCreateAndCaptureObjects pWaitData, pCaptureData, pHighlightData
33673383
end if
33683384
end revTutorialCreateAndCaptureObjects
33693385

3370-
on revTutorialSetPropertyOfObjects pObjects, pProp, pValue
3386+
on revTutorialSetPropertyOfObjects pObjects, pProp, pValue, pIsNot, pDefault
33713387
# If the step specified a value then we set this instead of the string "value"
33723388
if pValue is "value" and sStepContextA["value"] is not empty then
33733389
put sStepContextA["value"] into pValue
33743390
end if
33753391

3392+
if pIsNot then
3393+
put pDefault into pValue
3394+
end if
3395+
33763396
if the environment begins with "development" then
33773397
revIDESetPropertyOfObject pObjects, pProp, pValue
33783398
else

0 commit comments

Comments
 (0)