How to store large text

0 favourites
  • 6 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hey!

    I want to build a game, somewhat RPG-like.

    I need it to display rather large text, different text in more than one place. Ideally I would store this text separately in some XML or txt file.

    For example, I have a button "Intro", when the user clicks, they see a messagebox of sorts with some 3-4 paragrahps of text (some 200-250 words). They click OK, message box gone.

    Then they click Play, and are taken to a new layout, and another message box pops with another message, adding some more info to the story. In the new layout they click Help and see another message.

    All these messages I would like to have in one place where I can easily edit them.

    Can this be done in Construct 2?

    Thanks in advance.

  • Try out my Extra Expressions plugin, which has Base64 encode/decode capabilities.

    Just create your text in some text editor (without formatting, obviously), select all & copy into base64encode.org, encode and paste the resulting string into a variable or something.

    Then when you want to recall the text, simply use the decode expression where you normally enter the text.

    That way you can store large amounts of text in, say, an array (e.g. for each chapter) and pull it on demand.

  • Thanks Mipey! That sounds like it should work, but I was hoping for some more automatic solution, i.e. less manual steps when changing the story text.

    Any other ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, right now Construct 2 is pretty limited when it comes to implementing new features via plugins. It's still at a pretty early stage, I guess.

    It would be ideal to store the text separately, yes, however currently there doesn't seem to be any way to load these text files. At least all my attempts have failed. Javascript can't load files directly, it depends on external sources, such as querying server script and getting data with AJAX. And that doesn't work in localhost mode.

  • Did something really simple because I wanted the ability to easily edit large chunks of text:

    Created an Instance Variable for each block of Text to be used attached to just one Text Box.

    Each Instance Variable was named according to it's intended destination and/or scene - I used numbers and a 3 character scene code.

    Then used events to place text into just 3 text boxes that are reused throughout the game.

    I also used 7 different themes for directing how the text is displayed for a given scene

    There are over 400 text events and it works real quick with no major garbage.

    Couldn't use AJAX as the client required app to run offline.

    Didn't use an array as I didn't see the point of having to map out the event logic twice

    Hope this gives folk some ideas!

  • You might try storing the text as JSON. You could use this plugin to move it in and out of C2:

    http://www.scirra.com/forum/plugin-load-json_topic50331.html

    I think there's also some native support for JSON in arrays as of R87.

    To make the data easy to deal with, you could create a database and have it spit out text chunks in JSON format. If you use something like Ruby on Rails...

    http://www.rubyonrails.org

    ...you could create a basic CRUD app to handle the data pretty quickly. When you're ready you could output the data into .json files which you could store in a folder alongside the C2 code. Or, if you can store the database online, you might be able to access it with AJAX requests. I don't know much about C2's AJAx capabilities, though.

    There's some initial overhead with this method, but it would make data entry and keeping track of the structure much easier.

    Edit: There's also XML support in R87, and Ruby On Rails will spit out XML as well. XML has lots more overhead than JSON, though.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)