Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: malfacine on March 29, 2016, 09:24:59 AM
-
need help with script
{
local favs=fe.game_info(Info.Favourite);
local favart = fe.add_image("fav1.png", flx*0.01, fly*0.22, 30, 30 );
favart.preserve_aspect_ratio = true;
if ( favs == "1" )
{
favart.visible = true;
}
else
{
favart.visible = false;
}
}
dont work....
:-\ :(
-
I was having trouble with this last night.
This code I would expect to work:
if ( fe.game_info ( Info.Favourite ) ) {
// Do something
}
It should return a boolean value, not a string. Even assuming its a string as in your example proves to not work. I quit last night and its funny I see this post today.
-
Try:
fe.game_info(Info.Favourite, ioffset)
-
dont work
-
i forked the code of ArcadeBliss theme :P
class favicon
{
constructor()
{
local art_ref = fe.add_artwork("none");
local fav = fe.add_image( "favicon/"+my_config["favicon"]+".png", flx*0.00, fly*0.21, 60, 60 );
fav.visible = false;
favorite = fav;
}
function set_favorite()
{
local inf_fav=fe.game_info(Info.Favourite);
if (inf_fav=="1")
favorite.visible = true;
else
favorite.visible = false;
}
art_ref = null;
favorite = null;
}
class fav_con extends ConveyorSlot
{
constructor()
{
local fav = favicon();
base.constructor(fav);
}
}
local fav_s = [];
{
fav_s.append( fav_con() );
}
fe.add_transition_callback( "fav_renew" );
function fav_renew( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.EndNavigation:
{
foreach (fav in fav_s)
{
fav.m_obj.set_favorite();
}
}
break;
}
return false;
}
someone to help refine...
-
http://attractmode.org/docs/Layouts.html
fe.game_info()
fe.game_info( id )
fe.game_info( id, index_offset )
fe.game_info( id, index_offset, filter_offset )
Get information about the selected game.
Parameters:
id - id of the information attribute to get. Can be one of the following values:
Info.Name
Info.Title
Info.Emulator
Info.CloneOf
Info.Year
Info.Manufacturer
Info.Category
Info.Players
Info.Rotation
Info.Control
Info.Status
Info.DisplayCount
Info.DisplayType
Info.AltRomname
Info.AltTitle
Info.Extra
Info.Favourite
Info.Tags
Info.PlayedCount
Info.PlayedTime
Info.FileIsAvailable
Info.System
index_offset - the offset (from the current selection) of the game to retrieve info on. i.e. -1=previous game, 0=current game, 1=next game... and so on. Default value is 0.
filter_offset - the offset (from the current filter) of the filter containing the selection to retrieve info on. i.e. -1=previous filter, 0=current filter. Default value is 0.
Return Value:
A string containing the requested information.
My code example that does NOT WORK properly. The heart is displayed on every game, regardless of if it is indeed a favorite or not.
if ( fe.game_info ( Info.Favourite ) == "1" ) {
local favorite = fe.add_image ( "heart.png", 209, 2, 18, 18 );
}
When I add the following code, every game is returning a 1 for text. This makes no sense to me.
fe.add_text ( fe.game_info ( Info.Favourite ), 209, 2, 18, 18 );
-
@malfacine I figured out what was going on. The string returned was based on the game when the front end starts. It was not dynamically updated. If you use use a function with fe.add_image([!thisfunctionshouldreturntheimagepath], x, y, w, h), it should work dynamically. However, it does not work instantly when you add or remove favorite. Still working on that.
-
@malfacine I figured out what was going on. The string returned was based on the game when the front end starts. It was not dynamically updated. If you use use a function with fe.add_image([!thisfunctionshouldreturntheimagepath], x, y, w, h), it should work dynamically. However, it does not work instantly when you add or remove favorite. Still working on that.
I discovered that fe.game_info(Info.Favourite) need a fe.add_artwork as a reference for work
;)
-
Do you still need help? I am welcome to share my knowhow here
-
Do you still need help? I am welcome to share my knowhow here
i forked your code... I'm trying to refine it...
every help would be good ;D
solved the problem that makes your theme crash???
was giving a revised code on your...
-
paste you code so i can take a look
-
class favicon
{
constructor()
{
local art_ref = fe.add_artwork("none");
local fav = fe.add_image( "favicon/"+my_config["favicon"]+".png", flx*0.00, fly*0.21, 60, 60 );
local alpha_cfg =
{
when = Transition.ToNewSelection,
property = "alpha",
start = 0,
end = 255,
time = 800
}
animation.add( PropertyAnimation( fav, alpha_cfg ) );
fav.visible = false;
favorite = fav;
}
function set_favorite()
{
local inf_fav=fe.game_info(Info.Favourite);
if (inf_fav=="1")
favorite.visible = true;
else
favorite.visible = false;
}
art_ref = null;
favorite = null;
}
class fav_con extends ConveyorSlot
{
constructor()
{
local fav = favicon();
base.constructor(fav);
}
}
local fav_s = [];
{
fav_s.append( fav_con() );
}
fe.add_transition_callback( "fav_renew" );
function fav_renew( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.EndNavigation:
{
foreach (fav in fav_s)
{
fav.m_obj.set_favorite();
}
}
break;
}
return false;
}