Page 1 of 1

Localtext.txt (DSB 0.76+)

Posted: Sat Mar 14, 2020 12:52 am
by Sophia
DSB 0.76 includes support for localization (or easier modification) of text strings; most of the text strings that were formerly more or less hardcoded are now found in base/localtext.txt.

If you want to modify these strings for your own dungeon, you can create your own copy of localtext.txt in your dungeon's directory, containing your own text strings. You can also overwrite any of DSB's standard text strings. The format of a localtext.txt is a series of lines, each one consisting of a key (without whitespace), one or more tabs, and then a text string. In your code, use dsb_locstr(key) to grab an entry from your local text.

Example:
The following is defined in DSB's localtext.txt:

Code: Select all

COINFLIP_HEADS		IT COMES UP HEADS.
This text is output via the coin's attack method with this code:

Code: Select all

dsb_write(system_color, dsb_locstr("COINFLIP_HEADS"))
When the "FLIP" method is invoked, it prints the expected "IT COMES UP HEADS." when the coin comes up heads.

Attack methods themselves also have localization text. The key can be specified by the dungeon designer or auto-generated by DSB via the auto_loc_key property. Methods without proper localized text are displayed using their name in the table (just like they were in 0.75 and before) so this shouldn't break any older dungeons.

You can also create additional localtext files with an underscore and an uppercase two-letter code for the purpose of localization, for example, localtext_DE.txt for German text. If (and only if) the user's locale (in dsb.ini) is set to DE, it will load this file.

Re: Localtext.txt (DSB 0.76+)

Posted: Sat Mar 14, 2020 3:02 am
by Gambit37
This is awesome, it'll make a whole bunch of stuff much easier to manage, and opens up the engine to players and designers who want the game in other languages. Thank you for continuing support DSB with all these great features! :D

Re: Localtext.txt (DSB 0.76+)

Posted: Mon Mar 16, 2020 3:51 pm
by Gambit37
The limit for a string seems to be 300 characters. I wanted to put the DM end game text ("Thank you my friends...") into a string in localtext.txt, but it's around 370 characters and gets truncated by DSB. Any chance this limit could be increased?

Re: Localtext.txt (DSB 0.76+)

Posted: Mon Mar 16, 2020 10:14 pm
by Sophia
Sure, for 0.77 I've increased it to 4k.

Re: Localtext.txt (DSB 0.76+)

Posted: Mon Mar 16, 2020 10:16 pm
by Gambit37
Awesome, thank you.

Re: Localtext.txt (DSB 0.76+)

Posted: Tue Mar 17, 2020 1:20 am
by Gambit37
I noticed an issue with this new system: it's not possible to use extended ASCII characters for the power levels in the LEVEL_09 to LEVEL_15 strings. Lua seems to need these in the form: string.char(xx). I've successfully used that form for the potion power levels, eg, this works:

Code: Select all

powchar = {
  string.char(129), string.char(130), string.char(131),
  string.char(132), string.char(133), string.char(134)
}
How would I get the power symbols to work in localtext.txt? Copy/pasting symbols from an ASCII table doesn't work, eg, char 129 is apparently ΓΌ, but this renders out as ^^

Re: Localtext.txt (DSB 0.76+)

Posted: Tue Mar 17, 2020 1:41 am
by Sophia
The reason the symbols aren't showing up is because when you try to paste that char 129, your text editor is trying to be "helpful" and converting the character to Unicode. There are ways around this by changing your settings from UTF-8 to ASCII, but the simplest answer is probably to escape the characters; for example, \129 for character 129, \130 for character 130, etc. (If you need an actual backslash, put \\ and you'll get \)

Re: Localtext.txt (DSB 0.76+)

Posted: Tue Mar 17, 2020 1:45 am
by Gambit37
Ah of course! Character encoding has always been a bit of a pain in webdev, and I forgot that the same considerations would apply here. The escaping works fine, thanks! :)

Re: Localtext.txt (DSB 0.76+)

Posted: Mon Aug 31, 2020 8:50 pm
by Gambit37
To clarify for anyone now using this feature, add something like this to one of your startup lua files. The actual code numbers to use will depend on the position in the font that your runes are placed.

Code: Select all

-- Magic power characters (in extended system font from ASCII position 128+)
-- This format only usable from DSB 0.76+
powchar = { "\129", "\130", "\131", "\132", "\133", "\134" }