How do I save a random variable

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Ok, so I am creating a random character creation sheet which looks at a global variable such as var_Name and sets ones of the variable text to the text file I have on the layout using this

    tokenat(var_Name,floor(random(tokencount(var_Name,";"))),";")[/code:3mwzwluu]
    
    Now I have everything working so far but I need to find a way to save the randomly chosen information either locally or online or even both, so that I can allow the player to reload this data and be able to call it up & reference it in game, so my overall question, is there any way I can save a randomly chosen piece of text from a global variable into a savefile.
  • dop2000

    Thanks! Those are some good resources, but I am still a bit lost on

    Say I.E I have a global variable var_Name = "John; Sally; Joe"

    Now say the text choose Sally randomly out of that, how would I save that specific information is what I need to know, I went threw most of that information you gave and I can't seem to figure that part out :#

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • When you select your random name "Sally", put it into some other variable, say PlayerName . Then write this variable to the Local Storage.

    When player starts a new game do this:
    PlayerName=tokenat(var_Name,floor(random(tokencount(var_Name,";"))),";")  // select random name from the list
    playerNameText Set Text to PlayerName  // update text on the layout
    LocalStorage set "PlayerNameKey" to PlayerName  // save name to local storage
    
    When player loads saved game:
    retrieve "PlayerNameKey" from Local Storage into the variable PlayerName (see tutorials on how to do it properly)
    playerNameText Set Text to PlayerName  // update text on the layout[/code:12syfi2x]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)