TutorialsA* Search

Making What a Card Shows

Every piece of 8-Puzzle Solver comes to you in two parts. The first is a story. It’s a few paragraphs that put the piece in your head. They show what it does on the worktable, and roughly how. The second is a card, the same piece written out exactly, with every name and every number. Read the story. Then look at the card with that picture in mind, and build.

This page is about the cards. Each passage shows how to make one kind of thing in Myth Engine, in the editor’s own words. You don’t need all of it today. Read the first passage, Before your first card, and then start Chapter 1. That chapter meets nearly every kind of card, so it sends you back here often, one passage at a time. A paragraph that opens with a later chapter, such as From Chapter 2, can wait until then.

The editor will feel strange at first. That’s true for everyone. It passes, and somewhere in Chapter 1 your hands start finding things before your eyes do.

Before Your First Card

Everything your game is made of lives in the Resources panel, down the left side of the editor: its Objects, its Logic, its tables, its pictures and its Scene. To make something new, press Add at the bottom of that panel. The Add Resource window asks what kind of thing it is. Double-click anything in the Resources, and it opens in a tab of its own.

A card lists what you change, and a few lines that only confirm what’s already there. The passages below point those out. Whatever a card leaves out stays the way the editor makes it.

One thing only looks left out. It’s a Text that starts empty, which a card shows as (empty), or with nothing after “starts at”. The editor often puts a 0 in that box, so clear it.

This game needs Advanced Mode from the start. Two of its blocks make a Tile glide: Tween and Control Tween. The Action List hides them until it’s on, and they’re the only ones this game needs it for. To see them, choose Settings > Advanced Mode at the top of the editor. The status bar then says Advanced mode enabled. Only the editor changes. Your game stays exactly as it was.

To run your game, press Play, the triangle at the top of the editor. The game opens in a window of its own. Close that window, and you’re back. Save as you go with Ctrl+S, at the end of every part at least.

The Set Up Card

A chapter that adds keys, settings or placements opens with a Set up card. It holds everything that isn’t an Object or its Logic. Each block starts with a heading in capitals. Chapter 1’s is the longest. That chapter goes down it one block at a time, from the top of the card.

ART names the pictures the chapter will use. They’re in your project already. The Starter Kit brought both of them in Chapter 1. Observatory Worktable is the whole table behind the puzzle. UI Background is a tiny white square, and every Tile, Goal cell and button is that square, tinted.

COMMANDS are the game’s keys, each under a name your Logic uses. Chapter 1 has eight, Slide Tile 1 to Slide Tile 8. Press Game Settings, the button at the top of the Resources panel, and choose Input Manager. Then press Add Command. A small window asks for the Command Name and the Input Type. Every Command in this game is a Button. The window has an Add Command button of its own. Press that one. The Command is made.

A new Command has one row, and it reads No Input Assigned. Click it. Then press the card’s key, the one under Keybindings. Your Logic asks whether Slide Tile 1 was pressed, never which key did it.

GLOBAL VARIABLES are values the whole game shares. The Board State is one. On a card, a Global has a $ in front: $boardState. That tells it from the values a Logic keeps for itself. The name you type has no $.

You make a Global from inside a Logic Component. Down the left of its canvas is a column of small cards, and one is Globals. Press its + button and choose New Global…. The Add Global window asks for a Name, a Type and a Default, the value it starts at. Give it the card’s three, and press Add. $statusLine has nothing after “starts at”, so it starts empty: pick Text, then make sure its Default box is clear. Chapter 1 makes its Globals in Start Board, the first Logic Component that uses them. Once a Global exists, every other Logic finds it under Existing Globals, on the same + button.

GAME SETTINGS lines say where each setting lives. Take GAME SETTINGS > Display > Window. In Game Settings, choose Display, and find the Window group. The names under the heading are its fields. Enter them in the card’s order, top to bottom, and where the order matters, the chapter says why.

A SCENE block marked (new) is a Scene the chapter makes. In Chapter 1 it’s the one Scene your new project already has, given the card’s name: Puzzle Table. To reach a Scene’s own settings, open it and pick Select, the arrow above the preview. Then click an empty spot. The Scene’s Properties appear on the left.

