This example shows a more complex custom script which is used to make a memory game .
The first piece of the script registers the memorygame function setting it to take a row and a column (between 1 and 4).
Then global tables/arrays are created to hold the memory items, state and current card. The cards are allocated in pairs, and then ten sets of pairs are swapped to shuffle the deck.
This script block is the main function. It remembers the component the user clicked on (self) by storing it in the memory_item table/array. If it’s the first card clicked on (and it’s not already flipped) the card is turned over with an animation. If it’s the second card then it’s compared to the first card. If its a match we bounce the cards and leave them face up. If it’s not a match then the cards are turned back over.
This final code is some helper functions which use the handy set_prop_in function to set properties in a specified time in miliseconds. This creates the animation you see as the values change.
Finally here is a video of the game in action.