Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: BadFurDay on November 15, 2017, 05:30:39 PM
-
Hi everyone,
I'm wanting to use magic tokens with the command fe.do_nut so it will load a .nut file based on the display name. Is there anyway to do it as the way I thought would work doesn't, or even is there any workarounds to get it to do this?
Thanks for any help.
-
No. Look at layouts.md file on github. Magic tokens may only be used where explicitly stated. However, there are functions that will return the same data as a magic function. Browse through the markdown file, find the function you need, and include it within your file param within fe.do_nut(whatever_function_wil_return_your_info() + ".nut").
-
No. Look at layouts.md file on github. Magic tokens may only be used where explicitly stated. However, there are functions that will return the same data as a magic function. Browse through the markdown file, find the function you need, and include it within your file param within fe.do_nut(whatever_function_wil_return_your_info() + ".nut").
I'm sorry but can you point me in the right direction? Can't find this markdown file at all, where do I find it?
-
No. Look at layouts.md file on github. Magic tokens may only be used where explicitly stated. However, there are functions that will return the same data as a magic function. Browse through the markdown file, find the function you need, and include it within your file param within fe.do_nut(whatever_function_wil_return_your_info() + ".nut").
I'm sorry but can you point me in the right direction? Can't find this markdown file at all, where do I find it?
https://github.com/mickelson/attract/blob/master/Layouts.md
-
No. Look at layouts.md file on github. Magic tokens may only be used where explicitly stated. However, there are functions that will return the same data as a magic function. Browse through the markdown file, find the function you need, and include it within your file param within fe.do_nut(whatever_function_wil_return_your_info() + ".nut").
I'm sorry but can you point me in the right direction? Can't find this markdown file at all, where do I find it?
https://github.com/mickelson/attract/blob/master/Layouts.md
Thanks for your help so far. Looking through the layouts.md it would appear, to me at least, that both "fe.Display(name)" or "fe.game_info(Info.Emulator)" should return the information. Both just end up in the default layout that shows when something in the coding is completely wrong. Am I on the right track?
-
I've tried different variations of fe.do_nut(fe.game_info(Info.Emulator) + ".nut") and fe.do_nut(fe.Display(name) + ".nut") including fe.displays and neither work. My knowledge of coding this stuff is minimal and I usually just copy and paste previous work tweaking it to my liking. Unfortunately with this I am totally stumped, I don't know why or how it works so I can't get my head around it. Really no clue hoping someone can just show me how this is done please.
-
I've tried different variations of fe.do_nut(fe.game_info(Info.Emulator) + ".nut") and fe.do_nut(fe.Display(name) + ".nut") including fe.displays and neither work. My knowledge of coding this stuff is minimal and I usually just copy and paste previous work tweaking it to my liking. Unfortunately with this I am totally stumped, I don't know why or how it works so I can't get my head around it. Really no clue hoping someone can just show me how this is done please.
Try fe.do_nut(fe.list.name + ".nut"); Let me know if it works or not. I'm not at home. Print it to console to check and isolate the issue.
-
I used this before without any issue:
//replace specified magic tokens in path
function get_magic_token_path(path) {
local tokens = {
"Name": fe.game_info(Info.Name),
"Emulator": fe.game_info(Info.Emulator),
"Year": fe.game_info(Info.Year),
"Manufacturer": fe.game_info(Info.Manufacturer),
"Category": fe.game_info(Info.Category),
"System": fe.game_info(Info.System),
"DisplayName": fe.list.name
}
foreach( key, val in tokens)
path = replace(path, "[" + key + "]", val);
//replace slashes with backslashes
path = replace(path, "\\", "/");
//ensure trailing slash
local trailing = path.slice(path.len() - 1, path.len());
if ( trailing != "/") path += "/";
return path;
}
//replace all instances of 'find' in 'str' with 'repl'
function replace(str, find, repl) {
local start = str.find(find);
if ( start != null ) {
local end = start + find.len();
local before = str.slice(0, start);
local after = str.slice(end, str.len());
str = before + repl + after;
str = replace(str, find, repl);
}
return str;
}
But your problem may be that you are trying to load the .nut before AM has that info.
Try doing this before you load .nut:
local filename = fe.list.name + ".nut";
print( filename + "\n" );
You might have to use a transition callback and catch the Transition.StartLayout or Transition.ToNewList or whatever you need, where that information will be available.
That may put a kink in your plans, depending on what you are trying to do in the .nut
-
I've tried different variations of fe.do_nut(fe.game_info(Info.Emulator) + ".nut") and fe.do_nut(fe.Display(name) + ".nut") including fe.displays and neither work. My knowledge of coding this stuff is minimal and I usually just copy and paste previous work tweaking it to my liking. Unfortunately with this I am totally stumped, I don't know why or how it works so I can't get my head around it. Really no clue hoping someone can just show me how this is done please.
Try fe.do_nut(fe.list.name + ".nut"); Let me know if it works or not. I'm not at home. Print it to console to check and isolate the issue.
This worked a treat! Thanks for your input too though liquid8d. I'm basically trying to put all the robospin themes made by Cosmo and myself (in the themes section of this forum) into one layout. I'm using this command to bring up a separate .nut file with all the system/display specific stuff like snap position, but the main layout has the generic stuff like wheel and game information settings. Hoping this means that using the themes and customising them will be much easier for people. Does appear to cause a slightly longer loading time (on the Pi at least) though nothing too noticeable.
-
Couple more questions, the first one isn't major but the second one would be good to know:
1) Can I add a folder to the fe.do_nut(fe.list.name + ".nut"); line so I can put the extra files in a separate folder i.e. fe.do_nut(nuts/fe.list.name + ".nut"); (but this doesn't work).
2) Can I add a Transition.StartLayout to the fe.do_nut as currently scrolling through the displays with a button press means the same .nut is active instead of loading the new one to mach the new display/display name.
Thanks again.
-
Couple more questions, the first one isn't major but the second one would be good to know:
1) Can I add a folder to the fe.do_nut(fe.list.name + ".nut"); line so I can put the extra files in a separate folder i.e. fe.do_nut(nuts/fe.list.name + ".nut"); (but this doesn't work).
2) Can I add a Transition.StartLayout to the fe.do_nut as currently scrolling through the displays with a button press means the same .nut is active instead of loading the new one to mach the new display/display name.
Thanks again.
1. If your parameter is not a variable, it needs to be enclosed in quotes. Wrap your nuts and you will be fine. Lol "nuts/" + nutsvar + ".nut"
2. I don't understand what you are trying to do.
-
Couple more questions, the first one isn't major but the second one would be good to know:
1) Can I add a folder to the fe.do_nut(fe.list.name + ".nut"); line so I can put the extra files in a separate folder i.e. fe.do_nut(nuts/fe.list.name + ".nut"); (but this doesn't work).
2) Can I add a Transition.StartLayout to the fe.do_nut as currently scrolling through the displays with a button press means the same .nut is active instead of loading the new one to mach the new display/display name.
Thanks again.
1. If your parameter is not a variable, it needs to be enclosed in quotes. Wrap your nuts and you will be fine. Lol "nuts/" + nutsvar + ".nut"
2. I don't understand what you are trying to do.
I'll be sure to wrap my nuts lol.
It's for when you scroll through the displays with a button press, it doesn't "reload " the layout so it causes the old background and snap/boxart settings to carry over too which is what I have loading in this separate display name .nut file. I can share what I've done so far if that helps.
-
Couple more questions, the first one isn't major but the second one would be good to know:
1) Can I add a folder to the fe.do_nut(fe.list.name + ".nut"); line so I can put the extra files in a separate folder i.e. fe.do_nut(nuts/fe.list.name + ".nut"); (but this doesn't work).
2) Can I add a Transition.StartLayout to the fe.do_nut as currently scrolling through the displays with a button press means the same .nut is active instead of loading the new one to mach the new display/display name.
Thanks again.
1. If your parameter is not a variable, it needs to be enclosed in quotes. Wrap your nuts and you will be fine. Lol "nuts/" + nutsvar + ".nut"
2. I don't understand what you are trying to do.
I'll be sure to wrap my nuts lol.
It's for when you scroll through the displays with a button press, it doesn't "reload " the layout so it causes the old background and snap/boxart settings to carry over too which is what I have loading in this separate display name .nut file. I can share what I've done so far if that helps.
Ok, I understand now. I do not use displays. So there might be a better way. However, I would try creating a transition and reloading the layout via signal?
-
I've tried to us: fe.do_nut("nuts/" + fe.list.name + ".nut"); and it didn't work I'm afraid.
I've also tried to play about with signals previously and failed miserably. My experience with scripting is basically copying and pasting what has been done previously but manipulating it to try get it to work. Anything from scratch I'm pretty useless.
-
Can anyone help me to make the fe.do_nut apply/reload every time the display is changed?
-
I've tried to us: fe.do_nut("nuts/" + fe.list.name + ".nut"); and it didn't work I'm afraid.
I've also tried to play about with signals previously and failed miserably. My experience with scripting is basically copying and pasting what has been done previously but manipulating it to try get it to work. Anything from scratch I'm pretty useless.
Print to console the fe.list.name variable and see what the result is.
-
I've tried to us: fe.do_nut("nuts/" + fe.list.name + ".nut"); and it didn't work I'm afraid.
I've also tried to play about with signals previously and failed miserably. My experience with scripting is basically copying and pasting what has been done previously but manipulating it to try get it to work. Anything from scratch I'm pretty useless.
Print to console the fe.list.name variable and see what the result is.
I don't know how to do this, apologies.
-
I've tried to us: fe.do_nut("nuts/" + fe.list.name + ".nut"); and it didn't work I'm afraid.
I've also tried to play about with signals previously and failed miserably. My experience with scripting is basically copying and pasting what has been done previously but manipulating it to try get it to work. Anything from scratch I'm pretty useless.
Print to console the fe.list.name variable and see what the result is.
Can anyone help me with this? It's one big stumbling block to finishing the theme and sharing it.