Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Import Variables From .txt File?

I'm new to the forums, and I've examined the Sugarcube documentation, but unless I missed something, I'm not seeing any method of importing variables from an external file. Was hoping to have some data of a player's experience transferred to other instances of the Twine game being played. In this case, when the Twine story launched, it would initialize a certain set of variables with values located in some external file (like a text file). Is there any existing method of accomplishing this?

Comments

  • Does the Save to Disk/Load from Disk functionality not fit what you want to do?
  • If you're on about saving/loading savegames then the load/save feature is on the left hand side of the screen and will happily store variables.

    It is possible to reference external sources as there's a Twine script that loads verbs and nouns from an online database, but for anything custom I'm guessing you'd need to be able to write the Javascript to do whatever function you wanted or shuttle the data into Twine variables and then do it that way.
  • Yeah, no. I don't want to reinstate everything from a previous instance of playing the game like the save/load stuff would do. I wanted to be able to save only very specific data for export to another instance of the same game, but restart the rest of the game. In this way, I could play the game, pass the data from my game onto someone else, and then when they include that data file as they play the game themselves, elements of my actions would affect the world portrayed in their experience of the same game.

    I'm assuming there isn't any other method for this besides using Javascript? I mean, I could potentially learn the skills to do it, but if not, then I may just end up switching over to Game Maker as I've got a little bit of experience with it and GML. May be easier to complete the project that way.
  • In a way related, I'm searching for a way to save the game variables in a game and import in other, something let me make a single story in various files, like chapters.
    Manually, I can write some javascript that export state.history[0].variables in a text file and other that parse the json and set the variables again.
    There is some built in function for this or I'm reinventing the wheel?
  • Did anyone ever verify whether this was possible? Using Javascript to send state.history[0].variables to a txt file? Or some other method of data storage? This was -not- for the saving / loading of instances. I am working on a video game for communications research and I need to somehow retrieve the data the game collects on the player(s). It's dependent on both export and import of a txt file, or some analogous data storage file type.
  • I am looking to find out if this is possible myself, does anyone have any information?
  • Not sure if anyone is actually going to look at this, but I eventually found out that you can use jquery to send an AJAX request to a server-side php script that can then store and manipulate the variables sent using a series of html input elements (using them as name / value pairs by using their "name" and "value" attributes). Your server-side script can then do pretty much anything you want with them. echo data to a new file. Send the stuff to a database for queries. Dynamically load a new webpage based on the variables that are retrieved. The list goes on.
Sign In or Register to comment.