Ink integration and savesystem (error)

Announcements, support questions, and discussion for the Dialogue System.
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Ink integration and savesystem (error)

Post by NotVeryProfessional »

Working on getting the Ink integration working with the SaveSystem and I get an error. To ensure it's not something strange in my scene setup, I opened the Ink Integration example and added a save system:

* add SaveSystem Prefab to Dialogue Manager
* add DialogSystemSaver Component to Dialogue Manager and set it as described in Tony's last posting here: https://www.pixelcrushers.com/phpbb/vie ... f=3&t=4566
* added a "load" and "save" button to the UI that simply call the SaveSystem Load/SaveSceneFromIndex(1)

The error is the same as in my game:

Code: Select all

Dialogue System: Lua code 'Variable={Alert="", Actor="Player", Conversant="Story", ActorIndex="Player", ConversantIndex="Story", wagerAmount=0, forceful=0, evasive=0, teacup=0, gotcomponent=0, drugged=0, hooper_mentioned=0, losttemper=0, admitblackmail=0, hooperClueType=0, hooperConfessed=0, smashingWindowItem=0, notraitor=0, revealedhooperasculprit=0, smashedglass=0, muddyshoes=0, framedhooper=0, putcomponentintent=0, throwncomponentaway=0, piecereturned=0, longgrasshooperframe=0, DEBUG=0, Story_story="{\"flows\":{\"DEFAULT_FLOW\":{\"callstack\":{\"threads\":[{\"callstack\":[{\"cPath\":\"\",\"idx\":0,\"exp\":false,\"type\":0}],\"threadIndex\":0}],\"threadCounter\":0},\"outputStream\":[],\"currentChoices\":[]}},\"currentFlowName\":\"DEFAULT_FLOW\",\"variablesState\":{},\"evalStack\":[],\"visitCounts\":{\"\":1},\"turnIndices\":{},\"turnIdx\":-1,\"storySeed\":95,\"previousRandom\":0,\"inkSaveVersion\":9,\"inkFormatVersion\":20}", Story_TheIntercept="{\"flows\":{\"DEFAULT_FLOW\":{\"callstack\":{\"threads\":[{\"callstack\":[{\"exp\":false,\"type\":0,\"temp\":{\"$r\":{\"^->\":\"start.waited.0.g-0.5.$r1\"}}}],\"threadIndex\":6,\"previousContentObject\":\"start.waited.0.g-0.11\"}],\"threadCounter\":9},\"outputStream\":[\"^\\"Well, then,\\" he begins, awkwardly. This is an unseemly situation.\",\"\n\"],\"choiceThreads\":{\"7\":{\"callstack\":[{\"cPath\":\"start.waited.0.g-0.4\",\"idx\":8,\"exp\":false,\"type\":0,\"temp\":{\"$r\":{\"^->\":\"start.waited.0.g-0.4.$r1\"}}}],\"threadIndex\":7,\"previousContentObject\":\"start.waited.0.g-0.4.7\"},\"8\":{\"callstack\":[{\"cPath\":\"start.waited.0.g-0.5\",\"idx\":10,\"exp\":false,\"type\":0,\"temp\":{\"$r\":{\"^->\":\"start.waited.0.g-0.5.$r1\"}}}],\"threadIndex\":8,\"previousContentObject\":\"start.waited.0.g-0.5.9\"},\"9\":{\"callstack\":[{\"cPath\":\"start.waited.0.g-0\",\"idx\":11,\"exp\":false,\"type\":0,\"temp\":{\"$r\":{\"^->\":\"start.waited.0.g-0.5.$r1\"}}}],\"threadIndex\":9,\"previousContentObject\":\"start.waited.0.g-0.10\"}},\"currentChoices\":[{\"text\":\"\\"Commander.\\"\",\"index\":0,\"originalChoicePath\":\"start.waited.0.g-0.4.8\",\"originalThreadIndex\":7,\"targetPath\":\"start.waited.0.g-0.c-0\"},{\"text\":\"\\"Tell me what this is about.\\"\",\"index\":1,\"originalChoicePath\":\"start.waited.0.g-0.5.10\",\"originalThreadIndex\":8,\"targetPath\":\"start.waited.0.g-0.c-1\"},{\"text\":\"Wait\",\"index\":2,\"originalChoicePath\":\"start.waited.0.g-0.11\",\"originalThreadIndex\":9,\"targetPath\":\"start.waited.0.g-0.c-2\"}]}},\"currentFlowName\":\"DEFAULT_FLOW\",\"variablesState\":{},\"evalStack\":[],\"visitCounts\":{\"\":1,\"start\":1,\"start.0.g-0\":1,\"start.0.g-0.c-0\":1,\"start.0.opts\":2,\"start.0.opts.0\":2,\"start.0.opts.c-1\":1,\"start.0.opts.c-3\":1,\"start.0.g-1\":1,\"start.waited\":1,\"start.waited.0.g-0\":1},\"turnIndices\":{},\"turnIdx\":2,\"storySeed\":69,\"previousRandom\":0,\"inkSaveVersion\":9,\"inkFormatVersion\":20}", CurrentStory="TheIntercept", WasPlayerSpeaking=false}; Item["The_Wager"].State="unassigned"; Item["The_Wager"].Track=true; Actor={Player={Name="Player", Pictures="[]", Description="", IsPlayer=true, Bark_Index=0}, Story={Name="Story", Pictures="[]", Description="", IsPlayer=false}, PlayerSpeaker={Name="PlayerSpeaker", Pictures="[]", Description="", IsPlayer=false, Display_Name="Player"}, Monsieur_Fogg={Name="Monsieur Fogg", Pictures="[]", Description="", IsPlayer=false}}; StatusTable = ""; RelationshipTable = ""; ' threw exception 'Code has syntax errors:
Line 1, Col 9 '=': Failed to parse Letter of Name.
Line 1, Col 9 '=': Failed to parse Name of VarName.
Line 1, Col 9 '=': Failed to parse 'nil' of NilLiteral.
Line 1, Col 9 '=': Failed to parse Text of BoolLiteral.
Line 1, Col 9 '=': Failed to parse '0'...'9' of Digit.
Line 1, Col 9 '=': Failed to parse (Digit)+ of FloatNumber.
Line 1, Col 9 '=': Failed to parse Name of VariableArg.
Line 1, Col 9 '=': Failed to parse firstTerm of OperatorExpr.
Line 1, Col 9 '=': Failed to parse Expr of ExprStmt.
Line 1, Col 9 '=': Failed to parse remaining input.
'
UnityEngine.Debug:LogError (object)
PixelCrushers.DialogueSystem.Lua:RunRaw (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:228)
PixelCrushers.DialogueSystem.Lua:Run (string,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:129)
PixelCrushers.DialogueSystem.Lua:Run (string,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Lua/Lua Wrapper/Lua Interpreter/Lua.cs:139)
PixelCrushers.DialogueSystem.PersistentDataManager:ApplyLuaInternal (string,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/PersistentDataManager.cs:261)
PixelCrushers.DialogueSystem.DialogueSystemSaver:ApplyDataImmediate () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/DialogueSystemSaver.cs:64)
PixelCrushers.SaveSystem:ApplyDataImmediate () (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:779)
PixelCrushers.SaveSystem/<LoadSceneCoroutine>d__107:MoveNext () (at Assets/Plugins/Pixel Crushers/Common/Scripts/Save System/SaveSystem.cs:756)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
save file attached (had to add a .txt extension so it lets me upload it)
Attachments
save_1.dat.txt
(4.04 KiB) Downloaded 121 times
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ink integration and savesystem (error)

