Synisill
October 18th, 2020, 16:05
Edited: -PROBLEM SOLVED, solution beneath- This thread can be closed or moved.
Hello, dear developers!
I am struggling with a rather simple task. By now i am guessing there has to be an error in FGU, because i have double-checked everything i have done on my side. My problem in short words: i want to replace a certain pattern within a stringfield with an ANSI (or ASCII, i can not differentiate that properly) character. When i, for example, enter "(S)" into a stringfield, it should be replaced with the character ¸ (184).
First of all, i created a copy of the 5E ruleset in the same folder and edited the base.xml
<description>
<displayname>Atest</displayname>
<displayversion>1</displayversion>
<text>Atest ruleset</text>
<author>me</author>
<website>https://www.fantasygrounds.com</website>
</description>
Second, i created a ttf-font with the symbol i want at character 184. Copied it into \rulesets\atest\graphics\fonts
Third, i edited graphics_fonts.xml and inserted an "override" of the wanted font:
<font name="sheettext">
<ttf file="graphics/fonts/Genesys Regular.ttf" name="Genesys Regular" size="16" />
<color value="#000033" />
</font>
(Btw, i checked to link to the right font name! I am going to try my changes at a <stringu>-element which is derived from the CoreRPG ruleset:
<template name="stringu">
<stringfield>
<font>sheettext</font>
<lineoffset default="on" mergerule="replace">1</lineoffset>
</stringfield>
</template>
)
Fourth, i added my code to \rulesets\atest\campaign\record_char_notes.xml - at that spot there are no other elements which could interfere. I took the "Deity" entry as an example. Here is the code:
<stringu name="deity">
<anchored to="detailstitle2" position="belowright" offset="0,5" height="20">
<left anchor="center" offset="5" />
</anchored>
<script>
function onValueChanged()
-- get the source node value
local oldvalue = getValue();
local newvalue = oldvalue;
-- perform symbol replacements between [] or ()
newvalue = string.gsub(newvalue, "%(S%)", string.char(184));
newvalue = string.gsub(newvalue, "%(!%)", string.char(185));
newvalue = string.gsub(newvalue, "%[S%]", "&#184;");
newvalue = string.gsub(newvalue, "%[!%]", "&#185;");
-- set the new source node value
if newvalue ~= oldvalue then
setValue(newvalue);
end
end
</script>
</stringu>
I hope it will not be partly replaced when i send it. If so, i will add a screenshot after my post here.
That was it. All that work - for naught. In test mode, the replacement works in parts. The pattern is replaced as soon as i enter it, BUT with a question mark character (64) OR the blank html-mask as text (& # 184 ;).
Also note that the same code WORKS 100% in a formatted textfield! Can someone please help me here? I ran out of ideas.
A picture of the faulty result as it is will follow as attachment now:
Hello, dear developers!
I am struggling with a rather simple task. By now i am guessing there has to be an error in FGU, because i have double-checked everything i have done on my side. My problem in short words: i want to replace a certain pattern within a stringfield with an ANSI (or ASCII, i can not differentiate that properly) character. When i, for example, enter "(S)" into a stringfield, it should be replaced with the character ¸ (184).
First of all, i created a copy of the 5E ruleset in the same folder and edited the base.xml
<description>
<displayname>Atest</displayname>
<displayversion>1</displayversion>
<text>Atest ruleset</text>
<author>me</author>
<website>https://www.fantasygrounds.com</website>
</description>
Second, i created a ttf-font with the symbol i want at character 184. Copied it into \rulesets\atest\graphics\fonts
Third, i edited graphics_fonts.xml and inserted an "override" of the wanted font:
<font name="sheettext">
<ttf file="graphics/fonts/Genesys Regular.ttf" name="Genesys Regular" size="16" />
<color value="#000033" />
</font>
(Btw, i checked to link to the right font name! I am going to try my changes at a <stringu>-element which is derived from the CoreRPG ruleset:
<template name="stringu">
<stringfield>
<font>sheettext</font>
<lineoffset default="on" mergerule="replace">1</lineoffset>
</stringfield>
</template>
)
Fourth, i added my code to \rulesets\atest\campaign\record_char_notes.xml - at that spot there are no other elements which could interfere. I took the "Deity" entry as an example. Here is the code:
<stringu name="deity">
<anchored to="detailstitle2" position="belowright" offset="0,5" height="20">
<left anchor="center" offset="5" />
</anchored>
<script>
function onValueChanged()
-- get the source node value
local oldvalue = getValue();
local newvalue = oldvalue;
-- perform symbol replacements between [] or ()
newvalue = string.gsub(newvalue, "%(S%)", string.char(184));
newvalue = string.gsub(newvalue, "%(!%)", string.char(185));
newvalue = string.gsub(newvalue, "%[S%]", "&#184;");
newvalue = string.gsub(newvalue, "%[!%]", "&#185;");
-- set the new source node value
if newvalue ~= oldvalue then
setValue(newvalue);
end
end
</script>
</stringu>
I hope it will not be partly replaced when i send it. If so, i will add a screenshot after my post here.
That was it. All that work - for naught. In test mode, the replacement works in parts. The pattern is replaced as soon as i enter it, BUT with a question mark character (64) OR the blank html-mask as text (& # 184 ;).
Also note that the same code WORKS 100% in a formatted textfield! Can someone please help me here? I ran out of ideas.
A picture of the faulty result as it is will follow as attachment now: