You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Get the selected unit's first name in the Target Language, and The Trade Tongue. ex 'babblefish ELF'
-- When all is said and done be able to enact that change. 'babblefish ELF do'
-- I even do a bit of the gruntwork within.
-- But more specifically 'babblefish English do' for races with beautiful but hard to decrypt names.
-- This is a bit messier what with the parts of speech... not that I've looked into it.
-- /Currently doesn't remotely cover fake identities./ You get the identity right of the unit, not the Hist Fig.
-- Part of why the 'do' does not get done. When that happens there will be a help segment.
args=...
targlang=args
unit=dfhack.gui.getSelectedUnit()
worker0, worker1, fl_valuewordz, valuelangy=0
fl_wordz, worker2=''
langy= {}
--http://lua-users.org/wiki/StringRecipes ---------- and unit-info-viewer.lua
functionstr2FirstUpper(str)
returnstr:gsub("^%l", string.upper)
end
ifunit.name.has_name==falsethenqerror('No selected unit OR unit has no name -nicknames don\'t count. Select a (different) unit.') end
forfl_valuewordz,fl_wordzinipairs(df.global.world.raws.language.translations[unit.name.language].words) do
if (fl_wordz.value==unit.name.first_name) then
worker0=fl_valuewordz
break
end
end
forvaluelangy,langyinipairs(df.global.world.raws.language.translations) do
if (string.lower(langy.name) ==string.lower(targlang)) then
worker1=valuelangy
break
end
end
-- For posterity the above 'for' loop variables will maintain their names... even though I found out the hardway they're tossed out after the loop runs.
--I'm not sure of the spacing of most of the pieces.
--I'm also not sure on the positioning of the /the/ and /of/ segments. Does it really fill them in, in a funny order, as you earn them or what? Wiki doesn't say, and some examples suggest it.
the_restA6=" the "..string.lower(df.global.world.raws.language.translations[worker1].words[workery6][0])
the_restB6=" the "..string.lower(df.global.world.raws.language.words[workery6].forms[unit.name.parts_of_speech[5]])
else
the_restA6=""
the_restB6=""
end
ifnot (unit.name.words[6] ==-1) then
the_restA7=" of "..string.lower(df.global.world.raws.language.translations[worker1].words[workery7][0])
the_restB7=" of "..string.lower(df.global.world.raws.language.words[workery7].forms[unit.name.parts_of_speech[6]])
else
the_restA7=""
the_restB7=""
end
print(dfhack.TranslateName(unit.name,false,false).."'s name becomes " ..str2FirstUpper(the_restA0)..""..str2FirstUpper(the_restA1)..the_restA2..the_restA3..the_restA4..the_restA5..the_restA6..the_restA7.." in " ..str2FirstUpper(string.lower(targlang)))
print(dfhack.TranslateName(unit.name,false,false).."'s name becomes " ..str2FirstUpper(the_restB0)..""..str2FirstUpper(the_restB1)..the_restB2..the_restB3..the_restB4..the_restB5..the_restB6..the_restB7.." in the Trade Tongue.")
print('Or you could change unit.name.language to one of the other numbers directly but where\'s the fun in that? And you can\'t get the Trade Tongue without a prior existing English file in any event.')