Post by Tony Li »

Did you assign a unique key to DialogueSystemSaver?

I just tested the same thing, except since the scene already has a Demo Menu I just used that to save and load. (It calls SaveSystem.SaveToSlot and LoadFromSlot.) Instead of the SaveSystem prefab, I added a SaveSystem, JsonDataSerializer, and PlayerPrefsSavedGameDataStorer
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Ink integration and savesystem (error)

Post by NotVeryProfessional »

Yes, it has a unique key and I'm using the same setup, except that I use the disk and not the playerprefs storer.

I missed the demo menu. Tried to replicate it there. The error does not always show up, but once it does, it sticks. Might be something in the actual save game data.

Attached is my scene and the save game data. This for me 100% reproduces the error when I start the scene and press "load game" in the escape menu.
Attachments
Archiv.zip
(14.32 KiB) Downloaded 95 times
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ink integration and savesystem (error)

Post by Tony Li »

Thanks for the repro file. I'll check it out and get back to you by tomorrow morning.
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Ink integration and savesystem (error)

Post by NotVeryProfessional »

I'd try debugging it myself, but whenever it gets into the Lua parts, I understand not enough about it for that. As long as it's plain C# I'd try to be more useful in finding the root issue.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ink integration and savesystem (error)

Post by Tony Li »

Looks like Ink now generates JSON that the integration doesn't translate cleanly into a Lua string. I'll update the integration to include an InkSaver instead of using Lua.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ink integration and savesystem (error)

Post by Tony Li »

Hi,

The Extras page has a new Ink integration package (direct link) that adds an InkSaver script.

Add the InkSaver script to your Dialogue Manager, and set the Key field. The script will automatically untick the DialogueSystemInkIntegration's 'Include In Save Data' checkbox at runtime since InkSaver does the saving instead. I'm keeping the checkbox to support existing projects that are using older versions of Ink for Unity but it's otherwise basically deprecated by InkSaver now.
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Ink integration and savesystem (error)

Post by NotVeryProfessional »

Excellent. I've done a few quick tests and it seems to be saving everything correctly (including ink-internal states, such as visited knots) and without errors.
User avatar
Tony Li
Posts: 22161
Joined: Thu Jul 18, 2013 1:27 pm

Re: Ink integration and savesystem (error)

Post by Tony Li »

Great!
NotVeryProfessional
Posts: 150
Joined: Mon Nov 23, 2020 6:35 am

Re: Ink integration and savesystem (error)

Post by NotVeryProfessional »

Can I revive this topic to ask what the InkSaver should be saving and when?
And how should it handle variables that get initialized in the Ink files?

I have problems with both variables and visited knots. It may be related to the "save across scene changes" toggle, but either way I can't seem to get it save and load everything reliably when the game moves over several scenes.
Post Reply