Skills, Stats and Variables (how to write, deduce and check in the game)

Hola, Liana. I don’t know why, maybe I am stupid, or not flexible anymore. Or just too demanding of my game.

I cannot figure out the differences of skills, stats and variables. Also, how to write them, to check them and how to deduce.

Problem 1 (Yellow): If I set I can display energy in the text after some trial and error; quest.narrat helped me but had f.e. two “$”, which led me to some errors and next trials.
Anyway: For energy, I have not found any way how to deduce energy (from config,yaml). In the end, I had to set a variable and deduce it independently from the energy of config.yaml. How can I deduce it? Is it stats? If so, add_stat energy -1 doesn’t work.

Problem 2 (Purple): How is it with skills and stats (config.yaml?)? With get_stats_value I have no success. What do I write? Do I have to write a block after energy in config.yaml hudStats? In my case, I cannot display the xeno level in the game. %($get-stats_value xeno) gives me an error.

Side Questions:

  1. Not so important since it works anyway, but maybe it helps me in the future: If I set variables, where are they stored or written? In config.yaml?
  2. Can I add more properties in (screens).yaml? F.e. I have a picture, but it is too centered and I wish it to reposition by -100px. I have to do it in main.css or better with creating sprites. Adding properties to screens.yaml didn’t work. So, these .yaml are definite? I cannot add more properties than there are? Is there a cheatsheet for .yaml? Because the one in YAML Cheat Sheet & Quick Reference didn’t seem to fit.

If you’re trying to do those things in the middle of text you can’t. The string template syntax (%{$data.something}) only works with variables, you can’t call functions in it, so you need to first get the value and store it first

  add_stat energy -1
  var test (get_stat energy)
  "we have %{$test} energy"

Something like this should work. And for skills there’s a function to get the current level of a skill, and functions to add xp or set the level. There’s a page in the docs with all the functions sorted by categories. And yes the energy etc stuff is what is currently called “hud stats”, and they’re not normal variables as they’re a special feature. Same for skills, you’re not supposed to just manipulate them like normal variables as it’s a feature the engine manages, so you use commands to interact with them

Also another reason why your thing doesn’t work is that you’re trying to change some of those variables directly in code and it might be interfering with what narrat is doing with them.

The reason they’re used via functions and not directly is that energy and skills data are objects, and their structure might change, so if your code tries to modify them directly it might break what the engine does, or break in a future update if I change how they work internally

1 Like

config.yaml is just the config file, it doesn’t change. Variables are created and stored during gameplay so they’re part of the save file

Everything that changes in the game gets added to the save data, including the current state of the script (variables, current label, etc)

I don’t know what you mean, in screens.yaml you can have any amount of screens, and they can also have buttons. You can look at the viewport docs to see how it works, or some of the other games.

Screens are the background of a scene, they always take the entire viewport so there’s no positioning for them. Buttons are placed on top of them and they have specific positions and sizes (and even if they’re buttons they don’t have to be clickable, you can use them to just display images too)

Otherwise yeah sprites are fine for adding images on the screen dynamically

1 Like