User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

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

  1. #1
    Clicker Fusion 2.5 (Steam)

    Join Date
    May 2020
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

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

    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!

  2. #2
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Dec 2010
    Posts
    188
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    732
    Mentioned
    35 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Clicker Fusion 2.5 (Steam)

    Join Date
    May 2020
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)

    Inventaire.jpg

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

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    732
    Mentioned
    35 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    Clicker Fusion 2.5 (Steam)

    Join Date
    May 2020
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  7. #7
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    732
    Mentioned
    35 Post(s)
    Tagged
    0 Thread(s)
    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.

    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.

    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.

  8. #8
    Clicker Fusion 2.5 (Steam)

    Join Date
    May 2020
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    732
    Mentioned
    35 Post(s)
    Tagged
    0 Thread(s)
    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".)
    Attached files Attached files

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    732
    Mentioned
    35 Post(s)
    Tagged
    0 Thread(s)
    Here's an example of selecting the objects that have the right alterable value - counting only them - and then creating those objects on the second frame at random positions.
    Attached files Attached files

Page 1 of 2 1 2 LastLast

Similar Threads

  1. PHP saving loading values
    By warlords in forum Fusion 2.5
    Replies: 6
    Last Post: 11th June 2018, 02:53 PM
  2. Replies: 11
    Last Post: 10th May 2018, 08:43 PM
  3. Replies: 2
    Last Post: 3rd September 2017, 08:56 AM
  4. Replies: 2
    Last Post: 9th February 2017, 10:48 PM
  5. Saving and loading multiple objects on standard "Ini Object"?
    By EdibleWare in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 20th April 2016, 08:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •