Author Topic: YAML in PIRATEZ questions  (Read 4649 times)

Offline Bartojan

  • Colonel
  • ****
  • Posts: 136
    • View Profile
YAML in PIRATEZ questions
« on: February 14, 2017, 11:44:26 am »
I never worked with YAML before, so there are my questions:

1) Is it possible to use "one: ... few: .... other: ...." notation in every place where {N} or {0} is used? Is it possible only on places with {N}? Or have it be coded in the application, to use this notation?
Code: [Select]
STR_UNITS_IN_CRAFT:
  one: "{N} Unit aboard"
  other: "{N} Units aboard"

2) I like the "variable" &FIRST_NAMES used in Pirate.nam file. Is it possible to use similar "variables" for strings used inside the texts? E.g.
Code: [Select]
GunButt (Stun = 20+STR*0.6, Skill = MA/2+50, Acc = 80%, 18 TUs)is used many times in Piratez_lang.rul file and I would like to have some shortcut for it like &GUNBUT.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: YAML in PIRATEZ questions
« Reply #1 on: February 14, 2017, 02:58:30 pm »
1) This depends on how the engine is reading the YAML file, and for OXC/OXCE/OXCE+ this is not supported.

2) The "variables" you see are YAML anchors - you can mark the value of a particular tag as an anchor with ampersand (&), and reference it with asterisk (*).  This is useful for copy-paste like functions, but only if the values of the tags are exactly the same. This is not the case for Bootypedia articles, where there is unique text before the gunbutt, and also not all gunbutts are created equal.

This tutorial might be helpful if you want to learn more YAML.
« Last Edit: February 14, 2017, 03:18:15 pm by ohartenstein23 »

Offline Bartojan

  • Colonel
  • ****
  • Posts: 136
    • View Profile
Re: YAML in PIRATEZ questions
« Reply #2 on: February 14, 2017, 11:48:40 pm »
1) This depends on how the engine is reading the YAML file, and for OXC/OXCE/OXCE+ this is not supported.
There are at least 2 strings with one... many... notation. I will test it myself.

Thanks for the manual :) So, no text replacement in pure YAML. I am going to use some tool for it. Troff or FreeMarker.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: YAML in PIRATEZ questions
« Reply #3 on: February 14, 2017, 11:56:37 pm »
News to me if that's supported in how the strings are read - I should probably just check the source code to see...

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9105
    • View Profile
Re: YAML in PIRATEZ questions
« Reply #4 on: February 15, 2017, 12:34:28 am »
News to me if that's supported in how the strings are read - I should probably just check the source code to see...

Yes, it is supported, e.g.

Code: [Select]
  STR_DAY:
    one: "{N} deň"
    few: "{N} dni"
    other: "{N} dní"
  STR_HOUR:
    one: "{N} hodina"
    few: "{N} hodiny"
    other: "{N} hodín"

https://github.com/SupSuper/OpenXcom/blob/master/src/Engine/Language.cpp#L516

https://github.com/SupSuper/OpenXcom/blob/master/src/Engine/Language.cpp#L675
« Last Edit: February 15, 2017, 12:37:56 am by Meridian »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1933
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: YAML in PIRATEZ questions
« Reply #5 on: February 15, 2017, 12:48:01 am »
I stand corrected. Thank you Meridian for linking the code, I like the rare example of good documentation in a comment.