You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am struggling trying to save and load my story, but the story I reload fails with some weird error.
More specifically, I do this:
var story = Compile();
var json = story.ToJson(); // serialize
var story2 = new Story(json); // deserialize
var json2 = story2.ToJson(); // serialize again
var story3 = new Story(json2); // deserialize again
"story" and "story2" can be run with no issue. Running "story3" produces an error.
I also observe that json and json2 are different
I included a minimal example below.
Any idea of what I am doing wrong? Thanks for your help :)
class Program
{
const string rawink = @"== mytestknot ==
-> hello
= hello
Hi, {hello>1:still} no issue there.
// not that the problem diseapear if I remove {hello>1:still}
+ bla
-> DONE
";
static Story Compile()
{
var compiler = new Ink.Compiler(rawink);
var story = compiler.Compile();
return story;
}
static void Check(Story story)
{
story.ChoosePathString("mytestknot");
try
{
var str1 = story.ContinueMaximally();
Console.WriteLine(str1);
}
catch (Exception e)
{
Console.WriteLine("Failed");
Console.WriteLine(e);
}
}
static void Main(string[] args)
{
var story = Compile();
var json = story.ToJson(); // serialize
var story2 = new Story(json); // deserialize
var json2 = story2.ToJson(); // serialize again
var story3 = new Story(json2); // deserialize again
// the json do not match ?!
Console.WriteLine($"json==json2 {json == json2}");
// no more changes in the jsons
var json3 = story3.ToJson();
Console.WriteLine($"json2==json3 {json2 == json3}");
// chack that no story has errors
Console.WriteLine( $" any errors? { story.hasError} { story2.hasError} { story3.hasError}" );
// initial story works
Console.WriteLine("inital story");
Check(story);
Check(story);
// story deserialized from first json works
Console.WriteLine("story deserialized from story.ToJson");
Check(story2);
Check(story2);
// story deserialized from json2 fails
Console.WriteLine("story3");
Check(story3); // This one throws an exception
Check(story3);
Console.WriteLine();
Console.WriteLine(json);
Console.WriteLine(json2);
Console.WriteLine("DONE");
}
}
Here are the two jsons: {"inkVersion":20,"root":[[["done",{"#n":"g-0"}],null],"done",{"mytestknot":[{"->":".^.hello"},{"hello":[["^Hi, ","ev",{"CNT?":".^.^"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^still",{"->":".^.^.^.7"},null]}],"nop","^ no issue there.","\n",["ev",{"^->":"mytestknot.hello.0.10.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":2},{"s":["^bla",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"mytestknot.hello.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.10.s"},[{"#n":"$r2"}],"\n","done",null]}],{"#f":1}]}]}],"listDefs":{}}
{"inkVersion":20,"root":[[["done",{"#n":"g-0"}],null],"done",{"mytestknot":[{"->":".^.hello.0"},{"hello":[["^Hi, ","ev",{"CNT?":"^.^"},1,">","/ev",[{"->":".^.b.0","c":true},{"b":["^still",{"->":".^.^.^.7"},null]}],"nop","^ no issue there.","\n",["ev",{"^->":"mytestknot.hello.0.10.$r1"},{"temp=":"$r"},"str",{"->":".^.s.0"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":2},{"s":["^bla",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"mytestknot.hello.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.10.s.0"},[{"#n":"$r2"}],"\n","done",null]}],{"#f":1}]}]}],"listDefs":{}}
Edit:
I use Ink V1.0.0
I had forgotten to include the error message i get:
Ink.Runtime.StoryException: Ink had 1 error. It is strongly suggested that you assign an error handler to story.onError. The first issue was: RUNTIME ERROR: (mytestknot.hello.0.2): Read count for target ( - on ) unknown.
at Ink.Runtime.Story.ContinueInternal(Single millisecsLimitAsync)
at Ink.Runtime.Story.ContinueMaximally()
at inkbug.Program.Check(Story story) in C:\Users\33616\sources\inkbug\Program.cs:line 35
The text was updated successfully, but these errors were encountered:
However, the behavior I reported in the previous post still looks buggy. Is it really the intended behavior? Maybe it is worth documenting explicitly that it does not work?
Hi,
I am struggling trying to save and load my story, but the story I reload fails with some weird error.
More specifically, I do this:
I included a minimal example below.
Any idea of what I am doing wrong? Thanks for your help :)
Here are the two jsons:
{"inkVersion":20,"root":[[["done",{"#n":"g-0"}],null],"done",{"mytestknot":[{"->":".^.hello"},{"hello":[["^Hi, ","ev",{"CNT?":".^.^"},1,">","/ev",[{"->":".^.b","c":true},{"b":["^still",{"->":".^.^.^.7"},null]}],"nop","^ no issue there.","\n",["ev",{"^->":"mytestknot.hello.0.10.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":2},{"s":["^bla",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"mytestknot.hello.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.10.s"},[{"#n":"$r2"}],"\n","done",null]}],{"#f":1}]}]}],"listDefs":{}}
{"inkVersion":20,"root":[[["done",{"#n":"g-0"}],null],"done",{"mytestknot":[{"->":".^.hello.0"},{"hello":[["^Hi, ","ev",{"CNT?":"^.^"},1,">","/ev",[{"->":".^.b.0","c":true},{"b":["^still",{"->":".^.^.^.7"},null]}],"nop","^ no issue there.","\n",["ev",{"^->":"mytestknot.hello.0.10.$r1"},{"temp=":"$r"},"str",{"->":".^.s.0"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-0","flg":2},{"s":["^bla",{"->":"$r","var":true},null]}],{"c-0":["ev",{"^->":"mytestknot.hello.0.c-0.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.10.s.0"},[{"#n":"$r2"}],"\n","done",null]}],{"#f":1}]}]}],"listDefs":{}}
Edit:
Ink.Runtime.StoryException: Ink had 1 error. It is strongly suggested that you assign an error handler to story.onError. The first issue was: RUNTIME ERROR: (mytestknot.hello.0.2): Read count for target ( - on ) unknown.
at Ink.Runtime.Story.ContinueInternal(Single millisecsLimitAsync)
at Ink.Runtime.Story.ContinueMaximally()
at inkbug.Program.Check(Story story) in C:\Users\33616\sources\inkbug\Program.cs:line 35
The text was updated successfully, but these errors were encountered: