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

Commit 9e563d4

Browse files
Merge pull request #1673 from livecode/feature-tutorial_load_resource_stack
[[ InteractiveTutorial ]] Add load stack from resources
2 parents 6dc2ad4 + 77af96c commit 9e563d4

4 files changed

Lines changed: 61 additions & 8 deletions

File tree

Documentation/specs/tutorial-syntax.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ The possible actions are as follows:
6363
| "go" "to" "step" <Name: STRING>
6464
| "add" "guide" <Name: STRING> "with" "rect" <Rect: RECT> "to" <Target: Object>
6565
| “interlude”
66+
| "load" ("lesson" | "stack") <Source: STRING>
6667

6768
The highlight action causes the tutorial stack to point at the relevant
6869
object on the screen. If there is no highlight action, the tutorial stack
@@ -139,3 +140,13 @@ satisfied before continuing.
139140
| "the" <Property: PROPERTY> "of" <Target: Object> "is" "changed" "with" "default" <Value: STRING>
140141
| <Target: Object> "pops" "up" "answer" "dialog"
141142
| "this" "card" "is" <Card: STRING>
143+
144+
The load action causes tutorial state to be loaded. If the "lesson" Source
145+
is used, the tutorial runner will find the lesson with name Source in the
146+
same lessons folder as the current tutorial, and run it to completion. The
147+
resulting stack will then be available to use in the current tutorial.
148+
149+
If the "stack" Source is used, a stack will be loaded from the internal
150+
resources folder of the tutorial (_resources/). Any `cTutorialTag` custom
151+
property of objects on the stack will be converted to tags for objects
152+
which can subsequently be used in the current tutorial.

Toolset/libraries/revidelibrary.8.livecodescript

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10367,6 +10367,10 @@ private function __fetchAndRemoveControlTags pCard
1036710367
return tTags
1036810368
end __fetchAndRemoveControlTags
1036910369

10370+
command revIDETutorialUpdateAndRemoveTags pStackName, @xTags
10371+
union xTags with __fetchAndRemoveTags(pStackName)
10372+
end revIDETutorialUpdateAndRemoveTags
10373+
1037010374
on revIDETutorialLoad pCourse, pTutorial, pLesson
1037110375
local tLocation
1037210376
put __findTutorialLocation(pCourse, pTutorial, pLesson) into tLocation
@@ -10393,7 +10397,7 @@ on revIDETutorialLoad pCourse, pTutorial, pLesson
1039310397
put return & tStackName after tStackList
1039410398
end if
1039510399

10396-
union tTags with __fetchAndRemoveTags(tStackName)
10400+
revIDETutorialUpdateAndRemoveTags tStackName, tTags
1039710401
end repeat
1039810402

1039910403
dispatch "revTutorialResume" to stack "revTutorial" with tStackList, tTags, tLessonDataA["step"]

Toolset/palettes/tutorial/revtutorial.livecodescript

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,12 +432,20 @@ end revTutorialParseInterlude
432432
on revTutorialParseLoad pTokens, @rData
433433
local tData
434434
revTutorialParseLine "load lesson <token>", pTokens, tData
435-
if the result is not empty then
436-
return the result
435+
if the result is empty then
436+
put "load" into rData["type"]
437+
put tData[1] into rData["lesson"]
438+
return empty
437439
end if
438-
put "load" into rData["type"]
439-
put tData[1] into rData["lesson"]
440-
return empty
440+
441+
revTutorialParseLine "load stack <token>", pTokens, tData
442+
if the result is empty then
443+
put "load" into rData["type"]
444+
put tData[1] into rData["stack"]
445+
return empty
446+
end if
447+
448+
return the result
441449
end revTutorialParseLoad
442450

443451
on revTutorialParseCapture pTokens, @rData
@@ -2086,18 +2094,39 @@ on revTutorialExecuteAction pActionData
20862094
revTutorialDoCreateSet pActionData["objects"], pActionData["tag"]
20872095
break
20882096
case "load"
2089-
revTutorialDoLoad pActionData["lesson"]
2097+
revTutorialDoLoad pActionData
20902098
break
20912099
end switch
20922100
end revTutorialExecuteAction
20932101

2094-
on revTutorialDoLoad pLesson
2102+
command revTutorialDoLoadLesson pLesson
20952103
# Check to see if the stack from the specified lesson is complete
20962104
local tTutorialInfo
20972105
put revIDETutorialInProgress() into tTutorialInfo
20982106

20992107
# Simply run the lesson that is to be loaded
21002108
revTutorialRunTutorial tTutorialInfo["course"], tTutorialInfo["tutorial"], pLesson, tTutorialInfo["location"]
2109+
end revTutorialDoLoadLesson
2110+
2111+
command revTutorialDoLoadStackResource pFile
2112+
local tFileName, tStackName
2113+
put revIDETutorialInternalResource(pFile) into tFileName
2114+
lock screen
2115+
lock messages
2116+
go stack tFileName
2117+
put the name of stack tFileName into tStackName
2118+
set the filename of stack tStackName to empty
2119+
revIDETutorialUpdateAndRemoveTags tStackName, sTaggedObjects
2120+
unlock messages
2121+
unlock screen
2122+
end revTutorialDoLoadStackResource
2123+
2124+
on revTutorialDoLoad pActionData
2125+
if pActionData["lesson"] is not empty then
2126+
revTutorialDoLoadLesson pActionData["lesson"]
2127+
else if pActionData["stack"] is not empty then
2128+
revTutorialDoLoadStackResource pActionData["stack"]
2129+
end if
21012130
end revTutorialDoLoad
21022131

21032132
on revTutorialSetText pStep
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Interactive Tutorial syntax
2+
The syntax `load stack <FileName>` has been added to interactive
3+
tutorials. This allows prepared stacks to be imported as operating
4+
stacks in the current tutorial.
5+
6+
The prepared stack will be loaded from the internal resources folder
7+
of the tutorial (i.e. from `_resources/<FileName>`). Any `cTutorialTag`
8+
custom property of objects on the stack will be converted to tags for
9+
objects which can subsequently be used in the current tutorial.

0 commit comments

Comments
 (0)