inkle / inky

An editor for ink: inkle's narrative scripting language
http://www.inklestudios.com/ink
2.39k stars 290 forks source link

Allow opening an .ink file to a specific line #453

Open evyatron opened 1 year ago

evyatron commented 1 year ago

I think it would be a nice addition to be able to open a story to a specific line - especially for engines integration. A use-case example - working with Unity, I allow designers to select a knot to associate with a dialogue component (so upon player interaction we play that specific knot). I would like to add an "open knot" button in the Unity Inspector, as the story file can get quite long. Unity provides opening an asset with a specific line number and column: https://docs.unity3d.com/ScriptReference/AssetDatabase.OpenAsset.html

I'm not entirely sure how they pass these, but I would think it's just additional command line arguments, e.g. "story.ink 21 9"

--

I've taken the liberty to peruse the Inky source code a bit! (hopefully that's not out of place, apologies if it is) I believe the required changes would be:

  1. main.js : 197 - check if after a file has been set to open, there's also a numerical argument
  2. save that to something like "pendingPathToOpenLine"
  3. pass it to ProjectWindow.open in line 209
  4. in projectWindow.js : 37 - add a constructor overload that takes a line number and jumps to that on open
  5. do some magic that makes Electron scroll to the correct line