Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Wenzon on June 06, 2019, 09:56:00 AM
-
I'm trying to develop a theme but I'm not good at programming. Would someone help me with a script that abbreviated the name of the display I'm using?
Example: Capcom Play System III for CPSIII.
Thank you all and sorry for my English.
-
split() and string.slice()
http://www.squirrel-lang.org/doc/squirrel3.html
-
I'm trying to develop a theme but I'm not good at programming. Would someone help me with a script that abbreviated the name of the display I'm using?
Example: Capcom Play System III for CPSIII.
Thank you all and sorry for my English.
someone helped me with this
[b] // System
for ( local i = 0; i < fe.displays.len(); i++ ) {
local filter = fe.displays[i];
local shortname = filter.name.toupper();
local offset = 90 * i;
switch(filter.name) {
//prefer known abbreviations
case "Sega Model 2":
shortname = "SM2";
break;
case "Sega Model 3":
shortname = "SM3";
break;
case "Sega Naomi":
shortname = "NAO";
break;
case "Commodore 64":
shortname = "C64";
break;
case "Nintendo Entertainment System":
shortname = "NES";
break;
case "Super Nintendo Entertainment System":
shortname = "SNES";
break;
case "Microsoft MSX":
shortname = "MSX";
break;
case "Sega Mega Drive":
shortname = "MD";
case "Nintendo DS":
shortname = "NDS";
break;
//grab the first three letters as the short name
default:
if (shortname.len() > 4)
shortname = shortname.slice(0, 4);
break;
}
local newfilt = fe.add_text(shortname, -98 + offset, 10, 300, 80);
newfilt.set_rgb( 255, 255, 255 );
newfilt.font = "CODE";
newfilt.charsize = 30;
newfilt.style = Style.Bold;
local underline = fe.add_image("images/red.png", 22 + offset, 70, 60, 3);
underline.set_rgb( 240, 0, 0 );
underline.visible = false ;
if (i == fe.list.display_index)
underline.visible = true;
ui_filters.push(newfilt);
ui_underline.push(underline);
}
fe.add_transition_callback( this, "on_transition" );[/b]
-
I'm trying to develop a theme but I'm not good at programming. Would someone help me with a script that abbreviated the name of the display I'm using?
Example: Capcom Play System III for CPSIII.
Thank you all and sorry for my English.
someone helped me with this
// System
for ( local i = 0; i < fe.displays.len(); i++ ) {
local filter = fe.displays[i];
local shortname = filter.name.toupper();
local offset = 90 * i;
switch(filter.name) {
//prefer known abbreviations
case "Sega Model 2":
shortname = "SM2";
break;
case "Sega Model 3":
shortname = "SM3";
break;
case "Sega Naomi":
shortname = "NAO";
break;
case "Commodore 64":
shortname = "C64";
break;
case "Nintendo Entertainment System":
shortname = "NES";
break;
case "Super Nintendo Entertainment System":
shortname = "SNES";
break;
case "Microsoft MSX":
shortname = "MSX";
break;
case "Sega Mega Drive":
shortname = "MD";
case "Nintendo DS":
shortname = "NDS";
break;
//grab the first three letters as the short name
default:
if (shortname.len() > 4)
shortname = shortname.slice(0, 4);
break;
}
local newfilt = fe.add_text(shortname, -98 + offset, 10, 300, 80);
newfilt.set_rgb( 255, 255, 255 );
newfilt.font = "CODE";
newfilt.charsize = 30;
newfilt.style = Style.Bold;
local underline = fe.add_image("images/red.png", 22 + offset, 70, 60, 3);
underline.set_rgb( 240, 0, 0 );
underline.visible = false ;
if (i == fe.list.display_index)
underline.visible = true;
ui_filters.push(newfilt);
ui_underline.push(underline);
}
fe.add_transition_callback( this, "on_transition" );
The script worked but did not show the name of the display I'm using.
In the figure below the display is Capcom Play System III and its script presented the abbreviation of ATOMISWAVE ("ATOM").
I struggled to see if I could run the script correctly but I did not master the programming language. Now in editing of image I dominate a little bit. :)
qqplayer's script is almost that. If you can help me, I'll be very grateful.
-
Sorry I forgot a to paste the most important part.
fe.add_transition_callback( this, "on_transition" );
function on_transition( ttype, var, ttime )
{
//Update filter highlight
for ( local i = 0; i < ui_underline.len(); i++ )
ui_underline[i].visible = false;
ui_underline[fe.list.display_index].visible = true;
}