User Tag List

Results 1 to 4 of 4

Thread: Saving Global String into an Array

  1. #1
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Feb 2015
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Saving Global String into an Array

    Hello, I will attach my current code below.

    I'm currently having an issue with saving my global strings into a string array; I have code that works for the global values, but that's easier most likely because it's already a numeric value.

    Mostly I don't know how to write the string into an array using the expression editor.

    stringsglobal.png

    Above I run the fast loops "write global strings", "write global values" 75 times each, and 75 times each as well for the loading fast loops.

    Using the loop I'd like to tell it essentially "Write the global string with index value of 1 into array", though the name of that string is "player is dead" or something.

  2. #2
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,397
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    You're getting the loopindex of "write global strings", on an event with the condition "on loop "write global values"" (and the same with loading). For that to work, you would need to be running nested loops (on inside the other), which I'm pretty sure you are not. Otherwise, the name of the loop from which you are retrieving a loopindex, needs to match the "on loop" condition.
    So basically, you should separate the code into separate events for strings and values (you could combine them by using the same loop name for both - eg. "save globals" - but it's not a good idea, as you might need to change the number of values or something later on).

    You also shouldn't save/load the array file on each loop iteration (it will work, but it's very inefficient). That should be in the same event that triggers the loop, so it only runs once, immediately before loading / after saving.

    And of course, make sure that the array objects have the correct settings - the global strings array needs to be a text array; the global values array needs to be a number array; both need to have a zero based index.

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,397
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Sorry, make that a 1-based index...

    eg.
    + User clicks on saveButton
    -> Start fastloop "saveGlobalVals", 75 times
    -> Start fastloop "saveGlobalStrs", 75 times
    -> ValueArray: Save file to wherever...
    -> StringArray: Save file to wherever...

    + On loop "saveGlobalVals"
    -> ValueArray: write value global value(loopindex("saveGlobalVals") + 1) to loopindex("saveGlobalVals")+1

    + On loop "saveGlobalStrs"
    -> StringArray: write string global string(loopindex("saveGlobalStrs") + 1) to loopindex("saveGlobalStrs")+1

    + User clicks on loadButton
    -> valueArray: Load file from wherever...
    -> stringArray: Load file from wherever...
    -> Start fastloop "loadGlobalVals", 75 times
    -> Start fastloop "loadGlobalsStrs", 75 times

    + On loop "loadGlobalVals"
    -> Set global value loopindex("loadGlobalVals")+1 to valueAtX("valueArray", loopindex("loadGlobalVals")+1)

    + On loop "loadGlobalStrs"
    -> Set global string loopindex("loadGlobalStrs")+1 to strAtX("stringArray", loopindex("loadGlobalStrs")+1)

  4. #4
    Clicker Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)

    Join Date
    Feb 2015
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help; The loops actually were nested, the reason it wasn't working was the oldest thing in the book... I would change a String and save it, and because the way my game works the changing of that String made me move frames - to a frame that I didn't yet paste the new Global Strings array to, so it would skip over the code since the object didn't exist.


    Quote Originally Posted by MuddyMole View Post
    You also shouldn't save/load the array file on each loop iteration (it will work, but it's very inefficient). That should be in the same event that triggers the loop, so it only runs once, immediately before loading / after saving.
    I thought the Array needed to be loaded for each loop. I guess not, thanks though I will try moving the save and load to the actual loop that calls the other fastloops to run.

Similar Threads

  1. Replies: 2
    Last Post: 8th September 2016, 05:14 PM
  2. Can't write to array from global string
    By Filip in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 6th September 2013, 06:36 AM
  3. Global array saving
    By mobichan in forum iOS Export Module Version 2.0
    Replies: 1
    Last Post: 12th March 2013, 11:07 AM
  4. Saving to array from a sub app
    By Windybeard in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 6th June 2012, 01:44 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
  •