It’s still is.
This is the primary use of extensions. The fact that you use your own extension or ones shared by the community doesn’t change this.
Are you facing any issue with extension variables?
It’s still is.
This is the primary use of extensions. The fact that you use your own extension or ones shared by the community doesn’t change this.
Are you facing any issue with extension variables?
Thank you for responding.
To use a simple example, I made an extension for a game where you can exchange apples for gold using the normal scene variables Apples and Gold. Of course, in a real project, I might want to use many more variables with dynamic values.
In the screenshot, the top block of code uses the new way of altering variables, and it gets an error. But the bottom block of code uses the old method that I copied over from an older project (but which you can no longer get by using the “add action” prompt.) and it does what I want by altering the actual scene variables for Gold and Apples.
I also tried using the extension scene variables, but you cannot interact with them in the scene’s event page directly. For example, if I set Gold and Apples as extension scene variables, then I wanted to display those values using a text object in my scene, it doesn’t recognize the extension scene variables as valid in the expression builder.
So my question is how can I get the convenience and functionality of the Old Method using the new way.
…Thaz the same problem i’ve with custom objects…
The first question you should ask yourself when writing an extension is:
From your description, I guess it’s something like an inventory or resource manager and it’s role is to:
To do this I would:
To go further, I would :
The “simple inventories” extension that is not for from what you want to do. It may be useful to open it and take a look inside:
What does your extension do?
Which issues are you facing?
nope they’re not issue and not about extension.
I just was saying that even c.objects cannot interact with other scene/objects variables.
It’s not an issue i guess…but just a feature that would be great to have.
…
eg. i have a custom object lifebar that i can’t use cos i can’t check player’s variables…if not a child.
There is a custom object for life-bars in the extension list. The value of the bar can be set with an action from a variable value or anything else, so I don’t understand what you mean.
https://wiki.gdevelop.io/gdevelop5/extensions/panel-sprite-continuous-bar/
It’s not that. I know that works.
When you create a custom object from scratch you can’t read/refer to other variables (inside the custom object) that are not part of the custom object or its child cos as far as i can remember they give error…
if something changed i dunno…i’m gonna post some ss later…
Thank you again for the response.
I understand that you can make the extension variables manipulatable in the scene by creating an expression, and various actions to alter it.
But of course, this means that for each Extension variable you want to use in your scene, you need to
And sometimes, you might have to do this for dozens of variables, so it can balloon very quickly!
Whereas using the old method, if I wanted to edit or reference the variable in the scene, I could just do it directly in one step. Even if we could reference and manipulate extension variables without having to declare expressions and actions first, that would be a big help, but you can’t do that yet.
So at that point, it actually starts to feel less efficient to use the extension as a shortcut instead of just doing everything in the scene’s event sheet.
I understand that GDevelop has a reason for wanting to make things this way, even though I don’t totally understand the rationale myself. But from a casual developer’s point of view, it really feels like a feature I used to use a lot was made a lot more difficult and inefficient to use.
I’ve been using GDevelop for many years, and am a Gold tier subscriber and always sing its praises, so I don’t mean to come across as whiny or ungrateful, but this is one of the first changes where it feels like we’ve had something useful taken away.
Extensions are not tied to any specific scene so it’s impossible to use variables in expressions as we don’t know the variable types and also there can’t be any auto-completion.
One solution could be scene functions (basically external events with parameters), but I don’t know if it’s something that will be done one day because:
According to my experience, the function descriptions take a lot less time to write compared to the the events inside the extension and it’s not a loss because:
So you actually save time in the long run. If this is not the case, there is a good chance that the extension doesn’t completely fulfill its role (some logic is still in the scene when it should be in the extension).
Oh, boy! That depressing lost battle, so much lost potential
I think what you’re saying about scene extensions is what my main issue was.
Because a lot of my games exist only on one main scene (or different layouts of the same code), there’s never been a need for my extensions to be distinct from the scene events. But because most of the game was just one scene, there was a lot of code and repeated sequences, so the extensions were a very convenient way to make the project simpler and easier to read and edit. So I think external events with parameters would be a great solution, because that’s basically what I used my custom extensions to do in the first place.
But I appreciate the thought process of designing your project so the extensions are self contained and I will have to try to rethink my projects to work with that system.
One point I will bring up that makes that difficult is that implementing a custom extension midway through the project becomes very difficult. In other words, you have to know the scope of your game and each extension it uses before you start since everything in the extension has to be self contained.
If something gets too big in your scene code and you decide you want to make it its own extension, you have to go and scrub all references to that extension and rewrite your code since the two can’t naturally interact with each other.
Anyway, I appreciate all the answers and will try to learn how to use the new system most efficiently.
I have come from searching the internet and asking on the discord ‘how to access a global variable from within a custom extension’.
Consider this crudely drawn diagram.
I have a single global object
that contains much of the player's state
. My idea is to update this single global object
and ‘pass it down’ to other extensions.
(Those familiar with react or other component based frameworks may be familiar with this pattern)
My hope was that by doing this, I wouldn’t need to have multiple different extensions talking to each other, I could have them only talk to the global object
. This way they wouldn’t need to ‘know’ about any other extension. And further, I would potentially be able to extract arbitrary code into different extensions to clean up the event sheet.
The only way that I could think about how to update the global state from within an extension would be to access a global variable
.
I’m still new to G develop and I’m not even sure if this is an anti pattern. If there are better design patterns that fit the G develop paradigm, then I would love to hear about them.
If I understand, 2 extensions use:
The 2nd option sounds better to me because it allows to encapsulate the data with clear actions and expressions whereas the 1st option is a bit like making everything public
.
Sorry…but as an ignorant in coding engine there is something i don’t really get…
from ver 5.3 we are forced to declare all variables except locals, so to my point of view after declared they are stored in the project…always…
Why do i need to creat a global object which store my needed variables…or an extension that act like a bridge to bridge variables to whatever…
…where i’ ve alreadyt stored when i declared em… why i can’t just use them…in c.objects,extensions,or whatever i need?
…looks a bit redundant and inefficient imho…
but as i said it’s apoint of view of a simple user…
Do you have a precise use-case that we can discuss?
Some case happened to me these days…
i created from scratch a c.object made of 2-3 objects to simplify my event sheet…just to simplify cos in the latest ver i’ve bad ui refreshes
…as we argued before they need to be isolated from the scene…and…
I’m not against it…in fact they’re great…
but it’s a missed opportunity.
…imagine to create a fighting game…
…you then wan’t to create lifebars in the ui for stamina , magic, hps…ecc…
the first (most used by ppl) op0tion is to create an object for each bar
like
at beginner of the scene
trigger once----creat object lifebar
-----create object staminabar
-----create object manabar
…and…a whole page of event sheet.
now you want to trigger a dmg event to player…you can bcs you have access to all variables…
This is what 80% of users do.
now i guess… we agree that this is inefficient bcs c.objects release replaced at least the “creation” part of objects.
.the problem is that it ends here…
… whit the above method you can refer to all variables declared in the project if you need for example to subtract, add some values…you can’t if var are not of c.objects or its child.
.i guess you,Digidevice and Keith talked about this in firsts c.objects reletad threads…which a red a lot.
(there are many requests about this…mostly… posted just after c.objects release…)…i guess ppl didn’t really get the power of c.objects as mosts threads never talks about em…so i understand if they are underrated…as you know i too were sceptical
In my game i had to stop using them cos if i want to use them … i need to bind
my player too , (with all its vars), to custom object…
something which i absolutely don’t want bcs really inefficient…
this is just an example.
This for c.objects but i guess the same apply to extensions…
I’m not entirely sure I understand your question. I apologize.
I have a menu (extension1
) that shows the inventory of the player that also allows the player to equip four individual items
to four individual equipment slots
. (The sword and three hand slots)
I have some buttons (extension2
) that display which items
are equipped in their respective equipment slots
. When these buttons are pressed, It changes which type of attack the player can use.
My idea was to update the global state
from the first extension so that I can then pass it to the second extension so the second extension knows which items are equipped.
This is the first game dev project I’ve done that has any kind of complexity. I could really be doing this very wrong and completely against the grain of Gdevelop
’s strengths. I am extremely open to patterns that could be more idiomatic in the context of Gdevelop
.
Thank you for your time and patience.
I’m not completely sure I understand what you mean.
My motivation has been find an easy way for an extension to update some kind of structure and then that structure can be used in a different extension. Preferably without spaghetti code between the two. IE, the second extension would only need to be fed a structure that could come from anywhere.
I’m really sorry, I feel like I am over complicating this.
And I’m probably not understanding idiomatic design patterns specific to Gdevelop
. And further I apologize, because I’m not entirely sure that my problem is completely related to this topic.
it was a reply to my post.
Indeed, the question was for RMDB, but thank you, the explanations you gave will help.