Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: keilmillerjr on March 18, 2016, 07:16:46 PM

Title: Magic Tokens UPPERCASE?
Post by: keilmillerjr on March 18, 2016, 07:16:46 PM
Having a little trouble making magic tokens uppercase. Tried quite a few things. Anyone know how to achieve this?

http://attractmode.org/docs/Layouts.html#magic
http://attractmode.org/docs/Layouts.html#game_info
http://www.squirrel-lang.org/doc/squirrel3.html <- See section about toupper()
Title: Re: Magic Tokens UPPERCASE?
Post by: verion on March 19, 2016, 02:10:23 AM
As a workaround you can use a font that has ONLY uppercase letters - like a free BEBAS font.
It will automatically make all your texts uppercase.
Title: Re: Magic Tokens UPPERCASE?
Post by: keilmillerjr on March 19, 2016, 09:52:48 PM
I resolved this by passing a function to the magic token. I wish the function can take params... or can it?

Working Example
Code: [Select]
function test(){
  local text = fe.game_info(Info.Year);
  return text.topper();
}
fe.add_text("[!test]", 0, 0)
Title: Re: Magic Tokens UPPERCASE?
Post by: chrisvg on March 20, 2016, 12:41:43 AM
Quote
Magic tokens can also be used to run a function defined in your layout or plugin's squirrel script to obtain the desired text. These tokens are in the form [!<function_name>]. When used, Attract-Mode will run the corresponding function (defined in the squirrel "root table"). This function should then return the string value that you wish to have replace the magic token. The function defined in squirrel can optionally have up to two parameters passed to it. If it is defined with a first parameter, Attract-Mode will supply the appropriate index_offset in that parameter when it calls the function. If a second parameter is present as well, the appropriate filter_offset is supplied.

from https://github.com/mickelson/attract/blob/master/Layouts.md#magic-tokens (https://github.com/mickelson/attract/blob/master/Layouts.md#magic-tokens)
Title: Re: Magic Tokens UPPERCASE?
Post by: Josepzin on September 09, 2017, 11:02:34 PM
Thanks!!