Minetest and Twine (or Ink)

Post Reply
User avatar
Erdbeere
Member
Posts: 67
Joined: Tue Oct 31, 2023 10:45

Minetest and Twine (or Ink)

by Erdbeere » Post

If Minetest is really to be taken to a higher level as a game engine in order to gain more worldwide attention and stand out from similar projects, then it needs to get a tool that can be used to easily create interactive games. The player can already interact excellently in a given world, but the world (a self-contained game) has not been so easy for him.

I see an excellent opportunity in this direction in the integration of Twine into Minetest. This would allow the environment to come into direct contact with the player. Game designers can write real game sequences with the help of Twine and Minetest could incorporate and display them in the game, either in the HUD or with the help of NPCs.

http://twinery.org/
Last edited by Erdbeere on Sat Feb 17, 2024 18:01, edited 2 times in total.

User avatar
Blockhead
Member
Posts: 1548
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Minetest and Twine

by Blockhead » Post

I tried it earlier. It seems like a decent way to make interactive fiction and publish it for the web, but the way it's tied to the web and JavaScript or a macro language would make it quite a different beast to Minetest. I also have a hard time seeing how a story written in it could adapt to Minetest.

Maybe I'm ignorant, but twine looks like a series of linked story pages and links between them, as well as JavaScript & macros to handle making a "game" out of the story, whereas Minetest is a 3D world with a player avatar. This is a very different input method.

I can only assume you're looking for a way to write objectives, quests and that sort of thing into the game world. Something that would fit into a larger system along with mods like yl_speak_up that you have been discussing lately. It is not a bad idea to have that, but I'm not sure how much reuse we can make from Twine.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
Erdbeere
Member
Posts: 67
Joined: Tue Oct 31, 2023 10:45

Re: Minetest and Twine

by Erdbeere » Post

Before we throw up our arms here, JavaScript and HTML are evil and we can't do anything with them in Minetest, let's take a closer look at Twine. Twine is a full-fledged tool that allows you to design, save, and share stories. The storage format is twee, which is a type of markup and a plain text format. See https://github.com/iftechfoundation/twi ... ication.md

For the purposes of Minetest, you can scale back the story formats so far that a corresponding interpreter in Minetest can handle it. So you don't have to use the fancy format, but a simple format like this https://twinery.org/2/#/story-formats simple Paperthin or you can create your own format for Minetest, depending on the possibilities.

The advantages are obvious. Twine is established, it is translated into several languages and there are many users and correspondingly many introductory videos on Youtube etc. It's easy to use, you can prepare and test your stories outside of Minetest. It's easy to share and save existing stories.

Yes, I personally would like to use it to write the dialogues of NPC quests and even in different languages if possible. Such a tool would make the work extremely easier. This would make much more exciting quests possible. But why shouldn't a place or a specific node be able to "talk" to the player when I get close to them? The server rules could be integrated well and much more.

And why shouldn't the existing users of Twine also try to experience their previous text stories in a living 3D world? Minetest would be a great tool for them and I already see a lot of new games coming our way.

User avatar
Erdbeere
Member
Posts: 67
Joined: Tue Oct 31, 2023 10:45

Re: Minetest and Twine

by Erdbeere » Post

By the way, if you think my idea is totally absurd, you should at least take note of the fact that other real game engines use such tools, such as Unity's tool Ink https://www.inklestudios.com/ink/
Here are some ways you can use Ink in Unity:

Dialogues and Story Branching: Ink is well-suited for presenting dialogues and story branching in games. You can create complex dialogues that respond to player decisions and influence the course of the story.

Narrative Games: Ink can be used for developing narrative games where the plot and player decisions play a central role. The tool allows for a flexible narrative structure and easy adjustments to the story.

Quests and Objectives: If your game involves quests or objectives, you can use Ink to define various options and outcomes for each quest. This facilitates the management of complexity and branching in the narrative.

Text-based Games: Ink is also suitable for developing text-based games where the focus is on the plot and storytelling. It enables the creation of text adventures with different paths and endings.

User Interface Creation: Ink can be used for creating custom user interfaces that respond to the story and game progression. This could include animated text boxes or displays for player decisions.

nqnstudios
New member
Posts: 6
Joined: Sat Feb 17, 2024 01:40
GitHub: nqnstudios
In-game: NatQuayle

Re: Minetest and Twine

by nqnstudios » Post

