Howdy, Stranger!

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

SugarCube: Best way to replace references to "story" in built-in messages

What I am building is not a story or a game, and I'd like for there to be no chance of confusion when users see error messages such as "Apologies.  This story requires a less obsolescent web browser" or "Save is missing the required game data".  What is the best-practices way of replacing these references w/o resorting to editing the HTML file after building?

Comments

  • Well there are two files that would need to be changed if you want to do this 'pre-building' I think.

    One is the header file. Code.js if you're using vanilla headers, header.html if you're using Sugarcube.

    I believe you're also going to have to change engine.js in the Twine directory. If I were going to do this I'd make a backup (engine.js.old) and do a find replace for game and story with notepad++ or something. Make sure not to accidentally change the word history by accident.

    I THINK that would be all there is to it, but I can't be too sure without trying.
  • I'd like to be able to do it without hacking the header either, since I'm using SugarCube and it is frequently updated. But I suppose if that's the only good option... Kind of wish there was a Messages object that could be overridden from twee source as needed.

    I don't use Twine (I'm using Twee); I don't think that there is a file comparable to engine.js. I may have to switch to Twine eventually though (I doubt my colleagues would be willing to use a text editor); does engine.js really include messages that wouldn't be seen in a Twee game?
  • Generally only if theres a problem with the engine xD

    But yes, this is from engine.js. You may recognize it if you've ever worked with Twine and custom Macros.
    alert("There is a technical problem with this story ("+s.title+": "+e.message+")."+softErrorMessage)}}var softErrorMessage=" You may be able to continue playing, but parts of the story may not work properly."
    If any Twine/Sugarcube programmers are listening, I too would support a custom variable for something like this. Set a game variable in the beginning to a default (story) and be able to change it with something like $projecttype.
  • I see that message with my Twee WIP, but it seems to be generated by SugarCube (it's in the SugarCube source file main.js).
  • The SugarCube header distribution is not fractured into multiple files, there is only one: header.html.  Currently, the only good option would probably be to run a script which would read in the header, search & replace phrases (not individual words, you'll break something), and write out the "patched" header.
  • Some of the messages in SugarCube (and maybe in the vanilla headers too, I don't know) are maybe a bit snarky or confusing, at least for the audience I have in mind. For example I'd need to make "Apologies.  This story requires a less obsolescent web browser" much more helpful. It would be great if eventually there were a way to customize any message from source code (good for non-English stories too, obviously).

    Thanks for confirming!
  • Based on this thread I've decided to add a special "identity" StorySetting which contains the noun that the game uses for these messages:
    "There is a technical problem with this [story]" - error on script passage parsing
    "Sorry to interrupt, but this [story]'s code has got itself in a mess" - error during in-progress game
    "This [story] requires a newer web browser. Sorry." - error on IE7 (or any browser that doesn't support JSON or querySelector)
    "NOTE: This [story]'s HTML file contains embedded images that may be too large for this browser to display." - error on IE8 when images are used.
    "NOTE: The [story] contains a function that patches History.prototype.display, but takes the wrong number of arguments."
    "Are you sure you want to restart this [story]?"
    "Your browser couldn't save the state of the [story]."

    By default it's set to "game".
Sign In or Register to comment.