Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magic token function returns incorrect result? #534

Closed
Blakeg612 opened this issue Jan 14, 2019 · 3 comments
Closed

Magic token function returns incorrect result? #534

Blakeg612 opened this issue Jan 14, 2019 · 3 comments

Comments

@Blakeg612
Copy link

I have a text object with word_wrap set to true in which I place a bunch of game info (title, year, mfr, etc.). Because I want to use uppercase versions of said text, I've structured my fe.Text creation like this (this is an abbreviated version):

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(); }
  
local myText = fe.add_text("[!getTitle]\n(c) [Year] [!getMfr]\n[Players] PLAYER(S)\nPLAYED FOR [!getPlayedTime]", 0, 0, w, h);

However, when I run AM, my results are a garbled mess: portions of the tokens are expanded properly, but some elements include un-expanded bits and pieces of the magic token. For example, I might get something like this:

JOJO'S VENTURE
(C) 1998 CAPCOMlayedTime]

Or:

GALAGA
(C) 1981 NAMCOM (MIDWAY LICENSE)tName]; MAME

I've tried with and without newlines, but it makes no difference: something in the magic token functions -- or the way AM handles such functions internally -- corrupts what should get returned. I started a thread in the support forums, but no one else had a solution, either.

@oomek
Copy link
Collaborator

oomek commented Jan 14, 2019

I've never mixed magic tokens with magic token function, but I've checked it just now and indeed it's not interpreted properly. As a workaround you can put everything inside a single function like so:

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)

@Blakeg612
Copy link
Author

Thanks for the suggestion, oomek: I'll have to try later tonight (I'm not in front of my PC during the day). If I'm remembering correctly, I think I tried something similar, but I hadn't integrated a transition callback, and the game_info values remained "stuck" on whatever they were when the layout was first loaded. Again, I intend to give it a try tonight. Thanks!

@mickelson
Copy link
Owner

ok I've found and fixed the bug for this one, thanks for the report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants