1
Scripting / How can I process the number of players and style from nplayer.ini?
« on: June 13, 2017, 05:06:44 AM »
Hi,
nplayers.ini lists the number of players and style of multiplay (simultaneous or alternating) in the format "2P sim", "3P alt", or even "4P alt / 2P sim". Building a romlist with nplayers.ini in import_extras passes them on in this format.
I want to extract the number(s) of players and the style(s) from Info.Players for further processing or display as [!somefunction].
My first try was to simply splice off the first character of Info.Players (see below), but it's a dirty hack that doesn't cover two-digit numbers (Royal Ascot II has 12) nor styles or dual styles.
After doing some reading in http://www.squirrel-lang.org/doc/squirrel3.html I think about a combination of splice() and find(). But I'm a absolute beginner at Squirrel and need some (aka much) help with this. Ideally, the final result may help others in parsing the nplayers.ini.
Cheers
Favdeacon
nplayers.ini lists the number of players and style of multiplay (simultaneous or alternating) in the format "2P sim", "3P alt", or even "4P alt / 2P sim". Building a romlist with nplayers.ini in import_extras passes them on in this format.
I want to extract the number(s) of players and the style(s) from Info.Players for further processing or display as [!somefunction].
My first try was to simply splice off the first character of Info.Players (see below), but it's a dirty hack that doesn't cover two-digit numbers (Royal Ascot II has 12) nor styles or dual styles.
Code: [Select]
function playersStripped()
{
local pstrip = fe.game_info(Info.Players).slice(0,1);
return pstrip;
}
After doing some reading in http://www.squirrel-lang.org/doc/squirrel3.html I think about a combination of splice() and find(). But I'm a absolute beginner at Squirrel and need some (aka much) help with this. Ideally, the final result may help others in parsing the nplayers.ini.
Cheers
Favdeacon