My old partner once told me, “Just because you can do it in Lectora doesn’t mean you should.” That was before they found him stark raving mad, muttering about variables.


I was beginning to see his point. I had a case to solve that involved a chess set made only in Lectora by my old nemesis, Professor Lessesmore. I already figured out that once you click a piece to move it, a hidden layer with an invisible button for each square is shown (see The Case of the Persistent Variables: a Lectora Mystery Part 1 to learn how to do this tip). Clicking on the square sets the x/y coordinate that the piece moves to. But how do you encode the location with the least amount of variables?


As it turns out, you only need two actions on each square to accomplish this. The first action sets the location using the standard chess method of “1-8” for the vertical rows and “a-h” for the horizontal. In our example at right, button 8a sets the “_square” variable to “8a.” The second action runs an action group (parseSquare) that uses 16 actions to decode the location, and one to trigger the “move” action group. So action “8” sets the y variable to 100 (if “_square” contains “8), and the “a” action sets the x variable to 200 (if “_square” contains “a”). This way the x and y variables are used as containers and do not need to be hard coded to each square button, which would require 64 actions! Then the “move” group has a Lectora “Move To” action for each piece (and triggered if that piece is set to current) to animate it to the x/y position we defined (see illustration). With the action to hide the square “triggers” on run of the “move” group, we’ve made the pieces clickable once again.


With this foundation, all kinds of cool possibilities open up for dynamic targeting and animation, using only Lectora. Groups as sub-routines, and variables as containers for passed information — Professor Lessesmore is an evil genius.


Learn more how Lectora Templates can save you precious development time. Click the Lectora Templates button below to learn more.

Lectora Templates

Pin It on Pinterest