L-System in GDevelop

Hello I’m really interested in recreating what this website does:

http://paulbourke.net/fractals/lsys/

Although to be honest…I’m kind of lost.

I saw there is an user input where you can write things and you can add it to the scene, but it is not as easy as “the text = F” → “Create an object (drawer), draw a line”

If I could put the instructions the website uses for shapes, which are strings like “F+F+F+F” into the user input, then GDevelop would be able to draw those beautiful shapes as well.

Sorry I didn’t include any screenshots, just hypothetical thinking here.

1 Like

[accidentally sent too soon, take 2]

Interesting concept. Any particular area that you’re stuck on?

The shape painter would do the drawing.
You could use the input object to get the text
There are various text manipulation expression. You can go through the text with something like strAt (get a character from a text) using a variable for the position. And setting the result into a variable.
You might use the repeat event length of text times
Then use a bunch of conditions to handle the rules for each character.

I know I make it sound easy. This is just an initial big picture without knowing all of the rules that it uses.

That’s a real interesting idea. I might one day try it myself.

1 Like

Hi! Thank you so much for taking interest in this concept. One of the things I am stuck at is, I discovered how to draw a forward line writing “F” in the text input, but it won’t draw a line each time I write “F” inside the input, making it imposible to give it a set of instructions that sum themselves.

Is “strAt” like regexp? I think with regular expressions I would be able to handle it? Sorry If I don’t understand your ideas at first, you are much more advanced than me.

Anyway, the shape painter doesn’t make for good platforms. I am working on a new version with squares and the result is very interesting.

I will post the result of that new experiment and if you want, I’ll send the link to you as well

1 Like

It’s like mid(). It returns the character at a specific location from a string. The 1st position of a string is zero.

This just sets the variable chr to each character in the variable named text and then sends it to the debugger output. You can check the value of chr and draw the needed shape.

1 Like

Wow, really awesome. I’d like to use it for a rpg in early gameboy style

1 Like

If it was something too time consuming, you’d probably want to us the same concept but once per frame because it could appear to lock up otherwise. The repeat doesn’t have a way to exit and nothing else gets updated while it’s looping. You could increment the variable each frame while a boolean was true or false and then add a button or mouse click as a way to cancel it.

Thank you I will give it a try as soon as possible