Break my story into seperate pages

I’m trying to write an interactive novel, and I have been using an array variable and a number variable to keep track of my pages. I write down one page of my story in the first array child variable(StoryPages). I want to make the Currentpage (number variable) equal to the corresponding StoryPage child. For example CurrentPage = 0, go to story page child 0 and show that in the text object (StoryText) on the page. When the player presses the next arrow, I want it to add 1 to CurrentPage and therefore it will go to storypage 1 etc.

However, I don’t know how to code this and make the currentpage value equal the storypage child of the same value. Currently, no text is even showing up when I run the preview because there’s no relation between storypage and currentpage. I tried writing “Storytext set to variable(Storypage[currentpage])” earlier, but it didn’t work until I made the connection between the two variables when I added the currentpage to storypage, but of course that relationship wouldn’t help my project. I tried setting the variable currentpages to the childcount(storypages), but the text object StoryText won’t be set to currentpages because it returns a number. How should I solve this problem? Am I trying to do this the wrong way?

It looks like a syntax error. If you just need to know the syntax to use

2 Likes

slightly unrelated but i would recommended that you look into the dialogue tree system gdevelop has!! it is very neat and easy to use after you set it up with your game :slightly_smiling_face:‍:arrow_up_down:

2 Likes

Just to add on Lucky-j’s events. The variable system was modified awhile ago but there are still a lot of examples and tutorials that use the old system.

The Variable() and VariableString() expressions are no longer needed for variables. You can just use the variable name.

You do sometimes need to use ToString() and ToNumber() but GD handles most of the conversion automatically. I still like to use them to make my intentions clearer.

In your case, your variable names were mixed. No biggy. We’ve all done that.

2 Likes

Thankyou! That fixed it, tysm

1 Like

Oh, thanks for clearing that up! And yeah, I’m pretty new to coding, xd :sweat_smile:

Thanks! I’ll check it out, sounds like it’ll be very useful for my project :+1: