inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
4.05k stars 485 forks source link

Modding: Using multiple compiled ink assets during same runtime #333

Open jjsonick opened 7 years ago

jjsonick commented 7 years ago

So I'd like to use ink for dialogues and narration in a text-heavy CRPG I'm developing in Unity. I'd also like to give strong modding powers to players of the game, including creating their own dialogues.

After loading a game-default compiled ink asset ( _inkStory = new Story(inkAssetDefault.text); ), can you load a separate compiled ink asset into the same object ( _inkStory = Story(inkAssetMod1.text); ), have it do its thing, and then re-load the default one ( _inkStory = Story(inkAssetDefault.text); ) -- while tracking the knot position in any given ink asset and all gameworld state variables on the unity C# side, accessing these gameworld state variables via external functions, etc? Basically, holding all world-state and which-knot-should-we-go-to-when-this-inkfile-is-loaded data on the Unity game side (this would include doing saving and loading only on the C# side, too) and swapping out different ink assets to run different dialogues/scenes during runtime? This would allow modders to create their own compiled ink scenes/dialogues that could be loaded and unloaded at will by the game engine.

Or does the ink unity runtime have to function on just a single ink asset loaded once?

clembu commented 7 years ago

You do not have to use a single asset, no.

But if in the code you do this:

_story = new Story("file");
_story = new Story("other file");

you're going to overwrite your story data. So you're going to have two variables.

The "issue" with that is, it won't be the same story, so what you do with your default main quest won't affect the custom ones, and vice-versa.

I personally don't think that's a huge problem, but it can limit the storytelling. The sadder and bigger problem is that if you have 1 ink file per mod quest loaded, you could end up with a bloated memory, if they're a tad too big. Kind of like huge Skyrim mods.

My personal advice would be to recompile the story into a single ink file when your players add mods. Have a modding tool that adds INCLUDE mod-author_mod-name_quest-id.ink in your main ink file or something, and then recompile, and then you will be able to have the side quests as knots and stitches in your story.

But I would love to hear thoughts about this from more experienced devs out there.