Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Bgoulette on January 08, 2019, 09:18:46 PM
-
This is really weird.
I want certain game details returned in uppercase text. I discovered the toupper() function, but when running magic token text through a magic token function (e.g., [!getTitle]), sometimes it looks like it works, other times it returns a bunch of weird junk: an odd mixture of "magic-less" token parts and who knows what else.
Here's what I've coded:
function getTitle () { return fe.game_info(Info.Title).toupper(); }
function getMfr () { return fe.game_info(Info.Manufacturer).toupper(); }
function getPlayedTime () { return fe.game_info(Info.PlayedTime).toupper(); }
function getName () { return fe.game_info(Info.Name).toupper(); }
function getEmu () { return fe.game_info(Info.Emulator).toupper(); }
function getStatus () {
if (fe.game_info(Info.Status).len() < 1) {
return "";
}
else {
return "; " + fe.game_info(Info.Status).toupper();
}
}
And here's the line where I'm trying to populate my text instance:
local _gameInfo = fe.add_text("[!getTitle]\n© [Year] [!getMfr]\n[Players] PLAYER(S)\nPLAYED FOR [!getPlayedTime]\n[!getName]; [!getEmu][!getStatus]", 228, 880, 704, 136);
I tried adjusting the line breaks, adding whitespace, etc., but the fact is, it just doesn't work as-is. I'm not sure if I'm missing something or if there's a hiccup with getting the "processed" text from the magic token function(s).
If there's a simpler way to do this, I'm all ears. I tried chaining .toupper() directly to my tokenized string, but that just returned an uppercase version of the untranslated tokens. :shrug:
Here's a pic of some of the results (attached). Thanks for any help!
-
I'll look into this as soon as I have some time because I'm also interested in this, but as a quick and dirty solution right now I'm using an uppercase only font for my theme, so no issues with "toupper" function :D
-
It looks like text from multiple functions are running into each other. Share full code that produced the results?
-
Something fishy is going on related to "\n" character: look at this simple layout:
function getName () {
return fe.game_info(Info.Name)
}
function getEmulator () {
return fe.game_info(Info.Emulator)
}
local gameInfo = fe.add_text("\n[!getName] [!getEmulator]", 0, 0, fe.layout.width, fe.layout.height*0.5)
gameInfo.charsize = 20
gameInfo.word_wrap = true
local gameInfo2 = fe.add_text("[!getName] [!getEmulator]", 0, fe.layout.height*0.5, fe.layout.width, fe.layout.height*0.5)
gameInfo2.charsize = 20
gameInfo2.word_wrap = true
The result is missing the space when using the custom magic tokens, while it's ok otherwise.
-
Something fishy is going on related to "\n" character: look at this simple layout:
I thought that, too, but even ditching the newline produces weird, arbitrary-looking results for me!
Here's the layout I'm working on. It's still a wip, but it exposes everything I'm doing, in case it's me screwing up (attached). Sometimes it looked like something in the expansion just gets tired and spits back the un-magic token. Or even just a part of it. Weird! Thanks for looking!
-
This should do what you need I think:
function getAll() { return fe.game_info(Info.Title).toupper() + "\n(c) [Year] " +
fe.game_info(Info.Manufacturer).toupper() + "\n[Players] PLAYER(S)\nPLAYED FOR " +
fe.game_info(Info.PlayedTime).toupper() }
local all = fe.add_text("[!getAll]", 0, 0, w, h)