Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: jedione on August 24, 2019, 07:26:25 AM

Title: script help
Post by: jedione on August 24, 2019, 07:26:25 AM
anyone know what might be missing to make this work...

what it should do.  is play a sound when one uses the custom2 key

Code: [Select]
class clickme
{

function sound1() {

local click = fe.add_sound("select.mp3");
click.playing=true;
}


function on_signal( signal )
        {
                if ( signal == "custom2" )
                {
                        sound1()
                        return true;
                }
                return false;
        }
}

local stuff = clickme();

i get error     the index 'loop' does not exist

thanks not the best at scripting... :P
Title: Re: script help,,solved
Post by: jedione on August 24, 2019, 07:59:54 AM
well did not get it yet,   so i borrowed some code from kents arcade theme and changed it...

this is doing the job....now

Code: [Select]
local sound =1;

function on_transition( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.EndNavigation:
case Transition.StartLayout:
case Transition.FromGame:
move_sound();
break;
}
}

function move_sound2() {
local click = fe.add_sound("select.mp3");
click.playing=true;
}

function on_signal( sig )
{
switch ( sig )
{
case "custom2":
if (sound == 1){
move_sound2()
}
return true;
default:
}
return false;
}

fe.add_signal_handler(this, "on_signal");