[Help] Saving/Loading alterable values from multiple instances of an Object

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello everyone, my first post here,
    I'm stuck.

    Here's my problem:

    I'm working on a little 2D A-RPG rogue-like game. I created an object called "weapon", with multiple alterable values (ex : Level, Power, Stamina, etc...). Sometimes, when my hero kills a "bad guy", an event activate : Creating an object "weapon" with randomly generated alterable values. (ex : Level : 2, Power : 5...). I can pick this "weapon" and add it to my inventory and my hero will get those alterable values. Everything works as I want. But now, I need to think about a way to save and load this "weapon" when I go to an another frame. I just need to save all the alterable values of the item and retrieve them when I go to another frame (or re-creating the same "weapon").
    And I searched for days to find a way to do it, without success...

    I read about Array, but I'm not sure if this is what I need (and how to use it for what I want to do). I tried to use the Save Game Object, but it doesn't work (maybe the fact that my "weapon" is an unique active object, but duplicated with different alterable values).

    If someone can give me some advices or ideas, I will be soooo grateful!

  • is your character a global object/ transferred from frame to frame? add appropriate hero values eg weapon level power etc and then add those values to the heroes base. if your character is global then everything should just transfer automatically.

  • How to achieve what JohnArtbox is saying -
    Click on your object - the properties will open - Under the red arrow - Runtime Options - there's a block you can tick under Memory Objects - that says "Global Object". If you tick that, then all the alterable values are remembered from frame to frame and you don't have to do anything further.

    However, if you want them to be saved after you close the game and then open the game again - you could save the data in an ini file - you save the values there at the end of a frame and load them from there at the start of a frame.

    Casual games: Please login to see this link.

  • My character is a global object, that is not the issue (His statistics are placed in a global object and he retrieve them when he need it)
    The problem is that the "weapon" i gave him on a frame disapear when I go to another frame, and so my hero lose the stats the "weapons" used to give him in the previous frame. Here is a screenshot: The colored ball are my "weapons" that i give to my hero from my inventory (right). If they are "equiped" they share their stats with my hero (left)
    So when I go to another frame, I need to save those equiped objects ad get them again, otherwise my hero lose his new stats.
    And as my "weapon" is just a duplicated object, but with other alterable value, I don't know how to save and re-create it the best way. I want to save each other "weapon" I have in my inventory too (left). (Each ball is a "weapon" with 10-12 alterable values that I need to save)

    Please login to see this attachment.

    EDIT : My "weapons" are not Global, because they mess with each other when I go to another frame.

    Edited 2 times, last by Kroutt (May 23, 2020 at 12:18 PM).

  • You can make your weapon global objects too - so that their alterable values are saved. Each ball can be its own object but they can have the same qualifier - and then you control them using the qualifier so that you don't have to re-code every entry.

    You can give your main character an alterable value - Equipped - and when he is equipped with a weapon that value changes to 0 for none, 1 for a blue ball, 2 for an orange ball etc. At the start of the next frame you can read what his equipped value is and create the matching weapon.

    Also you can save the stats that the weapon gives the player as alterable values for the player - or as global values - so that it's always saved with the player - for example

    Your player's main stats can be saved in a global value like so:

    Player's speed = 10
    Player's strength = 10

    Then give the player matching alterable values - so Current Player's speed and Current Player's Strength. Now when he picks up a weapon you change the alterable value to include the weapon, so now that changes to Current Player's Speed = 15 and Current Player's Strength = 15. When he puts the weapon down - you reload the Current values from the global values - which will put them back to 10.

    Then put your character's speed to always equal his alterable value of Current Player's Speed etc.

    Casual games: Please login to see this link.

  • For the second half of your advice : It's already like this, so my hero conserve the stats between frames, but he no longer have the weapon with him and the alterable value "equiped" still show me 1, so I can't even equip something else.

    I found out that if I make my balls Global, I need to create as much balls in the next frame that I got in the previous. They conserve their values, I don't know how... Maybe I should create a system that count how much balls I have and create as much balls at each frame?

  • Quote

    For the second half of your advice : It's already like this, so my hero conserve the stats between frames, but he no longer have the weapon with him and the alterable value "equiped" still show me 1, so I can't even equip something else.

    If you don't want this - you can at the start of the frame set Equipped = 0.

    Quote

    I found out that if I make my balls Global, I need to create as much balls in the next frame that I got in the previous. They conserve their values, I don't know how...


    Global objects save their values. If you don't want that feature - make them local objects - then you start with a blank slate each frame. You can copy / paste the objects between frames. Also you don't necessarily need them on screen - so if you copy and paste them into the frame area but off-screen, then their values and features are there for you to use.

    Quote

    Maybe I should create a system that count how much balls I have and create as much balls at each frame?


    Yes, that's quite easy to do with Fusion - there's already a function - count how many of the objects - at the end of the frame you can tell Fusion to count the objects and save the value in a global value.
    In the new frame run a loop to create the balls as many times as the amount in the global value.


    What you can do is make and upload an example .mfa of what you want to achieve and note the areas you're having a problem with - this allows us to change the .mfa for you, which might be easier than trying to explain it.

    Casual games: Please login to see this link.

  • I like the idea of Counting the objects at the end and re-create it in the next frame, I will go this way but I don't understand how counting works yet : I found "Compare to the number of "weapon" there is", but how can I get a number of how much "weapon" there are in the actual frame?
    Otherwise I add +1 to Global value "number of weapon I have in my inventory" and at start of a frame, I create a fastloop "create weapon X time" where X is my Global value, but I think there is a better way to achieve that

    EDIT : I found the NObject function but I want my Global value to retrieve only the number of "weapons" who have their alterable value A > 0. The other one have -1 because they appear on the frame but I didn't add them to my inventory.

    Edited 2 times, last by Kroutt (May 23, 2020 at 2:14 PM).

  • Here's an example of using global objects to check if an object was added to your inventory.

    In this example the objects are created at start - in other words - they are placed on the board in frame 1 for the player to pick up and placed next to the board in frame 2.

    This example will test to see if the player picked them up in frame 1 - and then placed them back on frame 2. If they were not picked up in frame 1 - they will be destroyed.

    (Click on any object in frame 1 to "pick it up".)

  • Thank you for your examples! I was doing something similar but not properly... So, for now, for each "weapon" I have in my inventory, there will be the same amount of "weapon" created in the next frame.
    The next problem is : They lost their alterable value, so they act like non-picked object (their first value determine if they are on ground, or in a slot in my inventory. When I go to the next frame, the "weapons" created have this value at "on ground"), so they aren't in my inventory and they don't have the same stats anymore. Is there a way for those new created "weapons" to retrieve all the alterable value they "had" in the first frame?

    I did the Global Object way, copy/paste all my "weapons" to all frames, but it doesn't work for newly created "weapon" dropped by a dead "bad guy".

    I'm trying save the alterable values of my "weapons" to my inventory slot (Global objects), and making them create "weapons" in the next frame and redistribute the alterable values they got previously
    (If this doesn't work i'll try to do an example mfa)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!