I'm glad you mentioned Ink. I've used it (and I've used Twine) and even contributed to some of the ports of Ink to other programming languages than C#. I think Ink would be much better for integrating with Minetest because it's designed to be embedded in other engines. A port of Ink to C++ exists, which could be used to integrate Ink with Minetest: inkcpp

Whereas integrating Twine in Minetest would involve implementing a Twee interpreter from scratch, integrating Ink would entail linking the build against Inkcpp and coding UI around it.

User avatar
Erdbeere
Member
Posts: 67
Joined: Tue Oct 31, 2023 10:45

Re: Minetest and Ink instead of Minetest and Twine

by Erdbeere » Post

So I'm not fixated on Twine now. That was just the way it was, I had tried it and right away it worked and brought a good result. If Ink offers the same in terms of functions and should be an even better fit for Minetest, as well as there is nothing against it in terms of licensing, then Ink would be happy to do the same.

nqnstudios
New member
Posts: 6
Joined: Sat Feb 17, 2024 01:40
GitHub: nqnstudios
In-game: NatQuayle

Re: Minetest and Twine

by nqnstudios » Post

I just found there's also a Lua implementation of Ink, so it could be integrated in Minetest as a mod rather than a C++ engine feature.

(I can foresee that Ink support might be a little too left-field to merge into Minetest, so having it as a mod would prevent making someone maintain a Minetest+Ink fork.)

User avatar
Erdbeere
Member
Posts: 67
Joined: Tue Oct 31, 2023 10:45

Re: Minetest and Twine

by Erdbeere » Post

What is a mod today can still be permanently installed tomorrow. A mod would be wonderful and your link looks very promising. Now you just have to find someone who could make a lot of fame for Minetest with such a mod.

nqnstudios
New member
Posts: 6
Joined: Sat Feb 17, 2024 01:40
GitHub: nqnstudios
In-game: NatQuayle

Re: Minetest and Twine (or Ink)

by nqnstudios » Post

I don't know if it'll make Minetest famous unless someone creates an extremely well-written Ink/Minetest game that goes viral. Let's keep the expectations realistic :P

User avatar
Erdbeere
Member
Posts: 67
Joined: Tue Oct 31, 2023 10:45

Re: Minetest and Twine (or Ink)

by Erdbeere » Post

Sorry, that was my translation tool. I am a native German speaker. I meant more the fame in the Minetest community. I would like to give a few Euros for a mention in the Readme.md so that I can also get some of this fame. I'm serious.

nqnstudios
New member
Posts: 6
Joined: Sat Feb 17, 2024 01:40
GitHub: nqnstudios
In-game: NatQuayle

Re: Minetest and Twine (or Ink)

by nqnstudios » Post

Ah, I see what you mean. Well I've been wanting to get into Minetest modding for a long time and I had been thinking about Ink integration for sure. Maybe someday I'll find the time to do it.

User avatar
LMD
Member
Posts: 1382
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: Minetest and Twine

by LMD » Post

nqnstudios wrote:
Sat Feb 17, 2024 17:21
I just found there's also a Lua implementation of Ink, so it could be integrated in Minetest as a mod rather than a C++ engine feature.

(I can foresee that Ink support might be a little too left-field to merge into Minetest, so having it as a mod would prevent making someone maintain a Minetest+Ink fork.)
This is most probably preferable. We're pretty reluctant to add engine support for something which probably only part of the userbase needs if it can be done using a mod just as well.
My stuff: Projects - Mods - Website

Sokomine
Member
Posts: 4275
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Minetest and Twine (or Ink)

by Sokomine » Post

nqnstudios wrote: I just found there's also a Lua implementation of Ink, so it could be integrated in Minetest as a mod rather than a C++ engine feature.
Thank you! That's a very useful hint. I've taken that implementation and made it work in Minetest. That mostly required getting rid of the require(..) and converting to dofile(..). The mod narrator can be found here.

Stories written in Ink need to be converted into an intermediate lua format first. By default that narrator program does that automaticly. But as requiring an external library is a bit problematic in MT it's probably best to convert the story manually first anyway.

The stories can then be run via a chatcommand "/ink" or via the d_dynamic dialog target of yl_speak_up.

It was astonishingly difficult to find example stories. The intresting story 'TheIntercept' crashed early on, and mostly only pretty simple examples worked. Some features of ink do not seem to be supported by narrator yet (as is stated in the readme). That might not pose too big a problem - people new to it will most likely not use the most complex language structures.

The crashes and general security are a problem for servers. It won't be possible to upload the lua file of an ink story and just let it run on a server if a crash is likely. It is, however, a good option for standalone adventure games.
nqnstudios wrote: I'm glad you mentioned Ink. I've used it (and I've used Twine) and even contributed to some of the ports of Ink to other programming languages than C#. I think Ink would be much better for integrating with Minetest because it's designed to be embedded in other engines.
You seem to have far more experience with this than I do. Perhaps you can answer me some further questions?

First of: The general structure for what ink seems to call "knots", Twine "passages", simple_dialog "topics", yl_speak_up "dialog names" etc., including ways to switch to other such elements, more or less boils down to beeing very very similar. This is no big surprise as such a schem even pops up more or less automaticly when trying to write such a branching story or dialog tree by hand in a normal editor. This element alone might already be worth the effort and help writers of stories a lot.

Handling of variables and conditions is of course more complex. Narrator handles the variables and states (which knots visited etc.) on its own - so no problem there (apart from it having to be saved somehow in longer games; and how will it fare in multiplayer?).

What about quests where more than one NPC participates? Guess a main knot that just branches off to "talking to NPC A", "talking to NPC B" etc. might do the job. Guess that is what those "tags" may be good for as well?

An adventure game may have a main story line with some sidequests. The situation on a develloping multiplayer server with many diffrent players (hopefully) contributing small and big stories is a bit diffrent. There is no *one* main story line there. With the yl_speak_up NPC, players can create their own small quests. Is Ink able to handle multiple running stories in parallel?

Perhaps in the end I might still need an intermediate, massively simplified version of the ink format that players on servers can safely upload in order to update their NPC and where there's no danger of crashes.

I wonder if there are tools to convert ink files from one "writing style" into another? I.e. switching from the "weaving" writing to an "all knots" based version?

Some elements like repeating and modifying/extending the text of the selected answer when printing it is a fine feature but may be less relevant for talking to NPC.
A list of my mods can be found here.

nqnstudios
New member
Posts: 6
Joined: Sat Feb 17, 2024 01:40
GitHub: nqnstudios
In-game: NatQuayle

Re: Minetest and Twine (or Ink)

by nqnstudios » Post

I do have experience with Ink and some of its ports, but I've never done Minetest modding, just fiddled around with a few different games. So I didn't know about yl_speak_up or npc_talk until just now.

Since you're having trouble finding examples, I'll send you a private link to the Ink files of a game I made. You can use them for testing if you want, but don't share them with anyone or commit them to your repository please.
The crashes and general security are a problem for servers. It won't be possible to upload the lua file of an ink story and just let it run on a server if a crash is likely. It is, however, a good option for standalone adventure games.
Can you just run all Narrator calls in a try/catch and report the errors safely without crashing Minetest? I assume Lua has try/catch -- it's been a long time since I used it.
Handling of variables and conditions is of course more complex. Narrator handles the variables and states (which knots visited etc.) on its own - so no problem there (apart from it having to be saved somehow in longer games; and how will it fare in multiplayer?).
It looks like to save the state in longer games you'll want to use the save_state() and load_state() functions, and serialize/deserialize the output in your mod to whatever format Minetest uses for saving persistent data. In multiplayer you would probably make a new instance of the Book object for each player, and treat the dialog/quest state on an individual basis like World of Warcraft does--i.e. if one player talks to an NPC and changes the quest state, it *does not* change the state for anyone else. I think managing a global server state of all dialog and quest flags would be too intense. Maybe people would want to do quests in parties, though--but that's still super complicated because I wouldn't know how to sync the dialog UI to each player. Maybe how Divinity Original Sin 2 does it, where 1 player is driving the dialogue and the others in the party have to listen in? If it were me, I would stay far away from these complicated cases and start by making the mod for singleplayer adventure games in Minetest.
Is Ink able to handle multiple running stories in parallel?
It looks like that would be Multiple Parallel Flows, which is not supported in Narrator right now, but is supported by the full Ink language. This wasn't a feature of Ink back when I was using it so I have no expertise about it. Here's the Ink documentation for that feature.

There's something I missed before, which is that there are 2 options for running ink in Lua. Narrator doesn't support multiple parallel flows, but defold-ink does: https://github.com/abadonna/defold-ink

You could make a careful comparison of Narrator vs Defold-Ink and decide whether to scrap your Narrator-based mod to use Defold instead.

You may have already seen this, but this is the tutorial where I learned most about Ink: https://github.com/inkle/ink/blob/maste ... WithInk.md

Sokomine
Member
Posts: 4275
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Minetest and Twine (or Ink)

by Sokomine » Post

nqnstudios wrote: I do have experience with Ink and some of its ports, but I've never done Minetest modding, just fiddled around with a few different games. So I didn't know about yl_speak_up or npc_talk until just now.
Minetest modding is pretty easy. As to yl_speak_up and npc_talk: I've been working on them for quite a while and released them just recently. Both mods together allow to edit what NPC say. It's very similar to inks' knot-based approach - with text the NPC says and dialog options (in ink: diverts) to choose from. Plus some things the NPC can do that follow from the world they "live" in (access inventories, check and change state of blocks, variables, ...).
nqnstudios wrote: Since you're having trouble finding examples, I'll send you a private link to the Ink files of a game I made. You can use them for testing if you want, but don't share them with anyone or commit them to your repository please.
Thank you! That's a big help to see how far narrator gets. So far it seems to run mostly fine, although it eventually ends in crashes as well. That I won't share those files goes without saying.
nqnstudios wrote: Can you just run all Narrator calls in a try/catch and report the errors safely without crashing Minetest? I assume Lua has try/catch -- it's been a long time since I used it.
No need. The command line version crashes as well at the same points.

So far I've managed to get the story cloak_of_darkness running by changing "{not(has_cloak)}" to "{not has_cloak}". The story TheIntercept failed when trying to evaluate the functions lower(..) and raise(..) because its parameter evaluated to nil. Replacing those function calls got me a bit further but still lead to crashes/premature ends later on. Also missing knots lead to crashes.
nqnstudios wrote: In multiplayer you would probably make a new instance of the Book object for each player, and treat the dialog/quest state on an individual basis
Yes, that seems the most reasonable approach. I'm not sure how well it will scale if there are multiple small stories running per player. Also not so easy to figure out the right time in the game for saving/restoring.
nqnstudios wrote: Maybe people would want to do quests in parties, though--but that's still super complicated because I wouldn't know how to sync the dialog UI to each player.
That's indeed complicated. It could be done, but...players might not be overly pleased if they loose a fight against a monster because their teammate did choose that point in time to talk to an NPC who wanted to send on information and made the text pop up unexpectedly.
nqnstudios wrote: If it were me, I would stay far away from these complicated cases and start by making the mod for singleplayer adventure games in Minetest.
For singleplayer adventure games it's already usable. Ok, minus the saving of the states that I havn't added yet. And only to the extend that narrator handles.

Real multiplayer quests would of course be great. But also very difficult to create. The problem is more that multiple players will want to write diffrent stories - with players beeing in diffrent stages. Might be tricky to handle on a server. Especially if NPC take part in diffrent quests.
nqnstudios wrote: There's something I missed before, which is that there are 2 options for running ink in Lua. Narrator doesn't support multiple parallel flows, but defold-ink does: https://github.com/abadonna/defold-ink

You could make a careful comparison of Narrator vs Defold-Ink and decide whether to scrap your Narrator-based mod to use Defold instead.
Seems to be worth a look. Narrator seems to be able to handle quite a lot but not all.
nqnstudios wrote: You may have already seen this, but this is the tutorial where I learned most about Ink: https://github.com/inkle/ink/blob/maste ... WithInk.md
Yes, thanks. I've found and read that already. Though I couldn't find any information on how to escape characters - like when you want a litereal "=" or "[" or "{" etc. in your text. Seems "\" doesn't do it? My plan is to export the NPC .json format to ink (so the other way around) in order to see how well that can be done and how understandable that format will be for readers.

I still see no way for players to upload ink files on a multiplayer server and running them safely. But it's great for singleplayer adventures.
A list of my mods can be found here.

nqnstudios
New member
Posts: 6
Joined: Sat Feb 17, 2024 01:40
GitHub: nqnstudios
In-game: NatQuayle

Re: Minetest and Twine (or Ink)

by nqnstudios » Post

Sokomine wrote:
Wed Feb 21, 2024 23:43
nqnstudios wrote: Can you just run all Narrator calls in a try/catch and report the errors safely without crashing Minetest? I assume Lua has try/catch -- it's been a long time since I used it.
No need. The command line version crashes as well at the same points.

...

I still see no way for players to upload ink files on a multiplayer server and running them safely. But it's great for singleplayer adventures.
The reason I suggested the try/catch safety checks is not to make testing easier, it's actually so that if you do figure out a way for players to upload files, they can do that & if their scripts have errors, it won't crash the server.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests