Author Topic: [HELP] Function Control  (Read 4461 times)

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
[HELP] Function Control
« on: May 31, 2020, 07:46:26 PM »
Hello All, i'm using a module that I found here in the group "AM Controls Module v1.0", I'm modifying it to work as I want, an example when I'm in the layout and press "Enter - select" it opens the menu on the left side, scroll until down in "Launch" I press "Enter" again it simply closes the menu and does not start the game, could someone help me with this code, what I would like to do and when selecting the game the menu appears and after pressing " Enter "the game starts from the menu and not directly from the layout.

Code: [Select]
function control_signals( signal ){

if (signal == "select"){

if (menu.visible) hide_menu();
else show_menu();
return true;

}

else if ( signal == "back" ){

if (manager.enabled) hide_menu();
else if (menu.visible) menu_hide(); else return
return true;
}
return false;
}

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
Re: [HELP] Function Control
« Reply #1 on: June 01, 2020, 05:36:09 AM »

Can someone help me please?

sickle

  • Full Member
  • ***
  • Posts: 65
    • View Profile
Re: [HELP] Function Control
« Reply #2 on: June 02, 2020, 10:14:45 PM »
in your code, it says, if the menu is visible, hide the menu when you click enter (I assume the "hide_menu()" function has nothing about selecting a game in it):
Code: [Select]
if (signal == "select"){

if (menu.visible) hide_menu();
else show_menu();
return true;

}


remove "hide_menu()" and replace it with fe.signal( select )




for more context read this: http://attractmode.org/docs/Layouts.html#signal

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: [HELP] Function Control
« Reply #3 on: June 03, 2020, 04:18:57 AM »
@OP I am using control module like this:

Code: [Select]
//Custom Overlay: Game Info & Options Menu: Control Module: Signal Handlers
function start_menu()
{
g_surface.visible = true;
manager.enabled = true;
}

function stop_menu()
{
g_surface.visible = false;
manager.enabled = false;
}

function start_menu2()
{
g_surface2.visible = true;
manager2.enabled = true;
}

function stop_menu2()
{
g_surface2.visible = false;
manager2.enabled = false;
}

function cmenu_start()
{
manager.enabled = true;
}

function cmenu_stop()
{
manager.enabled = false;
}

function cmenu2_start()
{
manager2.enabled = true;
}

function cmenu2_stop()
{
manager2.enabled = false;
}

function g_surface_show()
{
g_surface.visible = true;
}

function g_surface_hide()
{
g_surface.visible = false;
}

function g_surface2_show()
{
g_surface2.visible = true;
}

function g_surface2_hide()
{
g_surface2.visible = false;
}

function control_signals( signal )
{
if (signal == "select")
{
if (manager.enabled) return; else start_menu();
return true;
}
else if ( signal == "back" )
{
if (manager.enabled) cmenu_stop();
else if (manager2.enabled) stop_menu2();
else if (g_surface.visible) g_surface_hide();
else if (g_surface2.visible) g_surface2_hide(); else return
return true;
}
else if (signal == "custom2")
{
if (g_surface2.visible) stop_menu2(); else start_menu2();
return true;
}
return false;
}

fe.add_signal_handler("control_signals");

//Game: info Panel: Control Module: Iniitialize Controls Manager
manager.init();
manager2.init();

The complete file is here, control module related code is near the end > https://raw.githubusercontent.com/randombyt/RetroDiction/master/layouts/retrodiction/layout_system.nut

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
Re: [HELP] Function Control
« Reply #4 on: June 04, 2020, 03:14:23 PM »
@OP I am using control module like this:

Code: [Select]
//Custom Overlay: Game Info & Options Menu: Control Module: Signal Handlers
function start_menu()
{
g_surface.visible = true;
manager.enabled = true;
}

function stop_menu()
{
g_surface.visible = false;
manager.enabled = false;
}

function start_menu2()
{
g_surface2.visible = true;
manager2.enabled = true;
}

function stop_menu2()
{
g_surface2.visible = false;
manager2.enabled = false;
}

function cmenu_start()
{
manager.enabled = true;
}

function cmenu_stop()
{
manager.enabled = false;
}

function cmenu2_start()
{
manager2.enabled = true;
}

function cmenu2_stop()
{
manager2.enabled = false;
}

function g_surface_show()
{
g_surface.visible = true;
}

function g_surface_hide()
{
g_surface.visible = false;
}

function g_surface2_show()
{
g_surface2.visible = true;
}

function g_surface2_hide()
{
g_surface2.visible = false;
}

function control_signals( signal )
{
if (signal == "select")
{
if (manager.enabled) return; else start_menu();
return true;
}
else if ( signal == "back" )
{
if (manager.enabled) cmenu_stop();
else if (manager2.enabled) stop_menu2();
else if (g_surface.visible) g_surface_hide();
else if (g_surface2.visible) g_surface2_hide(); else return
return true;
}
else if (signal == "custom2")
{
if (g_surface2.visible) stop_menu2(); else start_menu2();
return true;
}
return false;
}

fe.add_signal_handler("control_signals");

//Game: info Panel: Control Module: Iniitialize Controls Manager
manager.init();
manager2.init();

The complete file is here, control module related code is near the end > https://raw.githubusercontent.com/randombyt/RetroDiction/master/layouts/retrodiction/layout_system.nut


Thanks for the answer, but in reality what i wanted is to put the command "Select" to open the menu, and the same command "Select" to start the game, a key for 2 functions pressing "Select" opens the menu and pressing "Select "again starts the game.

sickle

  • Full Member
  • ***
  • Posts: 65
    • View Profile
Re: [HELP] Function Control
« Reply #5 on: June 04, 2020, 09:33:32 PM »
try something simple like this:
Code: [Select]
function minimenu (str){
if (str=="select")
if (minimenu == false){
minimenu==true
}
elseif (minimenu == true){
fe.signal(select)
}
}

if thats having some probs, change your action button to custom (str to "custom1-4")

arthurvalenca

  • Sr. Member
  • ****
  • Posts: 125
    • View Profile
Re: [HELP] Function Control
« Reply #6 on: June 08, 2020, 04:30:14 PM »
try something simple like this:
Code: [Select]
function minimenu (str){
if (str=="select")
if (minimenu == false){
minimenu==true
}
elseif (minimenu == true){
fe.signal(select)
}
}


it worked perfectly, thank you very much you solved my problem.

 :) ;)

if thats having some probs, change your action button to custom (str to "custom1-4")