Trying to follow tutorial, scene variable issues

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

Hi, I’m new here.

I am trying to follow the very first video tutorial, specifically the one titled ‘Beginner’s Guide To GDevelop - The No Code Open Source Game Engine’.

At 2:31 in the video, the video tutor creates a Score text object. If I understand the tutorial correctly, it’s just a normal text object.

Then at 4:04, they’re introducing the scoring mechanics via the scene Events tab.

They use the action of ‘Change the scene variable’.

I do not understand how I am supposed to do this.

I understand the logic behind what I’m supposed to do, but not how to find the command/action itself.

I have searched the in-app help, did a web search, and then searched the forums here, all to no avail.

Something else also confuses me about this.

I’m new to GDev and I don’t have much experience with it yet, but the tutorial appears to use a numeric function on a string/text variable.

That seems odd to me, so I tried replicating that and the program wouldn’t let me.

Assuming it’s not related to the ‘I can’t find change scene variable action’ issue, what am I missing here?

Click on the “Add action”, select the “Other actions” tab, expand Variables, expand “Scene variables”. Since it’s the score you want to change, you’ll want the “Change number variable” option.

Some languages have what’s called strongly typed variables. That means when a variable is declared as a number, string or another type, it can only be used as that.

GDevelop is weakly typed, which means you can declare a variable as a certain type, but if it’s contents satisfy another type, you can use it as that too.

A good example is a boolean - it’s either true or false. But, behind the scenes it’s stored as a 0 or 1. So GDevelop allows you to access it as a number. And, as a 0 or 1 can be represented as a string (“0” or “1”), you can access it like a string too. GDevelop will attempt to interpret it as the type that is used in the condition or action

(Actually, a boolean is false if it’s 0 or empty and it’s true otherwise, so you can set a variable to “2” or “A” and the expression to check the boolean value will come back as true).

Thanks for your reply! I’ll check this out later on tonight.

EDIT: Checked it out, you were 100% correct about where it was, so thank you :slight_smile:

However, it’s raised a different issue. I’d love some help with it if you have the time and energy. If not, no worries, and thanks for your help before. :slight_smile:

Short version is ‘The score doesn’t change’.

The pickup disappears and the sounds plays, but the score doesn’t change.

Apart from a few minor aesthetic details (Zoom level, using different gfx/sounds), I’ve followed the tutorial as closely as I could.

(There are supposed to be screenies of the video tutorial and my event page here, for comparison, but the forum is giving me grief, so I might have to reply with them. Point is they are identical - apart from the aesthetic choices and…)

The only difference I can see is in the final line:

Change the text of scene variable Score: set to “Score:” + ToString(Variable(Score))

In mine, the word ‘Score’ is blue, not purple. I don’t know the engine well enough to know if that means anything yet.

Here are some details you might need:

  • I didn’t declare (or add, via any variables page/tabs) any variables because the video tutor didn’t.

  • I tried doing it that way as well (adding a variable called ‘Score’) but that didn’t work either.

I thought strongly-typed variables were inherent to programming - I had no idea that weakly-typed variables even existed. My confusion has disappeared now. :slight_smile:

Your Boolean example was excellent, it made perfect sense - thank you so much!

Video Tutorial event page:

My event page:

Sidenote: As a new forum member I wasn’t allowed to post multiple pictures at once. This is why I’ve double/triple-posted.

This snip from the video updates the text of a text object:

This is your event - it’s updating the Score variable and replacing it with text:

BTW, you can use VariableString(var) instead of ToString(Variable(var)).