A new Scene starts with no camera at all. Under Cameras and Views, press Add View, and Myth makes the Main Camera and the Main View together. The Camera line gives the Main Camera’s X and Y, then its Visible Width and Visible Height, all in meters. The View line gives the Main View’s size on the game screen, in pixels. Chapter 1 says how to check them, and which boxes to change if one is different.

Start Scene waits until after the Scene. It’s a list of your Scenes by name. Puzzle Table is on it only once the Scene has that name. The list writes it Puzzle Table · 2D.

PLACE THESE says what goes where. Open the Scene, and the Place Scene Content panel is on its left. Your Objects are near its bottom, under Predefined Objects. Drag one onto the Scene, then type the card’s X and Y.

Nearly everything in 8-Puzzle Solver sits on the screen: the worktable, the title, the Tiles and the Goal picture. Their X and Y go into Screen Offset (px), counted in pixels from the top-left corner. Up counts as positive there. So the worktable’s Y of -425 puts its middle 425 pixels below the top edge. Type the card’s numbers, minus signs and all.

Puzzle Rules is the one thing in the world instead. It has no picture. Its X and Y go into World Position, in meters: 0 and 21.25.

A Placement’s Own Values

Some lines under a placement start with “with”, and each is a value only this placement has. The eight Tiles are one Object, placed eight times. The line with Data Structure > Values > Number = 1 is what makes the first one Tile 1.

Select the placement in the Scene, and its Properties open on the left. Near their foot is the placement’s Data Structure part. Under Values there’s one box for each field. The editor writes each field’s name its own way, so number shows as Number. Type the card’s value into it. The Goal Cells work the same way, with Slot.

An Object card can give a Sprite a line called Tint (on its placement). That color belongs to each placement, so the Object editor has no field for it. Select each placement of that Object, and open its Sprite part. Tint is in that part’s own Rendering group. Click its swatch, type the card’s code into the HEX box, and press Enter. Eight Tiles and nine Goal Cells make seventeen. It’s slow, and it’s the same every time.

From Chapter 4, a line such as with Per Instance Variables > Message = solvePressed gives one button its own message. Select the placement. Its name is in the Scene Explorer, on the right of the Scene, if it’s hard to click. Look down its Properties to Logic. Each Logic Component on the Object has a part of its own there. Under Send When Pressed is Per Instance Variables, with a box named Message. Type the card’s word into it. No quote marks. A button with no such line keeps the word every button starts with, which is stepPressed.

From Chapter 4, a line may also end with (Edit Object Locally). Its value belongs to one of the Object’s components, such as the words on the Solve button. Press Edit Object Locally, near the top of the placement’s Properties, and the Object’s components open for this one placement. Pick the component, and change the card’s field. The editor marks that component Override, because it now differs from the Object’s own. Back to Scene brings you back.

From Chapter 5, CHANGE THESE PLACEMENTS names placements already in the Scene, and where each one moves. Take Status Line, move to X 766, Y -560. Select the Status Line, and type the new numbers over the old ones. Two of the lines are Puzzle Buttons. The chapter says which button each one is.

An Object Card and Its Components

An Object is a thing in your game: a Tile, a button, a line of words. Make one with Add > Object. The Create Object window asks for the card’s name and an Object Type.

When the card’s Transform says Presentation > Space Window / UI, the Object is a Screen UI Object. It lives on the screen, measured in pixels. Its Space and Render Layer are set already, and its Bounding Box starts at 32 by 32. Every Object in this game is one of these but Puzzle Rules. That one is an Empty Object, a Transform and nothing else, and it holds only Logic.

Here is the Tile, from Chapter 1.

ObjectTile
Transform
Presentation > SpaceWindow / UI
Presentation > Render LayerUI
Bounding Box > SizeX 142, Y 142
Text / UI
Text{number}
Font Size50
EmphasisBold
Color#233947
AlignmentCenter
RenderingVector
Sprite
Z Index Within Object-1
SpriteUI Background
Transform > SizeX 142, Y 142
Tint (on its placement)#F1E8D3
UI Interaction(as it is added)
Data Structure
From LogicSlide To Slot, Click To Choose
Data StructureNumbered Tile
Logic
Slide To Slot
Click To Choose
Shared Variables
puzzleRulesPuzzle Rules

The card lists the Object’s components, with the fields to change under each one. A component gives an Object one ability. Sprite shows a picture, and Text / UI shows words. Data Structure gives the Object a small form of values to carry. UI Interaction lets the player press it. Transform is different: it’s on every Object from the very start. It says where the Object is and how big.

In the Object editor, Attached Components is the list at the top right. The Component Toolbox sits under it, in closed groups. Open a group, and click a component to attach it: Sprite and Text / UI are under Rendering. Select a component in Attached Components, and its Properties open on the left. The card’s lines are those Properties, in order.

The Transform’s Bounding Box is the Object’s own size, apart from its picture. Type the card’s numbers into its Size, 142 by 142 for a Tile.

A Sprite asks for its picture first. The Add Sprite Component window lists your pictures, so pick the card’s and press Add Sprite. Transform > Size is how big the picture is drawn, in pixels on the screen. Z Index Within Object at -1 puts the picture behind the Object’s own words, so the Tile’s number shows on top. Scene Depth Draw Order decides which Object is drawn over which. The higher number wins. The worktable’s -30 keeps it behind everything.

A Text / UI’s Font Size is a box. Emphasis has a B button, an I button and a list of weights. Pick the card’s weight, such as Bold or Semibold, from that list. Color is a swatch: click it, type the card’s code into the HEX box, and press Enter. Alignment is a row of three choices, and Center is the middle one.

Rendering is a list. Choose Vector, as the cards do. When you open that Object again, the list says Editor Default. Your Vector is still there. Only the list forgot.

A Text with braces in it shows a live value, one that changes while the game runs. Type it into the Text field as the card spells it, braces and all. So {number} follows the field named number in the Tile’s own Data Structure. And {$statusLine} follows that Global.

On a Screen UI Object, UI Interaction comes attached. Keep it only where the card lists it: on the Tile, and from Chapter 2 on the Puzzle Button. There it says (as it is added), so leave its fields the way they come. Every other Object in this game has none. On those, press the red trash button on its row in Attached Components.

A Data Structure line From Logic is one you don’t attach yourself. The Logic Components it names bring it. So the Tile gets its Numbered Tile the moment Slide To Slot is attached, and the line under it is there for you to check.

Logic comes last on an Object card. It isn’t in the toolbox. Switch the list at the top right of the preview from Components to Logic. Now Attached Logic is on the left, and Compatible Logic is on the right. Click each Logic Component the card names.

Some Object cards end with Shared Variables, as the Tile’s does: puzzleRules, Puzzle Rules. That’s a value the Object holds for its Logic, here the Object a Tile reports to. It arrives with the Logic. Switch the list back to Components, and look in the Object’s Properties under Variables. Each Shared Variable is there, marked From Logic. Its Value is a list, so pick the card’s Object in it.

A Data Structure Card

A Data Structure is a small form of named fields, and an Object carries one filled-in copy. Every Tile carries a Numbered Tile, which holds its number. Every Goal Cell carries a Goal Slot. Make one with Add > Data Structure. The Create Data Structure window asks only for its Name, and a new one starts with no fields at all. Here is Goal Slot, from Chapter 1.

Data StructureGoal Slot

What one Goal Cell shows. slot is the Slot of the Goal Picture it shows (0 to 8, in reading order), set on each placement; label is the number it shows: the Tile the Goal has in that Slot, empty for the Blank.

slotNumberdefault 0
labelTextdefault (empty)

The sentence under its name is its Description. If you’d like it, type it into the Description box on the left, under the Name. The game never reads it, but months from now, you will.

Press Add Field for each line. A field has a Name, a Type and a Value, and the card’s default goes in Value. A new field is a Number with 0. Switched to Text, it keeps the 0. So where the card says default (empty), as Goal Slot’s label does, clear the box.

A few Data Structures you’ll find made already, each named after something else you made. Slide To Slot Data belongs to the Logic Slide To Slot, and comes from its Data Structures card (the next passage). Board Layout Entry comes with the Board Layout table. Fill in their fields from their cards, the same way.

A Logic Component Card

A Logic Component is a piece of behavior you attach to an Object: how a Tile slides, or how Puzzle Rules makes a Move. Make one with Add > Logic Component. The Create Logic Component window asks for a Name and a Starter. Leave the Starter on Empty Logic Component. This card is from Chapter 1. It lets a click on a Tile choose it.

