Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: FrizzleFried on April 27, 2018, 07:26:53 AM
-
OK... here is my goal:
Currently I have a vertical layout that includes two arrows (left/right). They are, of course, static. I would like to create a 2nd set of arrows that looks like the first set but "depressed"... and then when someone selects the direction of the arrow, the "depressed" image pop up "over" the standard one giving the impression the arrow is being pushed when the direction is being selected. Also, the image has to remain on screen the entire time the "switch" is activated... so if they hold the stick to the left to scroll through the games, the button remains "activated" the entire time.
SO... I'm trying to come up with code that will make an image appear on screen in a specific location but ONLY while the switch is activated... when deactivated the image is to disappear.
Any suggestions?
Thanks!
I've uploaded an image of the current layout so you can get an idea for the arrows...
-
Not perfect but...
class PopUpImage
{
_my_imageleft=null;
_my_imageright=null;
constructor()
{
_my_imageleft = fe.add_image ("left.png",50,100,200, 200);
_my_imageleft.visible=false;
_my_imageright = fe.add_image ("right.png",450,100,200, 200);
_my_imageright.visible=false;
fe.add_signal_handler( this, "on_signal" )
}
function on_signal( signal )
{
if ( signal == "left" )
{
_my_imageleft.visible=!_my_imageleft.visible;
_my_imageright.visible=false;
return true;
}
else if ( signal == "right" )
{
_my_imageright.visible=!_my_imageright.visible;
_my_imageleft.visible=false;
return true;
}
return false;
}
}
local blah = PopUpImage();
http://forum.attractmode.org/index.php?topic=456.0
-
Updated liquid8 plugin for "two pngs"
class UserConfig </ help="This plugin will show a popup image when the specified key is pressed." /> {
</ label="Key", help="The key that will display the image", is_input="yes", order=2 />
key="";
</ label="Key2", help="The key that will display the image", is_input="yes", order=3 />
key2="";
</ label="Hold Key", help="If enabled, you must hold the key down", options="Yes,No", order=4 />
hold="No";
};
class PopUpImage
{
_image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
_image = fe.add_image("Arrow/left.png",50,100,200, 200);
_image.visible=false;
_image.preserve_aspect_ratio = true;
_key = config["key"];
_hold = config["hold"];
fe.add_ticks_callback( this, "on_tick" );
}
function on_tick( ttime )
{
local is_down = fe.get_input_state( _key );
if ( _hold == "Yes" )
{
_image.visible = is_down;
_showing = is_down;
} else
{
if ( is_down )
{
if ( ttime - _last_check > _key_delay )
{
_last_check = ttime;
_image.visible = !_showing;
_showing = !_showing;
}
}
}
}
}
fe.plugin[ "PopUpImage" ] <- PopUpImage();
class PopUpImage2
{
_image2 = null;
_key2 = null;
_hold = false;
_showing = false;
_key2_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
_image2 = fe.add_image("Arrow/right.png",450,100,200, 200);
_image2.visible=false;
_image2.preserve_aspect_ratio = true;
_key2 = config["key2"];
_hold = config["hold"];
fe.add_ticks_callback( this, "on_tick" );
}
function on_tick( ttime )
{
local is_down = fe.get_input_state( _key2 );
if ( _hold == "Yes" )
{
_image2.visible = is_down;
_showing = is_down;
} else
{
if ( is_down )
{
if ( ttime - _last_check > _key2_delay )
{
_last_check = ttime;
_image2.visible = !_showing;
_showing = !_showing;
}
}
}
}
}
fe.plugin[ "PopUpImage2" ] <- PopUpImage2();
Change this for what you need:
fe.add_image("Arrow/left.png",50,100,200, 200);
fe.add_image("Arrow/right.png",450,100,200, 200);
-
Updated liquid8 plugin for "two pngs"
class UserConfig </ help="This plugin will show a popup image when the specified key is pressed." /> {
</ label="Key", help="The key that will display the image", is_input="yes", order=2 />
key="";
</ label="Key2", help="The key that will display the image", is_input="yes", order=3 />
key2="";
</ label="Hold Key", help="If enabled, you must hold the key down", options="Yes,No", order=4 />
hold="No";
};
class PopUpImage
{
_image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
_image = fe.add_image("Arrow/left.png",50,100,200, 200);
_image.visible=false;
_image.preserve_aspect_ratio = true;
_key = config["key"];
_hold = config["hold"];
fe.add_ticks_callback( this, "on_tick" );
}
function on_tick( ttime )
{
local is_down = fe.get_input_state( _key );
if ( _hold == "Yes" )
{
_image.visible = is_down;
_showing = is_down;
} else
{
if ( is_down )
{
if ( ttime - _last_check > _key_delay )
{
_last_check = ttime;
_image.visible = !_showing;
_showing = !_showing;
}
}
}
}
}
fe.plugin[ "PopUpImage" ] <- PopUpImage();
class PopUpImage2
{
_image2 = null;
_key2 = null;
_hold = false;
_showing = false;
_key2_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
_image2 = fe.add_image("Arrow/right.png",450,100,200, 200);
_image2.visible=false;
_image2.preserve_aspect_ratio = true;
_key2 = config["key2"];
_hold = config["hold"];
fe.add_ticks_callback( this, "on_tick" );
}
function on_tick( ttime )
{
local is_down = fe.get_input_state( _key2 );
if ( _hold == "Yes" )
{
_image2.visible = is_down;
_showing = is_down;
} else
{
if ( is_down )
{
if ( ttime - _last_check > _key2_delay )
{
_last_check = ttime;
_image2.visible = !_showing;
_showing = !_showing;
}
}
}
}
}
fe.plugin[ "PopUpImage2" ] <- PopUpImage2();
Change this for what you need:
fe.add_image("Arrow/left.png",50,100,200, 200);
fe.add_image("Arrow/right.png",450,100,200, 200);
Got it working... thank you!
-
Welp, I do have a small issue. I am using the conveyor_helper mod to scroll through marquees.... I have an option for "FASTEST, FAST, MEDIUM, SLOW, and SLOWEST" as far as the scroll speed. Unfortunately, that scroll speed also affects how long it takes for the image to pop up using this code. It's fine for the FAST and FASTEST setting... the image almost immediately pops up because fastest is set for only 50 ms and FAST I believe is at 125... but when you get to MEDIUM there is a noticeable delay... by the time you get to SLOW or SLOWEST, well, the slowest setting is set for 450ms... so nearly a half second delay.
It doesn't sound like much, but when you are selecting a game, it's only taking 100ms-200ms to select "one game at a time"...
Is there any way to make this code ignore the conveyor_helper's scroll speed settings?
EDIT: Also, the code you posted prior works SOMEWHAT as well... it will turn on the image with left/right button presses, but then it requires a 2nd button press to turn it off... it doesn't automatically turn off the button when the button press ends.
-
Welp, I do have a small issue. I am using the conveyor_helper mod to scroll through marquees.... I have an option for "FASTEST, FAST, MEDIUM, SLOW, and SLOWEST" as far as the scroll speed. Unfortunately, that scroll speed also affects how long it takes for the image to pop up using this code. It's fine for the FAST and FASTEST setting... the image almost immediately pops up because fastest is set for only 50 ms and FAST I believe is at 125... but when you get to MEDIUM there is a noticeable delay... by the time you get to SLOW or SLOWEST, well, the slowest setting is set for 450ms... so nearly a half second delay.
It doesn't sound like much, but when you are selecting a game, it's only taking 100ms-200ms to select "one game at a time"...
Is there any way to make this code ignore the conveyor_helper's scroll speed settings?
EDIT: Also, the code you posted prior works SOMEWHAT as well... it will turn on the image with left/right button presses, but then it requires a 2nd button press to turn it off... it doesn't automatically turn off the button when the button press ends.
Post the complete code and some pics , I´m lost :)
-
Welp, I do have a small issue. I am using the conveyor_helper mod to scroll through marquees.... I have an option for "FASTEST, FAST, MEDIUM, SLOW, and SLOWEST" as far as the scroll speed. Unfortunately, that scroll speed also affects how long it takes for the image to pop up using this code. It's fine for the FAST and FASTEST setting... the image almost immediately pops up because fastest is set for only 50 ms and FAST I believe is at 125... but when you get to MEDIUM there is a noticeable delay... by the time you get to SLOW or SLOWEST, well, the slowest setting is set for 450ms... so nearly a half second delay.
It doesn't sound like much, but when you are selecting a game, it's only taking 100ms-200ms to select "one game at a time"...
Is there any way to make this code ignore the conveyor_helper's scroll speed settings?
EDIT: Also, the code you posted prior works SOMEWHAT as well... it will turn on the image with left/right button presses, but then it requires a 2nd button press to turn it off... it doesn't automatically turn off the button when the button press ends.
Post the complete code and some pics , I´m lost :)
Here's the layout.nut.
-
Welp, I do have a small issue. I am using the conveyor_helper mod to scroll through marquees.... I have an option for "FASTEST, FAST, MEDIUM, SLOW, and SLOWEST" as far as the scroll speed. Unfortunately, that scroll speed also affects how long it takes for the image to pop up using this code. It's fine for the FAST and FASTEST setting... the image almost immediately pops up because fastest is set for only 50 ms and FAST I believe is at 125... but when you get to MEDIUM there is a noticeable delay... by the time you get to SLOW or SLOWEST, well, the slowest setting is set for 450ms... so nearly a half second delay.
It doesn't sound like much, but when you are selecting a game, it's only taking 100ms-200ms to select "one game at a time"...
Is there any way to make this code ignore the conveyor_helper's scroll speed settings?
EDIT: Also, the code you posted prior works SOMEWHAT as well... it will turn on the image with left/right button presses, but then it requires a 2nd button press to turn it off... it doesn't automatically turn off the button when the button press ends.
Post the complete code and some pics , I´m lost :)
Here's the layout.nut.
But you also mod the conveyour_helper so wil be esier if you upload a beta version of your theme and the module too.
local glist = MyGameList();
Maybe you need to synchronize fade_speed with ms_speed
-
Welp, I do have a small issue. I am using the conveyor_helper mod to scroll through marquees.... I have an option for "FASTEST, FAST, MEDIUM, SLOW, and SLOWEST" as far as the scroll speed. Unfortunately, that scroll speed also affects how long it takes for the image to pop up using this code. It's fine for the FAST and FASTEST setting... the image almost immediately pops up because fastest is set for only 50 ms and FAST I believe is at 125... but when you get to MEDIUM there is a noticeable delay... by the time you get to SLOW or SLOWEST, well, the slowest setting is set for 450ms... so nearly a half second delay.
It doesn't sound like much, but when you are selecting a game, it's only taking 100ms-200ms to select "one game at a time"...
Is there any way to make this code ignore the conveyor_helper's scroll speed settings?
EDIT: Also, the code you posted prior works SOMEWHAT as well... it will turn on the image with left/right button presses, but then it requires a 2nd button press to turn it off... it doesn't automatically turn off the button when the button press ends.
Post the complete code and some pics , I´m lost :)
Here's the layout.nut.
But you also mod the conveyour_helper so wil be esier if you upload a beta version of your theme and the module too.
local glist = MyGameList();
Maybe you need to synchronize fade_speed with ms_speed
I'll package it up and send you a link via PM. Thanks
What APPEARS to already be affecting the delay for the image to appear is the delay associated with the "speed" setting of the conveyor_helper... the slower you set the conveyor, the long it takes for the image to appear on screen.
-
I am not sure if anything can be done about this...
It appears that the CONVEYOR_HELPER module takes over and STOPS all other scripts from running until it's completed it's task. So if you add a delay to it's task, then that delay will be added to the beginning of anything waiting for the conveyor_helper module to complete.
In another mod I use a starfield... when I move from one game to the other it pauses even the star field. I also have an animated marquee that doesn't even begin it's animation until after the conveyor_helper module completes it's task.
-
I am not sure if anything can be done about this...
It appears that the CONVEYOR_HELPER module takes over and STOPS all other scripts from running until it's completed it's task. So if you add a delay to it's task, then that delay will be added to the beginning of anything waiting for the conveyor_helper module to complete.
In another mod I use a starfield... when I move from one game to the other it pauses even the star field. I also have an animated marquee that doesn't even begin it's animation until after the conveyor_helper module completes it's task.
Testing the theme but still dont understand exactly whats the issue ;D
Your are talking about the time to "fade in" the snap?
-
when you press left and right, the arrows change colors. They are supposed to do so IMMEDIATELY. If you adjust the scroll speed it affects when those arrows change color... basically adding a delay before they change colors ... so with slower scroll speeds the delay is such that they never change colors unless you HOLD DOWN the left/right button.
One thing I forgot to mention... you need to go in to the DISPLAY settings and configure LEFT/RIGHT for it to start functioning...
-
I guess I'm at the point where I can simply ask...
Is there a way to prevent the conveyor_helper module from FREEZING everything else while it does it's task?
If I can figure out how to do that, I do believe it fixes more than one issue I am having.
:)
-
when you press left and right, the arrows change colors. They are supposed to do so IMMEDIATELY. If you adjust the scroll speed it affects when those arrows change color... basically adding a delay before they change colors ... so with slower scroll speeds the delay is such that they never change colors unless you HOLD DOWN the left/right button.
One thing I forgot to mention... you need to go in to the DISPLAY settings and configure LEFT/RIGHT for it to start functioning...
Are you testing this on a "powerfull" computer and with a keyboard?
I´ve set this:
layout_config Vertical Sphere_BETA
param glsel Dark
param glspeed Fastest
param hold Yes
param key left
param key2 right
But seems to work perfectly.
-
when you press left and right, the arrows change colors. They are supposed to do so IMMEDIATELY. If you adjust the scroll speed it affects when those arrows change color... basically adding a delay before they change colors ... so with slower scroll speeds the delay is such that they never change colors unless you HOLD DOWN the left/right button.
One thing I forgot to mention... you need to go in to the DISPLAY settings and configure LEFT/RIGHT for it to start functioning...
Are you testing this on a "powerfull" computer and with a keyboard?
I´ve set this:
layout_config Vertical Sphere_BETA
param glsel Dark
param glspeed Fastest
param hold Yes
param key left
param key2 right
But seems to work perfectly.
OK...set glspeed to SLOWEST... now note how long it takes for the yellow arrows to turn red when you move left and right.
THAT's the delay I'm referring to. No problem at FASTEST... the delay comes the SLOWER you set the scroll...
-
I see now , I think we need Arcadebliss or liquid8d help...
-
Usin transitions instead of signal will eliminate the need to configure buttons within attractmode config and your layout as well. Use a tick counter to see if game has not switched for specific amount of time to change visibility on overplayed image.