inkle / ink

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

How to get INCLUDEd variables to be written by state.ToJson #856

Open lhughes41 opened 11 months ago

lhughes41 commented 11 months ago

Greetings, I understand the basic idea of how to write/save a Story state. Namely: ...state.ToJson()

However I just discovered that variable brought into the Story object via an INCLUDE do not seem to get saved! I looked at the json produced to confirm this. Variables coming from the master file that called the INCLUDE do get written. Just not the ones in the INCLUDE. This is extremely unfortunate as we isolated all our variables across multiple Story(ies) in an INCLUDE. Is there some way to signal to 'To.Json' to include all variables? Namely and especially the INCLUDEd ones?

Thanks in advance. Luke Hughes lead (Burden of Command)

joningold commented 11 months ago

They absolutely do. Includes have no meaning to the compiler; the files are stuck together into one big blob. What you might be seeing is that until a variable changes it isn’t in the save data as we save a diff of the state against the initial state

lhughes41 commented 11 months ago

Thanks for the rapid response Jon. That was my understanding of how INCLUDE worked too. So was surprised. But perhaps it is the delta aspect as you say. Let me dig on that basis.

this overall is good news though if plays out way you say. Whew! Luke

joningold commented 11 months ago

I promise you if you still have an issue it isn’t due to including, the compiled format knows nothing about include structure. --

-- Jon Ingold Narrative Director, inkle @joningold, @inkleStudios http://www.inklestudios.com

lhughes41 commented 11 months ago

Jon I believe you. But having too many learned lessons about not testing ...;-).. I tested. And I am happy to confirm you are right. So am closing out.

Impressed with the rapid Jon response team around here ;-)

p.s. minor comment for future. Had to do a lot of workarounds and scripts to rebuild all our independent inks everytime an INCLUDE file changes (because globbed into the main ink files as you say). Any plans for future for such includes not to be globbed in and instead dynamically imported? I come from a Python (and LISP of all things) world where files are imported on the fly and so there is not a lot of recompiling everything when an imported file is changed. More modular IMHO. But like I said I am naive for less interpreted worlds (been many a day since I did C etc).

And here I am harrassing up a kind programmer with yet more improvement suggestions LOL. I get so tired of being on the receiving end of those myself ;-) So apologies.

best, Luke

IFcoltransG commented 9 months ago

@lhughes41 Is this issue ready to close?

lhughes41 commented 9 months ago

Yes thanks.