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