Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: 8bitsdeep on January 29, 2017, 09:28:33 AM
-
I'd like to change some colors used in my layout based on which system's games are currently displayed.
I tried:
switch("[System]")
{
case "NES":
t.set_rgb(255,0,0);
break;
}
"[System]" outputs the text "NES" as expected when used in an add_text call, but doesn't seem to work in a conditional. I also tried removing the quotes around [System].
Is there a way to do this?
-
You are correct, magic tokens don't work directly in code, only as parameters for certain AM functions.
You want fe.list, which is the current list (Display) instance:
https://github.com/mickelson/attract/blob/master/Layouts.md#CurrentList
fe.list.name should get what you want.
-
Thanks!
That works. Only issue is, when switching directly between lists with left/right, the value doesn't change. If I back out to the Displays Menu and select a console that way, then it updates fe.list.name.
Is there some way to force an update on transistion?
-
Yep :)
https://github.com/mickelson/attract/blob/master/Layouts.md#add_transition_callback
fe.add_transition_callback(this, "on_transition")
function on_transition(ttype, var, ttime) {
if ( ttype == Transition.ToNewList ) {
local name = fe.list.name
//...
}
return false
}
-
Perfect! Works like a charm now. Thanks much! :D