This post is both an Explanation on how to add custom Auto-Complete attributes to your custom commands... and a request for help since I'm at the limit of my programming knowledge, I don't know what to google :/
I'm trying to figure out the Naninovel Bridging service so I can figure out Expressions and what variables are available and if I can add my own.
Say we make our new command, following https://naninovel.com/guide/custom-comm ... om-command
For this example, we will make a [moveTo] command (something I want so that the writer can interface with game systems without touching code)
For simplicity, we just have the task debug.log the info, and we'll keep the command basic with a single input parameter.
For context, this command is created such that it represents the player character moving around the world, going to locations in the main world, such as "Base" and/or navigating to sub rooms, such as "Main Lobby" (with the game doing logic to check if any events occur or not). The goal is to have the command list out world locations, and or sub rooms, similar to how the [goTo] command will list out available labels to jump to.
As shown above, we can add attributes to make it [Required] [Nameless] and give it a nice [Description]!
However, notice the extra LocationContext attribute.
This is a custom attribute to provide the contextual list that shows up when you use the command.
Here's what I learned about creating the custom list of locations.
You can use ConstantContext and an Enum per the attribute example linked above... but that just a list, it doesn't do anything fancy, and it can't be automatically expanded upon using code. For this, the goal is to also have the list be automatically generated... somehow. So we'll create a custom attribute called LocationContext
LocationContext is AUTO GENERATED USING MAGIC as far as I can tell... something possibly related to this 'Bridging Service' I keep seeing mentions about in the comments, but no links to. It seems to be some magical part of Naninovel... that I can't get documentation on (nothing shows up on google?!).
Anyways, to create this attribute, we create a LocationContextAttribute, inheriting PararmeterContextAttribute (using ConstantContext and ActorContext as references)
The main thing is that the "Location" in LocationContextAttribute is what gets pulled by the 'Bridging Service' to generate the name of the new attribute LocationContext.
I'm using the ValueContextType.Constant... which I think just a way of organizing the different types of values Naninovel.Metadata system has to deal with. ie, we don't want to use Actor because it 'could' show up with actor commands, such as @char... which would probably be fatal... idk, I don't know what's really going on.
The next main thing is the pathPrefix. I can have this as "Location" and it would work, I'll show in the next step how to add a bunch of 'locations', but in the above example, I included the expression for how the goTo command works, because I'm trying to figure out how to make a different expression with different variables... I just can 't find documentation.
Anyways, when this is just 'Location', we are setting up our custom attribute to look for locations. So now the question is, How do we make locations?
Well this is what the IMetadataProvider is used for
Again, placeholder stuff to figure out how this works, and then worry about code that does fancy things, such as auto generate a list of locations based on other game files.
This requires the first function, GetMetadata, to return a project, which is filled with information, such as a list of actors, commands, resources, constants, variables, and functions. Based on the example provided on the attributes page, it looks like we can just return a new project and all the data gets incorparated. Since I'm using Constant before, I figure it would be smart to well... keep using constants, so I just fill the Constant[].
With the "Location/Test_Script" using the logic expression string pathPrefix = "Location/{:Path[0]??$Script}" such as what was in the second image, I know that the list of locations by be filtered by the script name, as indicated by $Script
And that's the end of the How To... because this is where I am stuck.
I basically want to create a $CurrentLocation variable... which the IDE can't really track, but we'll ignore that.
Right now "Location/Base" does not work. Ideally, what I want to do is specify Location.Room, or .Room if the writer knows the location. I don't want a bunch of Base_lobby, Base_Room1, Base_Room2 cluttering up the auto-complete list. So even if I can't get $CurrentLocation to work (because the idea doesn't make the most sense considering the IDE can't track game state), what I would like is to just list off locations, type the '.' token, and then have it list rooms, to sort of keep things clean and organized for my writer...
Is this even possible?
Anyways, a bit of a long story to get to a simple question... and that's just because I wanted to make this how-to guide after it took me a week or 2 to figure out naninovel enough. It feels like I'm a graduate student, sure there's all these documentations and technical stuff... but I'm still beating my head against a wall trying to figure it out, there wasn't a simple guide through the process.