Special letters in script

» Siedler Map Source Forum » Siedler DEdK Script Forum » Special letters in script

Seiten: 1

Qba331PL
#1
09.05.2018 09:46
Beiträge: 102

Special letters in script

Hi!

I saw that in some of your maps there is a function that allows to use umlauts. Is there possible to change it for other special letters?
How to do that.

Best regards,
Qba331PL

Play4FuN
#2
09.05.2018 10:20
Beiträge: 704

What special letters are you talking about?

____________________
LG Play4FuN

Siedler DEdK Mapping + Scripting Tutorials

Qba331PL
#3
09.05.2018 12:47
Beiträge: 102

Mainly about polish special letters(I can't write those letters here because this thing happens --> &#378.

Qba331PL
#4
09.05.2018 12:49
Beiträge: 102

And when I write special letter in script, text is cut.

mcb
#5
09.05.2018 13:13
Beiträge: 1472

This is the standard Umlaute func:

Umlaute = function(_text)
	local texttype = type(_text);
	if texttype == "string" then
		_text = string.gsub( _text, "ä", "\195\164" );
		_text = string.gsub( _text, "ö", "\195\182" );
		_text = string.gsub( _text, "ü", "\195\188" );
		_text = string.gsub( _text, "ß", "\195\159" );
		_text = string.gsub( _text, "Ä", "\195\132" );
		_text = string.gsub( _text, "Ö", "\195\150" );
		_text = string.gsub( _text, "Ü", "\195\156" );
		-- here you could insert your own substitutions
		return _text;
	elseif texttype == "table" then
		for k, v in _text do
			_text[k] = Umlaute( v );
		end
		return _text;
	else return _text;
	end
end;



It works by having the "ä" encoded the same as in normal strings and then replacing them by an escape secuence that represents this special character.
To get this escape secuence you can have a look at this list: https://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec
the 2nd row is the character you want, the 4th is a description of the caracter, and the 3rd is the number you need.
So have a look at the mathematical multiply symbol (looks a bit like a x) It is at U+00D7 in this list, and its UTF-8 in decimal is 195 151. So our escape secuence is : \195\151
Now you need something you can use to replace it with this. In case of a special letter (on your keyboard) you can just use this key. (It gets encoded the same in your script file, so it gets replaced). In my case i use the text @multiply (other special codes like color are also startet with @).
Now we have the complete replace call:

_text = string.gsub( _text, "@multiply", "\195\151" );


And we can insert it into the function:

Umlaute = function(_text)
	local texttype = type(_text);
	if texttype == "string" then
		_text = string.gsub( _text, "ä", "\195\164" );
		_text = string.gsub( _text, "ö", "\195\182" );
		_text = string.gsub( _text, "ü", "\195\188" );
		_text = string.gsub( _text, "ß", "\195\159" );
		_text = string.gsub( _text, "Ä", "\195\132" );
		_text = string.gsub( _text, "Ö", "\195\150" );
		_text = string.gsub( _text, "Ü", "\195\156" );
		_text = string.gsub( _text, "@multiply", "\195\151" );
		-- here you could insert your own substitutions
		return _text;
	elseif texttype == "table" then
		for k, v in _text do
			_text[k] = Umlaute( v );
		end
		return _text;
	else return _text;
	end
end;



But not all letters can be displayed by all fonts, so you have to test it. (But if this special letters are used in one normal settlers localization you should be fine).

MadShadow
#6
09.05.2018 14:50
Beiträge: 372

Hello, by coincidence I already have a function that provides the polish letters
I couldn't test it myself, but it seemed to work for darnok_PL and maybe it works for you too...

function Umlaute( _text )
	local texttype = type( _text );
	if texttype == "string" then
		_text = string.gsub( _text, "ä", "\195\164" );
		_text = string.gsub( _text, "ö", "\195\182" );
		_text = string.gsub( _text, "ü", "\195\188" );
		_text = string.gsub( _text, "ß", "ss" ); -- ß
		_text = string.gsub( _text, "Ä", "\195\132" );
		_text = string.gsub( _text, "Ö", "\195\150" );
		_text = string.gsub( _text, "Ü", string.char(195)..string.char(156)); --"\195\156" );
		-- Polish addition by darnok_PL :)
		_text = string.gsub( _text, "¹", "\196\133" );
		_text = string.gsub( _text, "æ", "\196\135" );
		_text = string.gsub( _text, "ê", "\196\153" );
		_text = string.gsub( _text, "³", "\197\130" );
		_text = string.gsub( _text, "ñ", "\197\132" );
		_text = string.gsub( _text, "ó", "o" ); -- Darnok_PL: the only polish letter that doesn't work
		_text = string.gsub( _text, "œ", "\197\155" );
		_text = string.gsub( _text, "¿", "\197\188" );
		_text = string.gsub( _text, "Ÿ", "\197\186" );
		return _text;
	elseif texttype == "table" then
		for k,v in _text do
			_text[k] = Umlaute( v );
		end
		return _text;
	else
		return _text;
	end 
end

Qba331PL
#7
09.05.2018 15:36
Beiträge: 102

Thank you guys!!!

Seiten: 1

SiteEngine v1.5.0 by nevermind, ©2005-2007
Design by SpiderFive (www.siedler-games.de) - English translation by juja

Impressum