User Tag List

Results 1 to 7 of 7

Thread: How to handle sorting when Saving/loading levels with an array?

  1. #1
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    808
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)

    How to handle sorting when Saving/loading levels with an array?

    Wanting to rethink how i save and load my levels and I need some inspiration and help.

    Currently I have one game frame where all my code is and it loads the levels from an array on start, regular one frame method.

    I have a separate project where i build the levels in frames and and then save it to a master array file. Each level gets an ID and that ID becomes a Z-index in the array.

    I have a level select that loops through the array and looks how many Z-indexes it has and creates buttons for each of them.

    My issue is when I want to e.g. reorder two levels or for instance inject a level between the existing ones, it shifts all the IDs and I have no smooth way to do that other than manually changing the index and resaving the array for every affected frame.

    E.g. i have 10 levels, but i want to insert a level between 6 and 7. So i have to change the id of level 7, 8, 9 and 10.

    Does anyone have any suggestion on what to do?

  2. #2
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    785
    Mentioned
    51 Post(s)
    Tagged
    0 Thread(s)
    I use a global value named level control as a master - and this determines the level the player has reached. Beyond that I load a level's data at the start of a frame and save it at the end of the frame based on the level control.

    I have a start of frame event - set level control to frame + 3 (assuming I have 3 starter frames before the level starts) - and then everything is loaded and saved based on that level control value.

    That way you can insert or change the order of the levels and it doesn't matter.

    But I always use ini files. In cases where I don't specifically want someone to manipulate it, I save it with a calculation or a control value - they could figure it out, but it would take more effort than actually just playing the game.

  3. #3
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    808
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Janette5 View Post
    I use a global value named level control as a master - and this determines the level the player has reached. Beyond that I load a level's data at the start of a frame and save it at the end of the frame based on the level control.

    I have a start of frame event - set level control to frame + 3 (assuming I have 3 starter frames before the level starts) - and then everything is loaded and saved based on that level control value.

    That way you can insert or change the order of the levels and it doesn't matter.

    But I always use ini files. In cases where I don't specifically want someone to manipulate it, I save it with a calculation or a control value - they could figure it out, but it would take more effort than actually just playing the game.
    Hmm, how do you handle the room IDs though?
    Even if you let a Global Value decide whats going to be loaded you have to reference the room/level somehow, and lets say i injected a room between 4 and 5 I still have to shift all the room id's.

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    785
    Mentioned
    51 Post(s)
    Tagged
    0 Thread(s)
    If your level control is 10 - then you go to 'frame + 10' etc. When you get to frame 10 - the stuff is retrieved and stored for whatever was on that frame.

    Sure, while you're creating the game things will change - level 10 might become level 9 or level 11 - but the way I tie my levels to my frames it doesn't matter.

    I save as level + level control + additional name - I never have to change any code - because the level is calculated based on the frame position i.e. the frames are in level order.

  5. #5
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    808
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Alright, i think thats the main difference, my levels are one offs. You select it from a level select and then it loads it.
    Do u mind expanding on that last part? How u save the levels? ("I save as level + level control + additional name")

  6. #6
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module
    Janette5's Avatar
    Join Date
    Dec 2014
    Location
    Western Cape, SA
    Posts
    785
    Mentioned
    51 Post(s)
    Tagged
    0 Thread(s)
    If every one of your levels is a stand-alone - then you could save with groups - I'm attaching an example. Nothing is hard-coded with the save, everything is calculated - so you can freely move frames around.

    Your ini file would look like this then: (find it under Users\Name\AppData\Roaming)

    [LEVEL3]
    strength=10
    stuff=10
    more=10
    score=10
    [LEVEL2]
    strength=2
    stuff=2
    more=2
    score=2
    [LEVEL1]
    strength=1
    stuff=1
    more=1
    score=1

    If you don't want to work with groups then you'd save it like this instead:

    * Start of Frame
    Ini : Set current file to "abracadabra23"

    * Start of Frame
    Special : Set Level Control to frame - 1
    Special : Set Level Strength to ItemValue( "Ini", "strength" + Str$(Level Control) )
    Special : Set Level Stuff to ItemValue( "Ini", "stuff" + Str$(Level Control) )
    Special : Set Level Score to ItemValue( "Ini", "score" + Str$(Level Control) )
    Special : Set Level More to ItemValue( "Ini", "more" + Str$(Level Control) )

    * End of Frame
    Ini : Set value Level Strength to item "strength" + Str$(Level Control)
    Ini : Set value Level Stuff to item "stuff" + Str$(Level Control)
    Ini : Set value Level More to item "more" + Str$(Level Control)
    Ini : Set value Level Score to item "score" + Str$(Level Control)


    And your ini file would look more like this:

    strength2=2
    stuff2=2
    more2=2
    score2=2

    strength1=1
    stuff1=1
    more1=1
    score1=1
    Attached files Attached files

  7. #7
    Clicker Fusion 2.5Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    zip2kx's Avatar
    Join Date
    Jun 2015
    Posts
    808
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Thank you!
    Must have been tired yesterday so i didnt fully understand. This way certainly smooths the process, i would still need to loop through all levels after the injected level to shift the IDs, but I wont need to manually switch the numbers and I automated the process by making fusion go to the next frame automatically in Global events, so it's not too bad.

Similar Threads

  1. Saving & Loading Array Files in HTML5
    By drnebula in forum HTML5 Export Module 2.5
    Replies: 2
    Last Post: 26th January 2019, 09:01 PM
  2. Replies: 4
    Last Post: 24th March 2018, 05:14 PM
  3. [RC5] Saving and/or loading array files
    By colej_uk in forum Android Export Module Version 2.0
    Replies: 9
    Last Post: 11th March 2013, 12:49 AM
  4. Problem with array loading/saving with INI++
    By timcclayton in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 21st November 2010, 06:21 PM
  5. array object : saving loading
    By jpcr in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 15th February 2008, 02:31 PM

Posting Permissions

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