Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Folia

A minimal framework for narrative games. · By Axile

[bug] string interpolation code can not access story-defined global functions

A topic by ironlantern72 created 56 days ago Views: 61 Replies: 3
Viewing posts 1 to 2

steps to reproduce

  • inside a node, use an interpolated string involving an inline call to a function defined inside the story (e.g. $(myUtils.getStatus()))
  • ensure function used returns a string-coercible value
  • run the node

expected behavior

string interpolates to call result (money: 522; magical orbs: fire, water)

actual behavior

string interpolates as though the call result was nil (nil)), but does not raise an “attempt to call a nil value” error

additional info

  • engine version: 1.3.0
  • platform: linux (WINE)

Ah okay I see what's happened here. varstrings aren't intended to be as sophisticated as this: they only substitute a single named variable, not an arbitrary lua expression, so you can't use inline function calls in this context (currently).

As a quick workaround, you can do something like

local orbs = table.concat(prog.orbs, ", ")
text "magical orbs: $(orbs)"

yeah that’s what i’ve been doing so far, adding a global status string var and making sure it’s updated whenever state it describes is touched.

I can see how that's limiting, yeah. We'll earmark this for a future version; it shouldn't be too hard to allow more flexible varstrings.