Logic ComponentClick To ChooseAttach to: Tile

Clicking or tapping this Tile chooses it. Puzzle Rules decides whether it moves.

Attach toAny Object
DATA STRUCTURES
Numbered Tileself.numberedTile
SHARED VARIABLES
NameTypeKindStarting Value
puzzleRulesObjectConstantNone
On Hud Activated
WhenUI Activated
1Choose TileFunction
puzzleRules
@self.puzzleRules
tile
self.numberedTile.number

The Logic opens on its canvas, the big space in the middle. Down the canvas’s left side is a column of small cards: Logic Component, Globals, Data Structures, Components, Per Instance Variables and Shared Variables. Each has a count and a + button. The blocks at the top of your card, before its first Event, are made on these.

The card’s heading names the Logic Component and the Object it goes on, here the Tile. That’s where you’ll attach it. The sentence under the name is its Description. If you’d like it, click the Logic Component card’s heading, and type it under Logic Component Name. That card also holds Attach to. Every Logic in this game says Any Object there, and that’s how a new one starts. It means any Object that has what the cards below it list.

DATA STRUCTURES are the forms this Logic hands to each Object it’s on. Numbered Tile, self.numberedTile, is one you made before. Press the Data Structures card’s +, and pick it under Existing Data Structures. Slide To Slot has a second one, Slide To Slot Data, which belongs to that Logic and no other. For a line like that, press + and choose New Data Structure. Myth makes it, names it after the Logic, and opens it, ready for the fields on its own card. Either way, the name on the right, such as self.numberedTile, is the name the Logic reads it by. Myth gives it that name itself. So Click To Choose reads the Tile’s number as self.numberedTile.number.

SHARED VARIABLES hold one value for each Object, the same for every placement of it. The Logic reads one with @self in front: @self.puzzleRules. Press + on the Shared Variables card. The Add Shared Variable window asks for a Name, a Kind, a Type and a Starting Value. The card gives all four, in its columns. Constant means the Logic reads it but never changes it. An Object Shared Variable starts at None, and the Object card picks its Object, as the Tile’s picks Puzzle Rules. A Number one, such as Slide To Slot’s slideSeconds, starts at the card’s number: 0.22.

PER INSTANCE VARIABLES hold one value for each placement. The Logic reads one as self.message. From Chapter 2, that’s how one Puzzle Button Object becomes five buttons. Each sends its own word. Press + on the Per Instance Variables card. The Add Per Instance Variable window asks for a Name, a Type and a Starting Value.

The rest of the card is its Events, each with its Actions. The next passages are about those.

Events: The When Bars

An Event is a moment your Logic waits for: the Scene starting, a click on a Tile, a key, a message arriving. Each Event on a card starts with a plain heading, such as On Tile Chosen. That’s the name Myth gives the Event by itself, from its kind and its setting, so you never type it. The message tileChosen makes On Tile Chosen, and the Scene starting makes When the Scene Starts. It’s the name you’ll pick when an Action asks for an Event.

Under the heading is the When bar. It names the kind of Event. Then comes its setting, if it has one: a Command or a Timer name.

Press Add Event, the + in the toolbar above the canvas. Its window has a filter at the top, so type the kind’s name there, pick it, and press OK. Create, Scene Start and UI Activated ask nothing more. The new Event appears on the canvas as a big block. Its kind is on top, and its own short sentence is under When, such as On custom event tileChosen. Every Event of the Logic sits on the canvas at once. The list in the toolbar takes you to any one of them.

Command Pressed asks for its Command in a second window, so make the Commands first. Pick the card’s, such as Slide Tile 1, and press OK again. Tile Keys has eight of these Events, one for each key.

A Recurring Timer has a name you make up, so its second window can’t list it. Choose Type a timer name… and press OK. Then type the card’s name, slide, into the small window that comes next.

Nearly all Events here are a Custom Event. That’s a message one piece of Logic sends and others listen for, like a bell rung in one room and heard in another. Its When bar names the message, such as tileChosen. To listen for a new one, open the Add Event window and choose Custom Events > Project Events > Add Custom Event…. Type its name. Once some Logic sends that message or listens for it, it’s on the list already.

