2
« on: June 06, 2020, 06:17:20 AM »
Hey All - Total Noob question here that I have not been able to answer or find an answer to in the forum:
I have several Displays that all use the same layout.nut file. The difference between the displays is each has a filter against the ROM list so that "Platform Games" are separated from "Maze Games", etc. This way, moving the joystick right/left moves between displays and therefor between game categories. All of this works fine.
Here's what I'm trying to accomplish: Display a different graphic on the screen when the display "Favorite Games" is displayed. (This graphic contains instructions informing the player which buttons to press to remove the selected game from the favorites list whereas the graphic for the other displays contains instructions informing the player which buttons to press to add the selected game to the favorites list).
Here's what I can't solve: I've constructed an IF statement to make a decision based on the name of the display - If display name is "Favorite Games" then show this graphic, if not, show the other. I cannot figure out how to construct the IF statement that can dynamically read the CURRENT display name. I've tried various methods to get at the current display name and while I can display the correct, current display name on the screen (both of these fe.add_text display the correct, current display name) using methods below I cannot figure out how to assign the current display name to a local or use it in an IF statement.
These statements display the current display name but I don't know how to assign them for use in an IF statement:
local control = fe.add_text( "Token: "+"[DisplayName]", 0, 30, 800, 15 );
local print_display = fe.add_text( "!dname: [!dname]", 0, 45, 800, 15 );
function dname()
{
local fct_current_display = fe.displays[fe.list.display_index];
return fct_current_display.name;
}
I'm trying to do something like this:
function disp_graphic()
{
local current_display_for_graphic = fe.displays[fe.list.display_index];
if ( current_display_for_graphic.name == "Favorite Games" )
{
local game_type = fe.add_image( "instructions/remove.png", 0, 540, 1024, 360 );
} else {
local game_type = fe.add_image( "instructions/add.png", 0, 540, 1024, 360 );
}
return current_display_for_graphic.name;
}
// Execute the function disp_graphic()
local test_this_function = disp_graphic();
Everything else I've tried only brings back the name of the initial display at start up time and the IF statement above works but doesn't change when moving from display to display. It seems like I'm struggling with two things: 1) local assignment of the string from the Token to a local variable upon which to make a decision on and/or 2) getting after the "right" thing to get the current display after the display has changed.
Any help would be appreciated.
My programming experience is super old and rusty (Think COBOL and early Client-Server, Visual Basic stuff) but I can usually muddle through! Thanks for the help!