General question on narrats abilitys

Hi, I want to make a game with a tradeing aspect. So I need to track different amounts of different wares and in what quantity they are sored in what place. I am so not going to do this with arrays. Is there a way to make narrate interact with a database I put into the public folder when ingame?
Also, is there a way to make narrat check for a condition every time a lable is run without putting in the line check for this condition at every lable?

What do you actually mean by this? All sorts of database tech systems exist, but a database is a bit out of scope for a visual novel engine. Nothing stops you from using javascript to write custom code to connect to say a sqlite db or something if you really want to, but you’d need to know what you’re doing to do that.

if you just mean the general concept of reading data, there is a load_data function which can load yaml files with any data you want and put the resulting object or array in a variable. Though if you want to write complicated algorithms iterating over a bunch of data/arrays then maybe writing bits of it in javascript and using a plugin to call that from narrat would be easier.

Not specifically but same thing, what’s the actual purpose? maybe there’s a better way of doing whatever you’re thinking. Technically you could make your own run function that also runs your condition, say:

run_with_condition labelToRun:
  if (myCondition):
    return (run labelToRun)
  else:
    return false

game:
  run (run_with_condition some_label)

Then using run_with_condition instead of just the default run would run custom code on every run. you can also use the macro feature to automate that and make the syntax better.

But really if you have lots of “business logic” to simulate economy, prices, trading, etc. a lot of this might be a lot easier to manage in typescript/javascript, and then adding commands to interface with it in narrat

Thanks for the fast reply

where to look for dokumentation on how to implement this

You can add plugins in your project’s code. not everything needs to be in plugins, but making a plugin is how you can add custom commands to narrat, so if you had a bunch of code to do your economy calculations in js functions, then you can have a narrat plugin which adds commands to interface with that, for example

2 Likes