You can build the sending and the listening in either order. Trigger Custom Event rings the bell for every Object that listens. Trigger Custom Event on Object rings it for one Object only, the one its Applies To names. Either one’s Custom Event field takes the name exactly as you type it. So you can send a message before anything listens.

From Chapter 2, a Custom Event box can hold a Per Instance Variable instead, so each button sends its own message. Make the Variable first, on the Per Instance Variables card. Then type it into the box as the card gives it, self.message.

Modes

To the right of every Event block stands a smaller, pointed block, joined to it by an arrow. That’s the Event’s Mode, and the Event’s Actions hang under it. A new Event has one Mode, named after its Logic Component. Most Events never need a second. Their cards don’t mention it.

Some Events, though, behave in more than one way, depending on what’s going on. Each way is a Mode of its own, with its own name and its own Actions. They stand in a row to the right of the Event. In Chapter 1, when you choose a Tile, Hand Moves either makes the Move, or does nothing while a Tile still slides. On the card, each way is a line under the When bar: Mode Ready (Starting Mode), then Mode While Sliding. The card repeats the Event’s heading and When bar above each one. It’s still one Event.

Right-click a Mode block and choose Rename Mode… for the card’s name. To add another, right-click the Event block and choose New Mode…, and type its Mode Name. Once an Event has several, its block gets two more settings. Modes reads One at a time or Combined. Every Event in this game stays on One at a time: one Mode answers, and the others wait. Starting Mode picks the one that answers first, marked (Starting Mode) on the card. The card lists the Modes in their order. A Mode’s right-click menu has Move Left and Move Right to put them in that order.

A Mode marked (no Actions) stays empty. While it’s the one that answers, the Event does nothing at all. So while one Tile slides, a click on another does nothing.

Switch Mode changes which Mode answers. It does that while the game runs. It picks the Event and the Mode from lists, by name, as in On Tile Chosen and While Sliding. So make the Event and its Modes first. The Action that switches them comes last.

Actions, One at a Time

Under each Event, the numbered rows are its Actions, in order. In the editor, they’re blocks on the canvas, joined by arrows into one line that runs down from the Mode’s block to End. In a Function, the line runs down from a block named Start instead. The Action List on the right holds every Action, in closed groups. Type an Action’s name into its search box. Click it, and its block appears.

A new block lands a little to one side, apart from the line, with no arrow into it. Such a block does nothing when the game runs, because it isn’t on the line yet. Right-click it and choose Connect to sequence. It joins the end of the line, right above End, and an arrow runs to it. Join each Action as you add it.

When an Event has several Modes, each Mode has a line of its own. To add an Action to one of them, right-click that Mode’s block, or a block on its line, and choose Add unattached Action here. A window opens with the Actions in it. Pick one and press OK. Its block lands near that line, and Connect to sequence joins it there.

To put a block between two others, click the round handle at the bottom of the block it should follow. Then click the round handle at the top of the new block. The handles join blocks of one panel only. So inside an If’s or a Repeat’s panel, add the new block with that block’s own Add inside item first. If, Else, Repeat and While shows how.

Fill in the fields the card lists, and leave the rest the way they start. An Action with no lines under it, like Control Tween, is whole: add it, join it, and leave it alone.

Some Actions have an Applies To line, naming the Object they work on. On the block, it’s the box after the word on, and it starts at Self. Without the line, leave it there. With it, type the card’s name, such as @self.puzzleRules.

Some Actions hand back an answer. On the card their first line is an Action Name, and on the block it’s the box after the word as. Type the card’s name there, with no quotes. A later Action reads the answer by that name. So chosenSlot.value is the Slot that a Slot Of Tile named chosenSlot found.

A Change Variable sets one Variable to a Value. On the canvas, its block starts with the word Set, and the Variable box comes after it. Type the Variable’s name as the card writes it. A name with a $ in front is a Global, so type the $ too. Beside it is an Operator list that starts at =, and then the Value replaces what the Variable held. With += the Value is added on, and with -= it’s taken away. No Operator line on the card? Then it’s =.

Declare Variable makes a value that lives only while its Event or Function runs, such as Slot Of Tile’s slot. Its block reads Declare, then a Type list, a Name, and a value after the = sign. The Type starts at Number. A card gives a Type line only where it’s something else, such as Boolean. Once a Declared name is in a Change Variable’s box, the box may show it as self.slot. It’s the same Variable.

Change Component Value changes one field of a component or a Data Structure, the one its Component Value path names. Type the path as the card spells it. Take self.goalSlot.label, from Show Goal Tile, which is the label field of this Object’s Goal Slot.

A Function goes in like any Action, from the Functions group of the Action List. The card gives it a small Function tag. Its fields are the Function’s PARAMETERS, under the same names, such as board and tile. A field that takes an Object, such as puzzleRules, takes the card’s name for it: @self.puzzleRules, in Click To Choose.

Chapter 1 also moves Tiles on the screen. Set Position puts this Object at an X and a Y at once. Its Position Relative To list says what they’re counted from, and it starts on World. The card’s Screen means screen pixels, the same as Screen Offset. Tween glides one value, named in its Value box, to its Target over its Duration in seconds. Two of them make a Tile’s slide: self.transform.position.x and self.transform.position.y. On a Screen UI Object, those are its place on the screen, in the same pixels as Screen Offset. Its Ease stays on Linear, so the Tile moves at an even speed. Control Tween ends a glide where it is.

Start Recurring Timer starts a timer with a name. Its Timer Name is the name a Recurring Timer Event listens for. Repeat Every (s) is how long it waits, and Ring Once at Yes rings it only once. Change Sprite Tint Property tints this Object’s picture with the color in its Value.

From Chapter 2, four Actions work on a Data Table while the game runs. Control Data Row adds a row by its name. Set Data Cell writes one value, in the row and the column its boxes name. Reset Data Table empties out what the game wrote. It puts the table back. Check Data Row Exists answers whether a row is there. Its answer is storedBefore.value, true or false.

From Chapter 4, Stop Recurring Timer stops a timer by its name, so it rings no more. From Chapter 5, Generate Random Integer picks a whole number from its Minimum to its Maximum, both included. Its Action Name is pick, so the number is pick.value.

Values, Quote Marks and All

Every value on a card is written exactly the way its box should hold it. Type it as you see it. The way a name starts tells you where its value lives. A plain name, such as tile, is a Parameter of this Function, or a Variable a Declare Variable made. A name with a $ in front is a Global. One that starts self., such as self.message, is a Per Instance Variable. With an @ in front, as in @self.puzzleRules, it’s a Shared Variable instead, one value for the whole Object.

A longer self. name reads a field of a Data Structure. So self.slideToSlotData.shownSlot is the shownSlot field of this Tile’s Slide To Slot Data. A value can be a small formula, too. The formula data('Board Layout', layout, 'boardLeft') reads one cell of the Board Layout table: the row named by layout, in the column boardLeft.

Most boxes read what you type as a formula. In those, a word needs quote marks, so the card gives it with them, like the table’s name "Search States" in Chapter 2. Without them, the box takes the word for the name of something else. It marks that as an error. A few boxes hold a word as you type it, such as a Custom Event’s name or a timer’s. A word a Function is handed, such as board for Slot Position’s layout, is another. The card gives those bare.

Which kind is a box? You don’t have to work that out, because the card already did. A word the card shows in quotes goes in with them. A word it shows bare goes in bare. Show Goal Tile’s '#d5c6a7' has quotes, and Slot Position’s board has none. Both are right where they are.

Single and double quote marks do the same job, so 'board' and "board" are one word to Myth. Type whichever the card shows. The box may redraw it in double quotes. Two quote marks with nothing between them, "", are a word with no letters. Check Goal sets the Status Line to that, to empty it.

The formula text() turns a number into words. Show Goal Tile’s text(goalTile.value) is the Tile’s number, as the words a Goal Cell shows. From Chapter 2, text(board) names a row by a Board State’s nine digits.

A true or false goes into a box as that word, with no quote marks around it at all. Yes and true, though, are one value, written in two different ways. So are No and false. Some places in the editor show one and some the other, as Ring Once shows Yes. Type each the way its card shows it, and it’s the same value.

If, Else, Repeat and While

An If runs some Actions only when its condition is true. It’s in the Action List’s Logic group. On the canvas it’s a wide, pointed block, and a line marked True runs down from it. That line is the card’s Then panel.

