Is there a way to "include" content from an external URL into a passage?

I’m using twine 2 / SugarCube 2.36.1.

Is there a way to “include” content from an external URL into a passage? I’m imagining an emulation of something along the lines of:
<<include [[From external website|]]>>

If something like this could work, how would the called-in external webpage need to be formatted?

I did do a search for existing advice but couldn’t find anything. I might not have used the right search terms.

Just use an iFrame.

It’s doable, though not recommended, since it wouldn’t work if the person was playing your game offline or the site was down. Also, even when it does work, keep in mind that the text would take a variable amount of time to load, thus your game may appear to lag. The data may also be cached by the browser, so even if that content is updated, the user may still see the old data if it’s cached in their browser.

An <iframe>, as mentioned by vessi, could work, though it may not be ideal, depending on your use case.

If you could explain Q1.) exactly what you’re trying to do, Q2.) what kind of content you’re trying to access, Q3.) if you have access to your own server where you’re pulling your data from or if it’s someone else’s server, and Q4.) whether your game is going to be located on the same server as the content you’re trying to access, then people might be able to suggest a better method to do what you want.

I’m not quite clear what you mean by “formatted” here. Q5.) Do you mean the format of the content (e.g. HTML, XML, JSON, etc.), how it’s styled, or something else? Please clarify.

The answer depends on the method used. For an <iframe> it would be best if it were an HTML page.

Please let us know the answers to those five questions above so we can try to help. :slight_smile:

Starting with your implicit Q0) (What is my use case?): I am building an intelligent strategic planning adviser (ie. not a game or a story). The current prototype has a large amount of text in a large number of passages that are linked to as background/context. The Adviser will be part of a new website. My plan is to pull out the background material into a database so it can be called for use in other parts of the website (eg. standard web pages, a collaboration wiki and the Adviser. The website/adviser project is part the outreach of a not-for-profit organisation.

Q1.) I would like to be able to use text chunks from the database to populate twine passages in the adviser or to inject text into points within twine passages - as one can do using within-project passage content using ≪include≫.

Q2.) The content I’m trying to include would be “rich text” that could include tables and embedded graphics. We haven’t decided on the technology for the database yet.

Q3.) The prototype adviser is currently being hosted by github and is accessed via the url that will be used for the multipart website. We will need to migrate to a new host as the various elements of the website come together. Pretty much all the decisions around that are still to be made.

Q4.) It’s not yet decided whether all the website elements will be hosted on the one server or whether some of the key elements (database, collaboration wiki) will be accessed from providers with their own server. That all depends on tech stack decisions that have not yet been made.

Q5.) “Do you mean the format of the content (e.g. HTML, XML, JSON, etc.), how it’s styled, or something else?” I was thinking about both the format of the content and its styling. I’m assuming that if the database content is to be used in a range of web environments it probably shouldn’t include twine markup but equally it should not contain markup or script that cannot be dealt with by a twine2/sugarcube generated .html file - unless it’s worth the bother of creating a translation utility to pass compatible content to the twine adviser.

I hope that covers what you need to know to make sense of my request! Thanks.

Would this approach be a suitable model for what I’m trying to do? (apart from the irrelevant issue of restricted content)

1 Like

It appears that Mr. Sutton has passed away. I hope that there is someone else to take on his work going forward.

Sorry to hear that Philip Sutton died, I had the same thoughts he did and I hope his work lives on.