Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: l3m35 on February 20, 2020, 03:44:00 PM

Title: Get substring from game title
Post by: l3m35 on February 20, 2020, 03:44:00 PM
Hello, since many romlists have messed titles, I was thinking in get the game title from the rom name, so instead of something like "Ghouls 'N Ghosts (JUE) (REV 01) [!]", I could extract only "Ghouls 'N Ghosts" from it.

I know the scraper should get it, but it seems to don't work for many games, specially the most obscure ones like prototypes, homebrews, etc.

My idea was to use a substr, could anyone tell me if I'm doing it wrong of if there is an easier way?

Code: [Select]
function clean_title() {
local m = fe.game_info( Info.Title );
m.substr(0,m.indexOf('('));
return m;
}
local cleanamer = fe.add_text( "[!clean_title]", flw*0.01, flh*0.55, flw*0.22, 100);

But this breaks Attract soon as I launch it (i know it's Javascript, no idea if Squirrel is the same thing).
Title: Re: Get substring from game title
Post by: keilmillerjr on February 20, 2020, 04:30:23 PM
I do the same thing, except use the split function.
Title: Re: Get substring from game title
Post by: l3m35 on February 20, 2020, 05:33:07 PM
Thank you. Seems to be working now with:

Code: [Select]
function mb_clnttl(ioffset ) {
local m = fe.game_info( Info.Title,ioffset );
return split( m, "(" )[0];
}
local cleaname = fe.add_text( "[!mb_clnttl]", flw*0.01, flh*0.75, flw*1, 100);
Title: Re: Get substring from game title
Post by: progets on February 20, 2020, 08:33:23 PM
Configure-->General-->Hide Brackets in Game Titles = Yes


Title: Re: Get substring from game title
Post by: l3m35 on February 23, 2020, 11:59:49 AM
Configure-->General-->Hide Brackets in Game Titles = Yes

Thank you, I tried it. But didn't work for uncommon titles using brackets and parentheses, some titles were broken.