The condition is one box inside the block, and the card gives it after the word If. Click the box and type it as the card spells it, such as apart.value == 1. Enter, or a click somewhere else, keeps it. From Chapter 2, a condition can join two tests. && means and: both have to be true.

To fill the True line, right-click the If and choose Add inside Then. A window opens with the Actions in it. Pick one and press OK. If the new block stands apart, join it with Connect to sequence. It joins the end of that If’s line. With one If inside another, right-click the If whose line the Action belongs on.

The card’s Otherwise panel is the If’s Else, the Actions for false. Right-click the If and choose Add Else. An Else block joins the If, on a line marked False beside it. Right-click the Else and choose Add inside Else for each of its Actions. Join each the same way. Otherwise gets a step number, but you won’t find it in the Action List.

A Repeat runs its Each time panel a set number of times, its Count. The card says Repeat 9 times, so Slot Of Tile’s Count is 9, once for each Slot of the Board. The Count box takes a formula too. In Chapter 2, it’s dataCount('Search States'), the number of rows in that table. On the canvas a Repeat starts closed, one bar with its Count on it. The small arrow at its left end opens it. It fills the way an If’s True line does: right-click it and choose Add inside Repeat.

Inside a Repeat, local.index says which time round it is, counting from 0. Slot Of Tile looks at Slot 0 first, then Slot 1, and so on up to Slot 8. Type local.index as the card has it. In a Repeat inside another Repeat, it means the inner one’s count.

A step at an If’s own indent, right after it, comes after the If instead of inside it. Add it from the Action List. Connect to sequence joins it to the end of the outer line. A block that went into the wrong panel can move. Right-click it and choose Cut, then paste it where it belongs, and join it.

From Chapter 5, a While runs its Each time panel again and again, for as long as its condition holds. Its condition is one box on its own bar, typed the way an If’s is. Add inside While fills its panel. Something inside has to change the condition sooner or later, or the loop never ends. In Random Move, counted grows by 1 until it reaches pick.value.

The step numbers count right through the panels. So step 4 may sit inside an If that began at step 3, and the indent shows where each one belongs.

A Function Card

A Function is a small piece of Logic that does one job when it’s asked. Slot Of Tile, from Chapter 1, answers which Slot holds a Tile. Make one with Add > Function. Give it the card’s name.

FunctionSlot Of Tile

Where one Tile is in a Board State: the Slot (0 to 8) that holds it. Tile 0 is the Blank.

PARAMETERS
NameTypeStarts at
boardNumber0
tileNumber0
RETURN TYPENumber
ACTIONS
1Declare Variable
Name
slot
Value
-1
2Repeat9times
Each time
3Tile In SlotFunction
Action Name
digit
board
board
slot
local.index
4Ifdigit.value == tile
Then
5Change Variable
Variable
slot
Value
local.index
6Return
Value
slot

Its card has PARAMETERS, then RETURN TYPE and ACTIONS. There’s no Event. Its Description, if you’d like it, goes on the Function’s own card. That’s at the top of the left column, under its Function Name.

PARAMETERS are the values a caller hands in. They live on the Start block, at the top of the canvas, where the line begins. Press its + button, and the Add Parameter window asks for a Name, a Type and a Default. The card’s last column, Starts at, goes into Default.

A Parameter of type Object, such as Choose Tile’s puzzleRules, has a Settings arrow on its row. Open it. When the card names an Object, as puzzleRules names Puzzle Rules, set Compatibility Mode to Nominal and pick it in Object Type.

RETURN TYPE is what the Function hands back. Open the Function’s own card, and pick it in the Return Type list. Slot Of Tile hands back one plain value, a Number. Slot Position hands back a Slot Position Result, a Data Structure with x and y. Make that Data Structure first, from its own card. Then it’s on the list. A Function with no RETURN TYPE line, such as Choose Tile, hands nothing back.

The ACTIONS hang in one line, from Start down to End, and they run each time another piece of Logic calls the Function. The Return Action comes last in the line. For one plain value it has one box, Value. For a Data Structure it has a box for each of the Data Structure’s fields, under the same names. In Slot Position, x gets slotX. And y gets slotY.

A caller reads the answer by its Action Name. When the answer is one plain value, add .value to that name, as in chosenSlot.value. When it’s a Data Structure, add the field. In Slide To Slot, startPlace.x is the x of the Slot Position call named startPlace.

A Data Table Card

A Data Table is a spreadsheet the game reads while it plays, one row for each thing. Make one with Add > Data Table. The Create Data Table window asks only for its Name. Here is Board Layout, from Chapter 1, and the Data Structure that comes with it.

Data TableBoard LayoutData Structure: Board Layout Entry
Row 0board
boardLeft187
boardTop-260
slotSpacing150
Row 1goalPicture
boardLeft694
boardTop-317
slotSpacing72
Data StructureBoard Layout Entry

One row of the "Board Layout" Data Table.

boardLeftNumberdefault 187
boardTopNumberdefault -260
slotSpacingNumberdefault 150

A table’s columns are the fields of its own Data Structure, named after it: Board Layout Entry for Board Layout. Myth makes that Data Structure with the table. It starts with no fields. The table’s card names it at the top, beside the table’s own name. Open Board Layout Entry from the Resources, and press Add Field for each line, with its name, type and default. They show up in the table at once, under Columns.

Then the rows. Add Row sits under the grid. A new row starts with every column’s default, so set the defaults first, and you’ll type only what differs. A row’s name goes in the grid’s Entry column. Double-click a cell to type in it. Enter keeps what you typed.

The card counts rows from Row 0, and the editor numbers them from 1. So Row 0, board, is your first row.

From Chapter 2, Search States starts with no rows at all. That’s right. The search writes its rows while the game runs, one for each Board it finds. Its isOpen field is a Boolean, a true or false. Pick Boolean for its Type, and give it the card’s default, true.

From Chapter 3, a card may take away a row that the table no longer needs. Click one of the row’s cells, then press Delete Selected Row, under the grid beside Add Row. The rows below it move up.

Changes Cards

From Chapter 2 on, the game changes what you’ve already made. A Changes card shows the whole piece with the changes marked, so you can find your place. Lines marked Add, in green, are new: add them. Lines marked Delete, red and struck through, are gone. Delete them. To take a block off the canvas, right-click it and choose Delete. The blocks after it close up the line.

A struck step keeps the number it had, right above the steps that take its place. Every other step shows its number as it is now. Sometimes a step stays and only its values change. Then the new values are green, with the old ones struck under them. The Description at the top is always the new one, and it’s never marked.

This one, from Chapter 2, changes Check Goal. Its Else goes, with the step that emptied the Status Line, because the search speaks on that line now.

Logic ComponentCheck GoalAttach to: Puzzle RulesAddDelete

Says "Solved" on the Status Line when a Move makes the Goal, as its Tile begins to slide.

Attach toAny Object
On Board Changed
WhenboardChangedCustom Event
1If$boardState == data('Puzzle Settings', 'puzzle', 'goalBoard')
Then
2Change Variable
Variable
$statusLine
Value
data('Messages', 'solved', 'words')
3Otherwise
4Change Variable
Variable
$statusLine
Value
""

If Your Game and a Card Disagree

It will happen. A value lands in the wrong box, or a step goes in the wrong panel. That’s how everyone learns this.

A piece that does nothing at all? Look first for a block standing apart from its line, with no arrow into it, and join it with Connect to sequence. A box the editor marks as an error? Count its quote marks. A Mode that never answers? Look at the Event’s Starting Mode, and at the names in the Switch Mode that should turn it on. A Tile that won’t move when you click it? Look at its placement’s Number, under Values. A Tile still at 0 asks for the Blank, and the Blank never slides.

Every chapter’s Goal box also holds that chapter’s finished project as a download. Open it with File > Open Project…. If yours has changes you haven’t saved, Myth offers to save them first.

Find the piece that misbehaves. Go down it line by line against yours, until the two part ways. Or start the next chapter from the download. Nothing you built is wasted, because now you know where everything goes.

One difference is only a name. In a download, a table’s grid has longer headings, such as Slot 0 center, X (px) above the column boardLeft. Its Data Structure still says boardLeft, so it’s the same column.

Chapter 1 begins with a new, empty project. It ends with eight Tiles on navy velvet, sliding where your hand sends them.