Author Topic: Re: [Players] to image? [Solved]  (Read 9562 times)

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: [Players] to image? [Solved]
« Reply #15 on: June 17, 2017, 03:11:17 PM »
I found an issue in the code "magic-images.nut"

As Boxxman said, that isn't a bug, it was intentionally using tags to find region. You could use name to save time from manually tagging, but matching might not be accurate for all types of roms ( U, US, USA, W, WORLD, EUR, EUROPE, etc..) - same for ESRB, you will need to add tags (ESRB-E, ESRB-M, etc) as there is no info on that being scraped

Favdeacon

  • Sr. Member
  • ****
  • Posts: 129
    • View Profile
Re: [Players] to image? [Solved]
« Reply #16 on: June 18, 2017, 04:02:13 AM »
Hi.

Code: [Select]
   local info = fe.game_info( Info.Players, index_offset ).tolower()
   if ( info.len() >= 1 ) return "players-" + info.slice(0, 1) + ".png"

Nice code. It fails on two-digit player numbers, though. A very seldom but nevertheless existing case, e.g. Royal Ascot II with 12 players. Perfectionists like me may that find unsettling. :)

Two friends who know their RegEx helped me write this function:

Code: [Select]
function plnum()
 {
  local ex = regexp(@"(\d+)P(?: (alt|sim))?");
local plinfo = fe.game_info(Info.Players);
  local plex = ex.capture(plinfo);
local plnum = plinfo.slice(plex[1].begin,plex[1].end);
local mpmode = plinfo.slice(plex[2].begin,plex[2].end);
return plnum;
 }

Given fe.game_info(Info.Players) in the format "2P alt" etc. it returns the number of players with one or more digits. As a bonus, the multiplayer mode "alt" or "sim" will be stored in the variable mpmode.

Because I am very new at Squirrel and coding overall, it may be not very optimized. Feel free to tinker with it.

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: [Players] to image? [Solved]
« Reply #17 on: June 21, 2017, 10:13:57 AM »
@BOXXMAN @liquid8d thanks for the info.