Author Topic: Get substring from game title  (Read 195 times)

l3m35

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Get substring from game title
« 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).

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1081
    • View Profile
Re: Get substring from game title
« Reply #1 on: February 20, 2020, 04:30:23 PM »
I do the same thing, except use the split function.

l3m35

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Get substring from game title
« Reply #2 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);

progets

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 984
    • View Profile
Re: Get substring from game title
« Reply #3 on: February 20, 2020, 08:33:23 PM »
Configure-->General-->Hide Brackets in Game Titles = Yes



l3m35

  • Jr. Member
  • **
  • Posts: 16
    • View Profile
Re: Get substring from game title
« Reply #4 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.