The LG(...) function - Grisgram/gml-raptor Wiki

This is the core function, the heart of LG. It will resolve all your strings and has a huge load of powerful features.

To resolve a string, call LG with a path to the string to retrieve.
The path can be in one of those formats:

  • LG("key1", "subkey", "keybelow");
  • LG("key1/subkey/keybelow");
  • You may even mix the formats: LG("key", "subkey/keybelow"); will work just fine!

String references - Strings within Strings

LG supports string references. Use [?key] to reference a string from within another string.
Reference resolve even works recursively! So the referenced string may contain another reference, and so on...
References are resolved only once and the result is cached, so you don't have to worry about performance too much when you create lots of references.
Only the first resolve consumes the CPU time. Subsequent ones will resolve through a cache hit.

Here is an example for string references:

    "author" : "Mike"
    "credit" : "Written by [?author]." -> Will resolve to "Written by Mike."

Random picks

LG supports "random picks", if some character should say "one out of x" possible statements, like greetings, curses or cheers when something happens in game.

To have LG pick one string random, you must either create a sub-object in json or create a group of strings that all share the same prefix.
Then put an asterisk * as wildcard marker at the end of your query string when you call LG.

Here is an example for random picks:

"greetings": {
	"greet_1" : "Hi.",
	"greet_2" : "Hello.",
	"greet_3" : "Welcome.",

You can pick one of those greetings randomly by querying LG with:

  • LG("greetings/*");
  • or
  • LG("greetings/greet*");

The return value of the LG function is always a string.
Either it is the resolved string or "??? [key] ???" if no string was found for the supplied parameters.

⚠️ ** Fallback** ⚠️