I will share some hacks I used in the LIP2-Engine. Some of them are basics, some are advanced, but I will try to explain it as easy as possible or approach it in multiple steps.
LIP2-HACK #1: Select a random row of a table
TL;DR: This post approaches the topic in multiple steps. You can also jump to -> Final solution if you want to skip the blabla.
One of the biggest improvements in the LIP2 (besides the controller) is the way how the map is filled with objects.
In the first game, I made a table with 99 rows listing the available objects multiple times and just randomly used one of it on the map using right(random(),2). The problem: There was no way to control, how often an object is really placed on the map. So e.g. there was no guarantee there even is an exit
I wanted to exactly define how often an object should be placed on the map, and thatfor I needed a way to select a row randomly from table, that has not been selected before. Here is how I made it work:
Example 1: Show a random fruit
In our example, we want to get a random fruit of our fruits table.
- Create a table called Fruits with a column “fruit” and a column “order”
- Fill in fruit names in your column fruit and fill in the formula
=random(false)in your column order
- On your canvas, create a new formula with
You now get a random fruit out of your table. That is cool, but is it cool enough? What, if you want another random fruit?