• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Modifying Custom Pause Menu Issue

maxman

Well-known member
The custom pause menu script which was created by @Kratus himself, works wonders! It really works for my Street Fighter project and any other mod. However, it doesn't display itself in my Rhythm of Destruction mod. Despite using the same code from both the template and my SF project, it doesn't show in ROD.

This is my update.c for ROD.
C:
#import "data/scripts/dc_bug_patch/continue_timer.c"
//#import "data/scripts/menu/pauseMenu.c"

void oncreate()
{
}

void ondestroy()
{
}

void main()
{
    /*
    * Execute the bug patch function.
    * The numeric value is allowed
    * continue time in game seconds.
    * Native engine default is 10.
    */
    int continue_time = 20;

    dc_continue_bug_patch(continue_time);

    LastNumber();
    //titleMusic();
    if(pausingGo()) result;
}

void titleMusic()
{
    if(openborvariant("in_menuscreen") || openborvariant("in_titlescreen"))
    {      
        if(getlocalvar("MusicMenu") == NULL())
        {
            playmusic("Data/Music/versus.bor", 1);
            setlocalvar("MusicMenu", 1);
        }
    }
    else {if(getlocalvar("MusicMenu") != NULL()) setlocalvar("MusicMenu", NULL());}
}

void LastNumber()
{
    //if(pausingGo()) return;

    if(openborvariant("in_level"))
    {
        int P1 = getplayerproperty(0, "entity");
        int P2 = getplayerproperty(1, "entity");
        int P1Life = getplayerproperty(0, "lives");
        int P2Life = getplayerproperty(1, "lives");

        if(P1)
        {
            drawstring(131, 2, 3, P1Life-1);
        }

        if(P2)
        {
            drawstring(311, 2, 3, P2Life-1);
        }

    }
}

void pausingGo()
{
    //NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN
    if(openborvariant("in_titlescreen")){
        if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
    }

    //CHECK IF THE PLAYER IS IN A LEVEL
    if(openborvariant("in_level")){
        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;
        int menuPause    = getglobalvar("menuPause");
        int max            = 3;
        int min            = 0;
        int add            = 1;

        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        if(openborvariant("game_paused") && !openborvariant("in_options")){

            //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
            if(    playerkeys(0, 1, "movedown")||
                playerkeys(1, 1, "movedown")||
                playerkeys(2, 1, "movedown")||
                playerkeys(3, 1, "movedown")){
              
                if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
                if(menuPause == max){setglobalvar("menuPause", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
              
                if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
                if(menuPause == min){setglobalvar("menuPause", max);}
            }

            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if(    playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
              
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);

                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(0, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(1, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(2, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(3, "newkeys", openborconstant("FLAG_START"));
                }

                //OPTIONS
                if(menuPause == 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }

                //HOW TO PLAY
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("menuPause", 0);
                    playgif("data/scenes/howto.gif");
                }

                //END GAME
                if(menuPause == 3){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(0, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(1, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(2, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(3, "newkeys", openborconstant("FLAG_START"));
                }
            }

            //TEXTS, IMAGES AND EFFECTS
            void str;
            float hRes        = openborvariant("hresolution");
            int align;
            int yPos        = 80;
            int fontPause    = 3;
            int font0        = 0;
            int font1        = 0;
            int font2        = 0;
            int font3        = 0;
            int yAdd        = 11;
            int layer        = 50000000; //-1000000003;

            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
            if(getglobalvar("menuPause") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPause") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPause") == 2){font2 = 1;}else    //IS HOW TO PLAY HIGHLIGHTED??
            if(getglobalvar("menuPause") == 3){font3 = 1;}        //IS END GAME HIGHLIGHTED??

            str = "Pause";align = (hRes-(strwidth(str, fontPause)))/2;
            drawstring(align, yPos, fontPause, str, layer);

            yPos = yPos+yAdd*3;
            str = "Continue";align = (hRes-(strwidth(str, font0)))/2;
            drawstring(align, yPos, font0, str, layer);

            yPos = yPos+yAdd;
            str = "Options";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);

            yPos = yPos+yAdd;
            str = "How To Play";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);

            yPos = yPos+yAdd;
            str = "End Game";align = (hRes-(strwidth(str, font3)))/2;
            drawstring(align, yPos, font3, str, layer);
        }

        //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
        if(openborvariant("game_paused") && openborvariant("in_options")){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
        }

        //NECESSARY STEPS THAT NEEDS TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
        //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUNS OUTSIDE OF THE PAUSE MENU
        if(!openborvariant("game_paused") && !openborvariant("in_options")){

            //END GAME
            if(menuPause == 3){gameover();}
        }
    }
}

I don't understand why it's not working at all.

Another issue I have is that I'm trying to include a certain model as a music option or something else. And I have to press anybutton and then escape button, to look at the music menu. Sometimes, I press "anybutton", "start", and then "escape", just to look at it too. I removed playgif and (excluded) setglobalvar("menuPause", 0) from the 3rd option, so I could input the music menu as an option in the pause menu.

Here is the invisible music entity as a list of music selection.
C:
name MusicSelect
type text
shadow 0

anim idle
@script
    void self = getlocalvar("self");
    int index = getentityproperty(self, "playerindex");
    void up = playerkeys(index, 0, "moveup");
    void down = playerkeys(index, 0, "movedown");
    void pick = playerkeys(index, 0, "anybutton");

    int Cframe = getentityproperty(self, "animpos");

    if(frame >= 1)
    {
        if(Cframe == 3 && down){updateframe(self, 4);}// NO SOUND TO BEGIN
        if(Cframe == 6 && up){updateframe(self, 7);} // SOUND TO GO UP
        if(Cframe == 9 && down){updateframe(self, 4);} // SOUND TO GO DOWN

        if(Cframe == 3 && pick){fademusic(0.5, "data/music/dojo/001.ogg", 1, 470767.5); updateframe(self, 24); }
        if(Cframe == 6 && pick){fademusic(0.5, "data/music/dojo/002.ogg", 1, 43526.7); updateframe(self, 24); }
        if(Cframe == 9 && pick){fademusic(0.5, "data/music/dojo/001.ogg", 1, 470767.5); updateframe(self, 24); }
    }

@end_script
    delay 11
    offset 1 1
    frame data/chars/0misc/empty.gif # 0
    @cmd settextobj 0 60 50 1 999999999 "001"
    @cmd settextobj 1 60 60 0 999999999 "002"
    frame data/chars/0misc/empty.gif # 1
    frame data/chars/0misc/empty.gif # 2
    @cmd updateframe getlocalvar("self") 2
    frame data/chars/0misc/empty.gif # 3
    sound data/sounds/beep.wav
    @cmd settextobj 0 60 50 0 999999999 "001"
    @cmd settextobj 1 60 60 1 999999999 "002"
    frame data/chars/0misc/empty.gif # 4
    frame data/chars/0misc/empty.gif # 5
    @cmd updateframe getlocalvar("self") 5
    frame data/chars/0misc/empty.gif # 6
    sound data/sounds/beep.wav
    frame data/chars/0misc/empty.gif # 7
    @cmd settextobj 0 60 50 1 999999999 "001"
    @cmd settextobj 1 60 60 0 999999999 "002"
    frame data/chars/0misc/empty.gif # 8
    @cmd updateframe getlocalvar("self") 8
    frame data/chars/0misc/empty.gif # 9
    sound data/sounds/beep.wav
    frame data/chars/0misc/empty.gif # 10
    @cmd settextobj 0 60 50 0 999999999 "001"
    @cmd settextobj 1 60 60 1 999999999 "002"
    frame data/chars/0misc/empty.gif # 11
    @cmd updateframe getlocalvar("self") 11
    frame data/chars/0misc/empty.gif # 12
    frame data/chars/0misc/empty.gif # 13
    frame data/chars/0misc/empty.gif # 14
    frame data/chars/0misc/empty.gif # 15
    frame data/chars/0misc/empty.gif # 16
    frame data/chars/0misc/empty.gif # 17
    frame data/chars/0misc/empty.gif # 18
    frame data/chars/0misc/empty.gif # 19
    frame data/chars/0misc/empty.gif # 20
    frame data/chars/0misc/empty.gif # 21
    frame data/chars/0misc/empty.gif # 22
    frame data/chars/0misc/empty.gif # 23
    frame data/chars/0misc/empty.gif # 24
    frame data/chars/0misc/empty.gif # 25
    frame data/chars/0misc/empty.gif # 26
    frame data/chars/0misc/empty.gif # 27
    delay 2
    @cmd cleartextobj 0
    @cmd cleartextobj 1
    @cmd killentity getlocalvar("self")
    frame data/chars/0misc/empty.gif # 28
    frame data/chars/0misc/empty.gif # 29

update.c:
C:
void main()
{
    //SONG SELECTION IN THE PAUSE MENU ONLY IN THE THIRD GAME MODE
    if(openborvariant("in_titlescreen")){
        if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
    }

    //CHECK IF THE PLAYER IS IN THE THIRD GAME MODE
    if(openborvariant("in_level") && openborvariant("current_set") == 2){

        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;
        int menuPause    = getglobalvar("menuPause");
        int max            = 3;
        int min            = 0;
        int add            = 1;

        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        if(openborvariant("game_paused") && !openborvariant("in_options")){

            //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
            if(    playerkeys(0, 1, "movedown")||
                playerkeys(1, 1, "movedown")||
                playerkeys(2, 1, "movedown")||
                playerkeys(3, 1, "movedown")){
              
                if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
                if(menuPause == max){setglobalvar("menuPause", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
              
                if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
                if(menuPause == min){setglobalvar("menuPause", max);}
            }

            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if(    playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
              
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);

                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    //changeplayerproperty(0, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(1, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(2, "newkeys", openborconstant("FLAG_START"));
                    //changeplayerproperty(3, "newkeys", openborconstant("FLAG_START"));
                }

                //OPTIONS
                if(menuPause == 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }

                //HOW TO PLAY
                /*
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("menuPause", 0);
                    playgif("data/scenes/howto.gif");
                }
                */

              
                //SELECT MUSIC
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    //setglobalvar("menuPause", 0);
                    void vSpawn = spawn();
                    loadmodel("MusicSelect");
                    setspawnentry("name", "MusicSelect");
                }
              

                //END GAME
                if(menuPause == 3){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
            }

            //TEXTS, IMAGES AND EFFECTS
            void str;
            float hRes        = openborvariant("hresolution");
            int align;
            int yPos        = 80;
            int fontPause    = 3;
            int font0        = 0;
            int font1        = 0;
            int font2        = 0;
            int font3        = 0;
            int yAdd        = 11;
            int layer        = -1000000003;

            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
            if(getglobalvar("menuPause") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPause") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPause") == 2){font2 = 1;}else    //IS SELECT MUSIC HIGHLIGHTED??
            if(getglobalvar("menuPause") == 3){font3 = 1;}        //IS END GAME HIGHLIGHTED??

            str = "Pause";align = (hRes-(strwidth(str, fontPause)))/2;
            drawstring(align, yPos, fontPause, str, layer);

            yPos = yPos+yAdd*3;
            str = "Continue";align = (hRes-(strwidth(str, font0)))/2;
            drawstring(align, yPos, font0, str, layer);

            yPos = yPos+yAdd;
            str = "Options";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);

            yPos = yPos+yAdd;
            str = "Select Music";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);

            yPos = yPos+yAdd;
            str = "End Game";align = (hRes-(strwidth(str, font3)))/2;
            drawstring(align, yPos, font3, str, layer);
        }

        //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
        if(openborvariant("game_paused") && openborvariant("in_options")){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
        }

        //NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
        //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
        if(!openborvariant("game_paused") && !openborvariant("in_options")){

            //END GAME
            if(menuPause == 3){gameover();}
        }
    }
}

I don't like when I have to press any button on a different option, and then the escape button after. I want to press any button on that particular option like I do to any option in the pause menu. How can I achieve pressing any button effortlessly without requiring button combinations? The music menu is a text type entity.

8-4-2023 12-50-34 PM.png

FFp_demo_001 - 0012.png
 
Last edited:
I am having a blast with these global variables after creating them from scratch and setting them to suit my needs in keyall.c
Yeah, did you see how it's a lot better to build systems from scratch? Now you are entering on another level which opens many new possibilities for all your projects, it's very cool :)
Keep training and making tests to the point where just by understanding a code concept will be enough for you to develop your own version from scratch.

I think it's gonna be a little bit tough when it comes to creating another condition in the pause menu, but I can give a try
This is why I suggested creating a music menu separated from the pause menu, like a jukebox concept. I saw it working fine in your video, I think this is the way to go.
 
Hey Kratus. I have another question regarding changing the background skin for a particular level or game mode. I created a new attempted script for changing the background skin. It's not crashing anymore after I had trials and errors to fix it. But I have a problem with spawning a certain entity with a given function in keyall. When I press Attack4 to call the entity to spawn, it doesn't appear at all. Here's what I got.

C:
#import "data/scripts/spawn004.c"

void main(){
    int player = getlocalvar("player");
    variableFlag(player);
    variableChange(player);
    variTest(player);
    variPause(player);
    variChangeStage(player); // NEW
}

void variChangeStage(int player){
    if(openborvariant("in_level")){
        int welian    = getglobalvar("welian"); //CHANGE BACKGROUND OR WHATEVER
        void vSpawn; // = spawn004(vName, vAlias, vMap, fX, fY, fZ, iAdjust, iDirection, vAni3, iFrame);
        if(playerkeys(player, 1, "attack4")){
            clearspawnentry();
            loadmodel("Bakraun1");
            setspawnentry("name", "Bakraun1");
            if(welian == NULL()){
                setglobalvar("welian", 1);
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                //changeentityproperty(vSpawn, "animation", openborconstant("ANI_IDLE"));
                //if(vAni3 == openborconstant("ANI_IDLE")){
                //    setglobalvar("welian", 1);
                //}
            }else{
                //changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW"));
                setglobalvar("welian", NULL());
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_FOLLOW1"), 0);
            }
        }
    }
}

spawn004.c:
C:
void main(){
    spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
}

void spawn004(void vName, void vAlias, int vMap, float fX, float fY, float fZ, int iAdjust, int iDirection, void vAni3, int iFrame){

    //spawn003
    //Damon Vaughn Caskey
    //08/28/2007
    //
    //Calls spawn001 and adds direction adjustment. See spawn001 for parameters.
    void vSpawn = spawn001(vName, vAlias, vMap, fX, fY, fZ, iAdjust);
    void vParent = getentityproperty(vSpawn, "parent");
    int iDir = getentityproperty(vParent, "direction");

    if (iDirection == 1){ //Direction setting 1 (Opposing target)?
 
        if (iDir){ //Facing left?

            iDirection = 0; //Force right facing.

        }else{ //Facing right?

            iDirection = 0; //Force left facing.

        }

    }else if (iDirection == 2){ //Direction setting 2 (left)?

        iDirection = 0; //Force left facing.

    }else if (iDirection == 3){ //Direction setting 3 (right)?

        iDirection = 0; //Force right facing.

    }else if (iDirection == 0 || !(iDirection)){ //Direction setting 0 (same as target)?

        iDirection = iDir; //Force facing same as target.
 
    }
 
    changeentityproperty(vSpawn, "direction", iDirection); //Adjust spawn direction.
    changeentityproperty(vSpawn, "animation", vAni3);
    changeentityproperty(vSpawn, "animpos", iFrame);

    return vSpawn;
 
}

void spawn001(void vName, void vAlias, void vMap, float fX, float fY, float fZ, int iAdjust){

    //spawn001
    //Damon Vaughn Caskey
    //07/06/2007
    //
    //Spawns entity with various adjustments as requested.
    //
    //vName: Model name of entity to be spawned in.
    //vAlias: Alias name given to spawned entity.
    //iMap: Color remap of spawned entity.
    //fX: X location adjustment.
    //fZ: Y location adjustment.
    //fY: Z location adjustment.
    //iAdjust: Starting postion and adjustment behavior -
    //
    //    0. Caller location.
    //  1. Caller location and store adjustment on caller for later use.
    //  2. Current area of screen.
    //    3. Caller's current opponent.
    //    4. Caller's location and store adjustment on spawn for later use.

    void vSelf = getlocalvar("self"); //Get calling entity.
    //void vSelf = getlocalvar("player");
    void vSpawn; //Spawn object.
    int iDirection = getentityproperty(vSelf, "direction"); //Get calling entity direction.


    clearspawnentry(); //Clear current spawn entry.
    setspawnentry("name", vName); //Aquire spawn entity by name.
    setspawnentry("alias", vAlias); //Set alias.
    setspawnentry("map", vMap); //Set color remap.
    setspawnentry("coords", fX, fZ, fY); //Set spawn location
 
    vSpawn = spawn(); //Spawn entity.
    clearspawnentry(); //Clear current spawn entry.
 
    if (iDirection == 0){ //Is caller facing right?             
 
         fX = -fX; //Reverse X adjustment to match facing.
        
    }
 
    if (!(iAdjust)){ //Adjust spawn to caller.

        fX = fX + getentityproperty(vSelf, "x"); //Get X location and add adjustment.
        fY = fY + getentityproperty(vSelf, "a"); //Get Y location and add adjustment.
        fZ = fZ + getentityproperty(vSelf, "z"); //Get Z location and add adjustment.

    }else if (iAdjust == 1){ //Adjust spawn to caller and store adjustments on caller for later use.
     
        //Store adjustment variables on caller.
        setglobalvar("fXA" + vSelf, fX); //X adjustment.
        setglobalvar("fYA" + vSelf, fY); //Y adjustment.
        setglobalvar("fZA" + vSelf, fZ); //Z adjustment.
 
        fX = fX + getentityproperty(vSelf, "x"); //Get X location and add adjustment.
        fY = fY + getentityproperty(vSelf, "a"); //Get Y location and add adjustment.
        fZ = fZ + getentityproperty(vSelf, "z"); //Get Z location and add adjustment.

    }else if (iAdjust == 2){//Adjust entity to caller Z, Y, with X base relating to stage location.
   
        fX = fX + openborvariant("xpos"); //X = Stage location + X adjustment.
   
    }else if (iAdjust == 3){ //Adjustment from current opponent.

        void vTarget = vTar001(1, vSelf); //Caller's current opponent.

        //Store adjustment varaibles on current opponent.
        fX = fX + getentityproperty(vTarget, "x"); //Get X location and add adjustment.
        fY = fY + getentityproperty(vTarget, "a"); //Get Y location and add adjustment.
        fZ = fZ + getentityproperty(vTarget, "z"); //Get Z location and add adjustment.
 
    }else if (iAdjust == 4){ //Adjust spawn to caller and store adjustments on spawn for later use.
           
        //Store adjustment varaibles on spawn.
        setglobalvar("fXA" + vSpawn, fX); //X adjustment.
        setglobalvar("fYA" + vSpawn, fY); //Y adjustment.
        setglobalvar("fZA" + vSpawn, fZ); //Z adjustment.
 
        fX = fX + getentityproperty(vSelf, "x"); //Get X location and add adjustment.
        fY = fY + getentityproperty(vSelf, "a"); //Get Y location and add adjustment.
        fZ = fZ + getentityproperty(vSelf, "z"); //Get Z location and add adjustment.
 
    }else if (iAdjust == 5){ //No adjustment at all.
 
        return vSpawn;
 
    }
 
    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "parent", vSelf); //Set caller as parent.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
 
    setglobalvar(vAlias + vSelf, vSpawn); //Store spawned entity in persistent global variable.
   
    return vSpawn; //Return spawn.

}

void vTar001(void vTarget, void vSelf){
 
    //vTar001
    //Damon Vaughn Caskey
    //08/02/2007
    //
    //Returns target entity handle from desired source.
    //
    //itarget: Desired target source.
    //vSelf: Entity searching for target.

    if (!(vTarget)){ //Self.

        return vSelf; //Return "self".
 
    }else if (vTarget == 1){//Current opponent.
   
        return getentityproperty(vSelf, "opponent"); //Get current opponent.

    }else if (vTarget == 2){ //Current hold victum.

        return getentityproperty(vSelf, "grabbing"); //Get entity vSelf is holding.

    }else if (vTarget == 3){ //Nearest hostile entity.

        return findtarget(vSelf);
   
    }else if (vTarget == 4){ //Caller's parent.

        return getentityproperty(vSelf, "parent");

    }else{ //Variable.

        return getglobalvar(vTarget + vSelf); //Get and return variable matching caller and vTarget.

    }

}

Here's the entity I'm trying to call with attack4.

Code:
name    bakraun1
type    none
health  1
speed   0
setlayer -2
gfxshadow 0
subject_to_wall 0

anim idle #Fade in to appear as next background to change
     loop      0
     delay     5
     offset    10 163
     flipframe 0
     drawmethod alpha 6
     drawmethod channel 0.10
     sound data/sounds/klunk.wav
     frame     data/bgs/dojo2/beach.png #0
     drawmethod alpha 6
     drawmethod channel 0.20
     frame     data/bgs/dojo2/beach.png #1
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/beach.png #2
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/beach.png #3
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/beach.png #4
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/beach.png #5
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/beach.png #6
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/beach.png #7
     drawmethod alpha 6
     drawmethod channel 0.90
     frame     data/bgs/dojo2/beach.png #8
     #drawmethod off
     drawmethod alpha 0
     drawmethod channel 0
     frame     data/bgs/dojo2/beach.png #9
     delay 30
     frame     data/bgs/dojo2/beach.png #10
     delay 5
     frame     data/bgs/dojo2/beach.png #11

anim follow1 #Background fades out after going back to its original training base
     loop      0
     delay     5
     offset    10 163
     flipframe 0
     sound data/sounds/shaah.wav
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.90
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.20
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.10
     frame     data/bgs/dojo2/beach.png
     #drawmethod off
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/beach.png

anim follow2 #Acting as previous background after next background starts
     delay     100
     offset    10 163
     flipframe 0
     frame     data/bgs/dojo2/beach.png
     delay 5
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/beach.png

EDIT: Just fixed the background skin for fading in and it's good. But now my only problem is that when I press attack4 after changing the background skin, it cannot fade out back to the normal stage. The sound with the test for changing is good, but eliminating with the fade-out background is what I'm having trouble. Is it because of this one here?

C:
            }else{
                //changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW"));
                setglobalvar("welian", NULL());
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_FOLLOW1"), 0);
            }
 
Last edited:
I just solved it by inputting performattack or changeentityproperty in place. It's now working as I expected, as well as removing flipframe from anim follow1.

C:
void variChangeStage(int player){
    if(openborvariant("in_level")){
        int welian    = getglobalvar("welian"); //CHANGE BACKGROUND OR WHATEVER
        void vSpawn; // = spawn004(vName, vAlias, vMap, fX, fY, fZ, iAdjust, iDirection, vAni3, iFrame);
        if(playerkeys(player, 1, "attack4")){
            clearspawnentry();
            loadmodel("Bakraun1");
            setspawnentry("name", "Bakraun1");
            if(welian == NULL()){
                setglobalvar("welian", 1);
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            }else{
                //changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW"));
                setglobalvar("welian", NULL());
                performattack(vSpawn,openborconstant("ANI_FOLLOW1"));
            }
        }
    }
}

Code:
anim follow1 #Background skin fades out after going back to its original training base
     loop      0
     delay     5
     offset    10 163
     #flipframe 0
     sound data/sounds/shaah.wav
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.90
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.20
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.10
     frame     data/bgs/dojo2/beach.png
     #drawmethod off
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/beach.png

I think I'm all good with transition between the base place and one background skin. However, if I'm going to have two or more background skins to change from one to another, I'm definitely going to need help because I have an animation that waits for the other one to appear so that the one that was (dis)playing will vanish after the next one comes.
 
OK. I think I did. I attempted the stage transitioning successfully and this is my first time to load/call 2 models for spawning as stage transitions, as well as adding another model name in spawn004.c. The results went well and I'm happy with that.

C:
void variChangeStage(int player){
    if(openborvariant("in_level")){
        int welian    = getglobalvar("welian"); //CHANGE BACKGROUND OR WHATEVER
        void vSpawn;
        void vSpawn2;
        if(playerkeys(player, 1, "attack4")){
            clearspawnentry();
            loadmodel("Bakraun1");
            loadmodel("Bakraun2");
            setspawnentry("name", "Bakraun1");
            setspawnentry("name", "Bakraun2");
            if(welian == NULL()){
                setglobalvar("welian", 1);
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            }else if(welian == 1){
                changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
                setglobalvar("welian", 2);
                vSpawn2 = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            }else{
                changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                setglobalvar("welian", NULL());
            }
        }
    }
}

The only change I did was adding a model name with the same spawn function as the first one.

spawn004.c:
C:
void main(){
    spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
    spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
}

Let me know if there's anything I did wrong, even though the result turns great.

I think I'm in a time where I can input these into the menu after I made them one by one, all thanks to your example. One thing I don't know of, is transitioning from a BG skin with a previous music that was active to the next music with another BG skin that starts playing. I will get to that if I start the menu thing.


Still waiting for the next step on what to do after testing these. I don't get how I can hide the pause menu for a new one.
 
Last edited:
OK. I think I did. I attempted the stage transitioning successfully and this is my first time to load/call 2 models for spawning as stage transitions, as well as adding another model name in spawn004.c. The results went well and I'm happy with that.

C:
void variChangeStage(int player){
    if(openborvariant("in_level")){
        int welian    = getglobalvar("welian"); //CHANGE BACKGROUND OR WHATEVER
        void vSpawn;
        void vSpawn2;
        if(playerkeys(player, 1, "attack4")){
            clearspawnentry();
            loadmodel("Bakraun1");
            loadmodel("Bakraun2");
            setspawnentry("name", "Bakraun1");
            setspawnentry("name", "Bakraun2");
            if(welian == NULL()){
                setglobalvar("welian", 1);
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            }else if(welian == 1){
                changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
                setglobalvar("welian", 2);
                vSpawn2 = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            }else{
                changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                setglobalvar("welian", NULL());
            }
        }
    }
}

The only change I did was adding a model name with the same spawn function as the first one.

spawn004.c:
C:
void main(){
    spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
    spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
}

Let me know if there's anything I did wrong, even though the result turns great.

I think I'm in a time where I can input these into the menu after I made them one by one, all thanks to your example. One thing I don't know of, is transitioning from a BG skin with a previous music that was active to the next music with another BG skin that starts playing. I will get to that if I start the menu thing.

Great job with the level transition :)

Now that you are more familiar with variables, an additional tip is to manage their types according to every situation. You don't need to always use global variables for everything, use them for global events only (like menus) where they need to be accessed by other scripts and must be persistent along all the playthrough.
For entity stuff where it's treated individually I recommend entityvars and for other situations use the localvars.
 
Kratus, I'm having trouble with exiting the pause menu when I choose option 3 in update.c. I realized that if I select it or don't input anything in it, it doesn't hide the pause menu options.

C:
//TESTING
                if(menuPause == 3){
                    //setglobalvar("menuPause", 0);
                    //menuMusic2();
                    newMenuTest();
                }

Also, I tried to make this menu display with a pause using "textbox" along with this particular code if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("musicMenu") == NULL()){, but it only shows in less than a second.

One part in update.c:
C:
void newMenuTest(){
// Draw a single variable on the screen.
//CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS AND THE MUSIC MENU IS DISABLED
if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("musicMenu") == NULL()){  
    int BGname = getglobalvar("BGname");
    void flag = getglobalvar("flag");
    int xPos = 110;
    int yPos = 100;
    int ySpace = 20;
    int font = 0;
    void str;
    int layer = 1001;
    int xPos2 = 170;
    changeopenborvariant("textbox", 1);
    //START VARIABLE IF NULL
    if(BGname == NULL()){
        setglobalvar("BGname", 0);
    }
    //DRAW ALL INFO ON THE SCREEN
    //drawstring(xPos,yPos, font, var, layer);
    //drawstring(xPos, yPos+ySpace, font, flag, layer);
    str = "Song:";
    drawstring(xPos2,yPos, font, str, layer);
    drawstring(xPos2, yPos+ySpace, font, BGname, layer);
}
}

I also inserted this new key script in keyall after mixing some of them. I'm having trouble with controlling these as well. I unpause the game and I have it freeze the game til I press the attack button to unfreeze and play music. Funny thing is that every time I press attack, it plays music (remix.bor) and transitions the background (beach). (There's something wrong with my key input.)

C:
void testAll(int player){
if(openborvariant("in_level")){
    int BGname    = getglobalvar("BGname"); //GET THE VARIABLE
    void variable    = getglobalvar("variable"); //GET THE VARIABLE
    int max            = 2; //MAXIMUM VARIABLE INCREMENT
    int min            = 0; //MINIMUM VARIABLE DECREMENT
    int add            = 1; //INCREMENT-DECREMENT AMOUNT PER KEY PRESS
    void vSpawn;
    void vSpawn2;


    //INCREMENT IF RIGHT IS PRESSED
    if(playerkeys(player, 1, "moveright")){
        //INCREMENT
        if(variable >= min && variable < max){
            setglobalvar("BGname", BGname+add);
        }
        //BACK TO THE MINIMUM VALUE IF MAXIMUM IS REACHED
        if(BGname == max){
            setglobalvar("BGname", min);
        }
    }
    //DECREMENT IF LEFT IS PRESSED
    if(playerkeys(player, 1, "moveleft")){
        //DECREMENT
        if(variable > min && variable <= max){
            setglobalvar("variable", variable-add);
        }
        //BACK TO THE MAXIMUM VALUE IF MINIMUM IS REACHED
        if(variable == min){
            setglobalvar("variable", max);
        }
    }
    if(playerkeys(player, 1, "attack")){
        clearspawnentry();
        loadmodel("Bakraun1");
        loadmodel("Bakraun2");
        setspawnentry("name", "Bakraun1");
        setspawnentry("name", "Bakraun2");
        changeopenborvariant("textbox", 0);
        if(BGname == NULL()){
            setglobalvar("BGname", 1);
            vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
        }if(BGname == 1){
            changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
            setglobalvar("BGname", 2);
            vSpawn2 = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
            fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
        }else{
            changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
            setglobalvar("BGname", NULL());
            fademusic(0.5, "data/music/remix.bor", 1, 1);
        }
    }
}
}

I have to use entityvar in keyall.c/update.c? Am I missing a flag or something? What's the next step if I want it to enter the pause menu and have it to hide for freezing the gameplay before play?
 
Kratus, I'm having trouble with exiting the pause menu when I choose option 3 in update.c. I realized that if I select it or don't input anything in it, it doesn't hide the pause menu options.
I didn't understand, do you want to quit the pause menu or just hide it? To quit you need to use the ESC key effect, to hide you need to create a condition for both pause/new menus. I coded an example below.

Also, I tried to make this menu display with a pause using "textbox" along with this particular code
Usually I don't recommend to use the textbox together with the native pause, the textbox I use in menus outside of the pause menu.

I also inserted this new key script in keyall after mixing some of them. I'm having trouble with controlling these as well. I unpause the game and I have it freeze the game til I press the attack button to unfreeze and play music. Funny thing is that every time I press attack, it plays music (remix.bor) and transitions the background (beach). (There's something wrong with my key input.)
Is the music menu fully working separated from the pause menu? In case not, it's still too early to mix.

I have to use entityvar in keyall.c/update.c?
Not exactly, it was just a recommendation for different situations.

What's the next step if I want it to enter the pause menu and have it to hide for freezing the gameplay before play?
I updated the pause menu template with a new menu example.

C:
void main()
{
    //NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN
    if(openborvariant("in_titlescreen")){
        if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
    }

    //CHECK IF THE PLAYER IS IN A LEVEL
    if(openborvariant("in_level")){
        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;
        int menuPause    = getglobalvar("menuPause");
        int max            = 4;
        int min            = 0;
        int add            = 1;

        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") == NULL()){

            //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
            if(    playerkeys(0, 1, "movedown")||
                playerkeys(1, 1, "movedown")||
                playerkeys(2, 1, "movedown")||
                playerkeys(3, 1, "movedown")){
                
                if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
                if(menuPause == max){setglobalvar("menuPause", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
                
                if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
                if(menuPause == min){setglobalvar("menuPause", max);}
            }

            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if(    playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
                
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);

                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }

                //OPTIONS
                if(menuPause == 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }

                //HOW TO PLAY
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("menuPause", 0);
                    playgif("data/scenes/howto.gif");
                }

                //NEW MENU FLAG
                if(menuPause == 3){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("newMenu", 1);
                }

                //END GAME
                if(menuPause == 4){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
            }

            //TEXTS, IMAGES AND EFFECTS
            void str;
            float hRes        = openborvariant("hresolution");
            int align;
            int yPos        = 80;
            int fontPause    = 3;
            int font0        = 0;
            int font1        = 0;
            int font2        = 0;
            int font3        = 0;
            int font4        = 0;
            int yAdd        = 11;
            int layer        = -1000000003;

            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
            if(getglobalvar("menuPause") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPause") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPause") == 2){font2 = 1;}else    //IS HOW TO PLAY HIGHLIGHTED??
            if(getglobalvar("menuPause") == 3){font3 = 1;}else    //IS NEW MENU HIGHLIGHTED??
            if(getglobalvar("menuPause") == 4){font4 = 1;}        //IS END GAME HIGHLIGHTED??

            str = "Pause";align = (hRes-(strwidth(str, fontPause)))/2;
            drawstring(align, yPos, fontPause, str, layer);

            yPos = yPos+yAdd*3;
            str = "Continue";align = (hRes-(strwidth(str, font0)))/2;
            drawstring(align, yPos, font0, str, layer);

            yPos = yPos+yAdd;
            str = "Options";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);

            yPos = yPos+yAdd;
            str = "How To Play";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);

            yPos = yPos+yAdd;
            str = "New Menu";align = (hRes-(strwidth(str, font3)))/2;
            drawstring(align, yPos, font3, str, layer);

            yPos = yPos+yAdd;
            str = "End Game";align = (hRes-(strwidth(str, font4)))/2;
            drawstring(align, yPos, font4, str, layer);
        }

        //DEFINE CONDITIONS TO ACTIVATE THE NEW MENU
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") != NULL()){
            newMenu();
        }

        //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
        if(openborvariant("game_paused") && openborvariant("in_options")){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
        }

        //NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
        //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
        if(!openborvariant("game_paused") && !openborvariant("in_options")){

            //END GAME
            if(menuPause == 4){gameover();}
        }

        
    }
}

void newMenu()
{
    //DRAW CONTENT ON THE SCREEN
    drawstring(50, 50, 0, "New Menu");
    drawstring(50, 60, 0, "Press any key to back");

    if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
        playerkeys(1, 1, "anybutton")||
        playerkeys(2, 1, "anybutton")||
        playerkeys(3, 1, "anybutton")||
        playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
        playerkeys(1, 1, "esc")||
        playerkeys(2, 1, "esc")||
        playerkeys(3, 1, "esc")){
        
        //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
        setglobalvar("newMenu", NULL());

        //DISABLE ANY ACTION KEY NATIVE EFFECT
        changeplayerproperty(0, "newkeys", 0);
        changeplayerproperty(1, "newkeys", 0);
        changeplayerproperty(2, "newkeys", 0);
        changeplayerproperty(3, "newkeys", 0);
    }
}

 
I didn't understand, do you want to quit the pause menu or just hide it? To quit you need to use the ESC key effect, to hide you need to create a condition for both pause/new menus. I coded an example below.
Both, I think. I'd like to transition starting from the pause menu to a new menu. For instance, when I select option 3 in the pause menu, I enter a new menu like your example. When I'm in the new menu, I would like to have a certain option that allows you to press left/right, as well as pressing any button (can use only one button or "anybutton" for this) to accept. If I want to press attack to select and attack2 to exit the pause menu during that new menu, I think most likely I'd like to quit both the pause menu and new menu in the end. I know keyall is used for key events, but under that new menu of option 3 (getglobalvar("menuPause") == 3).

For quitting, do I need to use it like this?
C:
//NEW MENU FLAG
                if(menuPause == 3){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("newMenu", 1);
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }

Is the music menu fully working separated from the pause menu? In case not, it's still too early to mix.
I have them separated but it's just that I created one script by naming it "testAll" in keyall and mixed them based on the ones I created previously (one script per button for level transition, the other for playing music, and another one for freezing the gameplay).

I updated the pause menu template with a new menu example.
Shoots! I just realize that I didn't bother looking at the condition carefully under the main pause menu part after you talked about it. But I didn't know where in update.c I could find it. Thank you for the new pause menu template, Kratus. I can hear the beep sound every time I press up/down in the new menu from option 3, but that's okay because I'm in the learning process. :) Maybe because it's under this one?

C:
        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") == NULL()){

Now I'm looking forward to how to press a button to select one part done (in keyall) under option 3. It might sound similar to the flag and variable examples of key presses you showed me. But I want to try it inside the new menu. It's like highlighting "fighting mode" and pressing left/right to pick one of the three choices in the partner menu demo. The only difference from it is that you select that part by attack button or whatever. You know how the globals work for menus, so I'll wait.

BTW I made this new menu with update.c and it works fine, all thanks to that pause menu template.

Screenshot 2024-03-31 191205.png

Let me show you some important bits which I created a new one for this.
C:
        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == NULL()){
            //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
            if(    playerkeys(0, 1, "movedown")||
                playerkeys(1, 1, "movedown")||
                playerkeys(2, 1, "movedown")||
                playerkeys(3, 1, "movedown")){
               
                if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
                if(menuPause == max){setglobalvar("menuPause", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
               
                if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
                if(menuPause == min){setglobalvar("menuPause", max);}
            }
            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if(    playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
               
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);
                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
                //OPTIONS
                if(menuPause == 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }
                //HOW TO PLAY
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("menuPause", 0);
                    playgif("data/scenes/howto.gif");
                }
                //NEW MENU FLAG
                if(menuPause == 3){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("newSelectMusic", 1);
                }
                //END GAME
                if(menuPause == 4){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
            }
            //TEXTS, IMAGES AND EFFECTS
            void str;
            float hRes        = openborvariant("hresolution");
            int align;
            int yPos        = 80;
            int fontPause    = 3;
            int font0        = 0;
            int font1        = 0;
            int font2        = 0;
            int font3        = 0;
            int font4        = 0;
            int yAdd        = 11;
            int layer        = -1000000003;
            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
            if(getglobalvar("menuPause") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPause") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPause") == 2){font2 = 1;}else    //IS HOW TO PLAY HIGHLIGHTED??
            if(getglobalvar("menuPause") == 3){font3 = 1;}else    //IS NEW MENU HIGHLIGHTED??
            if(getglobalvar("menuPause") == 4){font4 = 1;}        //IS END GAME HIGHLIGHTED??
            str = "Pause";align = (hRes-(strwidth(str, fontPause)))/2;
            drawstring(align, yPos, fontPause, str, layer);
            yPos = yPos+yAdd*3;
            str = "Continue";align = (hRes-(strwidth(str, font0)))/2;
            drawstring(align, yPos, font0, str, layer);
            yPos = yPos+yAdd;
            str = "Options";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);
            yPos = yPos+yAdd;
            str = "How To Play";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);
            yPos = yPos+yAdd;
            str = "New Menu";align = (hRes-(strwidth(str, font3)))/2;
            drawstring(align, yPos, font3, str, layer);
            yPos = yPos+yAdd;
            str = "End Game";align = (hRes-(strwidth(str, font4)))/2;
            drawstring(align, yPos, font4, str, layer);
        }
        //DEFINE CONDITIONS TO ACTIVATE THE NEW MENU
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") != NULL()){
            newSelectMusic();
        }
        //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
        if(openborvariant("game_paused") && openborvariant("in_options")){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
        }
        //NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
        //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
        if(!openborvariant("game_paused") && !openborvariant("in_options")){
            //END GAME
            if(menuPause == 4){gameover();}
        }
       
    }

C:
void newSelectMusic(){
    void str;
    float hRes    = openborvariant("hresolution");
    void variable_try    = getglobalvar("variable_try");
    int variable_numba    = getglobalvar("variable_numba");
    int align;
    int xDif    = 10;                //DIFFERENCE BETWEEN THE FIRST AND SECOND COLUMNS
    int xPos1    = (hRes/2)-xDif;    //BASE X POSITION, FIRST COLUMN (HIGHLIGHTED OPTIONS NAME)
    int xPos2    = (hRes/2)+xDif;    //BASE X POSITION, SECOND COLUMN (HIGHLIGHTED OPTIONS CHANGE)
    int yPos    = 60;                //BASE Y POSITION FOR ALL MENU CONTENT, USE THIS TO MOVE ALL OPTIONS TOGETHER
    int font    = 0;                //ALL FONTS BELOW CHANGES FROM 0 TO 1 IF THE OPTION IS HIGHLIGHTED
    int layer    = 1003;

    str = "Music:";
    align = xPos1-strwidth(str, font);
    drawstring(align, yPos, font, str, layer);
    void str2 = "Tester:";
    drawstring(align, yPos+11, font, str2, layer);

    if(variable_numba == NULL()){
        setglobalvar("variable_numba", 0);
    }

    if(variable_try == NULL()){
        setglobalvar("variable_try", "Beach");
    }

    drawstring(xPos2, yPos, font, variable_try, layer);
    drawstring(xPos2, yPos+11, font, variable_numba, layer);
    //drawstring(200, 50, 0, "Good Morning.");
    //drawstring(200, 60, 0, "How is it going?");

    if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
        playerkeys(1, 1, "anybutton")||
        playerkeys(2, 1, "anybutton")||
        playerkeys(3, 1, "anybutton")||
        playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
        playerkeys(1, 1, "esc")||
        playerkeys(2, 1, "esc")||
        playerkeys(3, 1, "esc")){
       
        //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
        setglobalvar("newSelectMusic", NULL());

        //DISABLE ANY ACTION KEY NATIVE EFFECT
        changeplayerproperty(0, "newkeys", 0);
        changeplayerproperty(1, "newkeys", 0);
        changeplayerproperty(2, "newkeys", 0);
        changeplayerproperty(3, "newkeys", 0);
    }
}
 
Last edited:
Both, I think. I'd like to transition starting from the pause menu to a new menu. For instance, when I select option 3 in the pause menu, I enter a new menu like your example. When I'm in the new menu, I would like to have a certain option that allows you to press left/right, as well as pressing any button (can use only one button or "anybutton" for this) to accept. If I want to press attack to select and attack2 to exit the pause menu during that new menu, I think most likely I'd like to quit both the pause menu and new menu in the end. I know keyall is used for key events, but under that new menu of option 3 (getglobalvar("menuPause") == 3).
From this point you already have all the menu concepts from beginning to the end. Once you know how to use global variables as a flag to enable/disable the "new menu" according to my latest example, now you can use the original pause menu as an guide to build a music menu fully functional, it's basically the same process.
 
Wow! It's funny that I thought about using the pause menu as a guide and/or reference for creating menus after your latest example.

What about the highlight on the selected option? Just use the pause menu as guide?
 
I (almost) did it by following the pause menu as a guide, but I'm having trouble with selecting it in the new menu via pause menu. I don't see it highlighted. Also, I try to press any button to exit the new menu, but only escape button can do it. I want to enable "anybutton" in the new menu, in case I'm going to create an exit option to unpause the pause menu. I want to unpause the game if I select a certain option from the new menu like unpausing the pause menu to resume the game.

update.c:
C:
void main()
{
    //NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN
    if(openborvariant("in_titlescreen")){
        if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
    }
    //CHECK IF THE PLAYER IS IN A LEVEL
    if(openborvariant("in_level")){
        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;
        int menuPause    = getglobalvar("menuPause");
        int max            = 4;
        int min            = 0;
        int add            = 1;
        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        //if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") == NULL()){
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == NULL()){
            //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
            if(    playerkeys(0, 1, "movedown")||
                playerkeys(1, 1, "movedown")||
                playerkeys(2, 1, "movedown")||
                playerkeys(3, 1, "movedown")){
              
                if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
                if(menuPause == max){setglobalvar("menuPause", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
              
                if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
                if(menuPause == min){setglobalvar("menuPause", max);}
            }
            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if(    playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
              
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);
                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
                //OPTIONS
                if(menuPause == 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }
                //HOW TO PLAY
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("menuPause", 0);
                    playgif("data/scenes/howto.gif");
                }
                //NEW MENU FLAG
                if(menuPause == 3){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    //setglobalvar("newMenu", 1);
                    setglobalvar("newSelectMusic", 1);
                }
                //END GAME
                if(menuPause == 4){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
            }
            //TEXTS, IMAGES AND EFFECTS
            void str;
            float hRes        = openborvariant("hresolution");
            int align;
            int yPos        = 80;
            int fontPause    = 3;
            int font0        = 0;
            int font1        = 0;
            int font2        = 0;
            int font3        = 0;
            int font4        = 0;
            int yAdd        = 11;
            int layer        = -1000000003;
            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
            if(getglobalvar("menuPause") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPause") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPause") == 2){font2 = 1;}else    //IS HOW TO PLAY HIGHLIGHTED??
            if(getglobalvar("menuPause") == 3){font3 = 1;}else    //IS NEW MENU HIGHLIGHTED??
            if(getglobalvar("menuPause") == 4){font4 = 1;}        //IS END GAME HIGHLIGHTED??
            str = "Pause";align = (hRes-(strwidth(str, fontPause)))/2;
            drawstring(align, yPos, fontPause, str, layer);
            yPos = yPos+yAdd*3;
            str = "Continue";align = (hRes-(strwidth(str, font0)))/2;
            drawstring(align, yPos, font0, str, layer);
            yPos = yPos+yAdd;
            str = "Options";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);
            yPos = yPos+yAdd;
            str = "How To Play";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);
            yPos = yPos+yAdd;
            str = "New Menu";align = (hRes-(strwidth(str, font3)))/2;
            drawstring(align, yPos, font3, str, layer);
            yPos = yPos+yAdd;
            str = "End Game";align = (hRes-(strwidth(str, font4)))/2;
            drawstring(align, yPos, font4, str, layer);
        }
        //DEFINE CONDITIONS TO ACTIVATE THE NEW MENU
        //if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") != NULL()){
        //    newMenu();
        //}
        //DEFINE CONDITIONS TO ACTIVATE THE NEW MENU
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") != NULL()){
            newSelectMusic();
        }
        //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
        if(openborvariant("game_paused") && openborvariant("in_options")){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
        }
        //NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
        //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
        if(!openborvariant("game_paused") && !openborvariant("in_options")){
            //END GAME
            if(menuPause == 4){gameover();}
        }
      
    }
}
void newMenu()
{
    //DRAW CONTENT ON THE SCREEN
    drawstring(50, 50, 0, "New Menu");
    drawstring(50, 60, 0, "Press any key to back");
    if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
        playerkeys(1, 1, "anybutton")||
        playerkeys(2, 1, "anybutton")||
        playerkeys(3, 1, "anybutton")||
        playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
        playerkeys(1, 1, "esc")||
        playerkeys(2, 1, "esc")||
        playerkeys(3, 1, "esc")){
      
        //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
        setglobalvar("newMenu", NULL());
        //DISABLE ANY ACTION KEY NATIVE EFFECT
        changeplayerproperty(0, "newkeys", 0);
        changeplayerproperty(1, "newkeys", 0);
        changeplayerproperty(2, "newkeys", 0);
        changeplayerproperty(3, "newkeys", 0);
    }
}
void newSelectMusic(){
    int volume        = openborvariant("effectvol");
    int speed        = 100;
    int loop        = 0;
    int menuSong    = getglobalvar("menuSong");
    int max            = 2;
    int min            = 0;
    int add            = 1;
    if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == 1){
        if( playerkeys(0, 1, "movedown") ||
            playerkeys(1, 1, "movedown") ||
            playerkeys(2, 1, "movedown") ||
            playerkeys(3, 1, "movedown") ){
            if(menuSong >= min && menuSong < max){setglobalvar("menuSong", menuSong+add);}
            if(menuSong == max){setglobalvar("menuSong", min);}
        }
        if( playerkeys(0, 1, "moveup") ||
            playerkeys(1, 1, "moveup") ||
            playerkeys(2, 1, "moveup") ||
            playerkeys(3, 1, "moveup") ){
            if(menuSong > min && menuSong <= max){setglobalvar("menuSong", menuSong-add);}
            if(menuSong == min){setglobalvar("menuSong", max);}
        }
        if( playerkeys(0, 1, "anybutton") ||
            playerkeys(1, 1, "anybutton") ||
            playerkeys(2, 1, "anybutton") ||
            playerkeys(3, 1, "anybutton") ){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
            if(menuSong == 0){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
            }
            if(menuSong == 1){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
            }
            if(menuSong == 2){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/remix.bor", 1, 1);
            }
        }
      
        void str;
        float hRes        = openborvariant("hresolution");
        int align;
        int yPos        = 50;
        int fontPause    = 3;
        int font0        = 0;
        int font1        = 0;
        int font2        = 0;
        int yAdd        = 11;
        int layer        = -1000000003;
            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
        if(getglobalvar("menuSong") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
        if(getglobalvar("menuSong") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
        if(getglobalvar("menuSong") == 2){font2 = 1;}
        str = "Select Song";align = (hRes-(strwidth(str, fontPause)))/2;
        drawstring(align, yPos, fontPause, str, layer);
        yPos = yPos+yAdd*3;
        str = "Beach";align = (hRes-(strwidth(str, font0)))/2;
        drawstring(align, yPos, font0, str, layer);
        yPos = yPos+yAdd;
        str = "Italy";align = (hRes-(strwidth(str, font1)))/2;
        drawstring(align, yPos, font1, str, layer);
        yPos = yPos+yAdd;
        str = "Normal";align = (hRes-(strwidth(str, font2)))/2;
        drawstring(align, yPos, font2, str, layer);


        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == 1){
            if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")||
                playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
                playerkeys(1, 1, "esc")||
                playerkeys(2, 1, "esc")||
                playerkeys(3, 1, "esc")){
      
                //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
                setglobalvar("newSelectMusic", NULL());
                //DISABLE ANY ACTION KEY NATIVE EFFECT
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);
            }
        }

    }
}


EDIT: Should I use "in_level" for this?
 
Last edited:
I don't see it highlighted
You didn't start the "menuSong" global variable, you can't increment/decrement if the variable is NULL(). You must start it with a value, I suggest starting it from zero.

menu as a guide
When I meant "as a guide" I mean to follow the logic but coding yours step by step, you still are doing copy/paste operations without looking at the logic.

Also, I try to press any button to exit the new menu, but only escape button can do it
You already have this logic working in the last template I posted, I suggest looking at it again to check where the problem is.
In addition you can play the music during the up/down key presses in the same way I'm doing in the bgm option in the SOR2X using left/right, this way you can use the "anybutton" only to quit the music menu.
 
You know what, Kratus? I just included a function I created in keyall and this is working exactly what I wanted. Even though I finished coding the new function in keyall, I forgot to uncomment the new function. I just realized that my code in update.c works wonders with keyall.c.

Let me show you the new one I have in keyall.c.

keyall.c:
C:
void main(){
    int player = getlocalvar("player");
    //variableFlag(player);
    //variableChange(player);
    variTest(player);
    variPause(player);
    variChangeStage(player);
    newSelectMusic(player); // NEW
}

void newSelectMusic(int player){
    if(getglobalvar("newSelectMusic") == 1){
        int moveright   = playerkeys(player, 1, "moveright");
        int moveleft    = playerkeys(player, 1, "moveleft");
        int attack      = playerkeys(player, 1, "attack");
        void variable_try   = getglobalvar("variable_try");
        //int variable_numba    = getglobalvar("variable_numba");
        int volume      = openborvariant("effectvol");
        int speed       = 100;
        int loop        = 0;
        if(moveright){
            //playsample(openborconstant("SAMPLE_BEEP"), 0, volume, volume, speed, loop);
            //if(variable_numba >= min && variable_numba < max){setglobalvar("variable_try", variable_try);}
            //if(variable_numba == max){setglobalvar("variable_try", variable_try);}
       
            if(variable_try == "Beach"){setglobalvar("variable_try", "Italy");}
            if(variable_try == "Italy"){setglobalvar("variable_try", "Normal");}
            if(variable_try == "Normal"){setglobalvar("variable_try", "Beach");}
        }
        if(moveleft){
            //playsample(openborconstant("SAMPLE_BEEP"), 0, volume, volume, speed, loop);
        //if(variable_numba > min && variable_numba <= max){setglobalvar("variable_numba", variable_numba-add);}
        //if(variable_numba == min){setglobalvar("variable_numba", max);}
            if(variable_try == "Beach"){setglobalvar("variable_try", "Normal");}
            if(variable_try == "Normal"){setglobalvar("variable_try", "Italy");}
            if(variable_try == "Italy"){setglobalvar("variable_try", "Beach");}
        }
        /*if(attack){
            if(variable_try == "Beach"){
                //vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
            }
            if(variable_try == "Italy"){
                //vSpawn = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
            }
            if(variable_try == "Normal"){
                fademusic(0.5, "data/music/remix.bor", 1, 1);
            }
        }*/
    }
}


Yeah. I know my code looks weird with left and right commands in keyall.c, but it's working with up/down in both update.c and keyall.c really fine. I'm not minding the left/right commands, so I will change it later. Thanks for your big help, Kratus.
 
You know what, Kratus? I just included a function I created in keyall and this is working exactly what I wanted. Even though I finished coding the new function in keyall, I forgot to uncomment the new function. I just realized that my code in update.c works wonders with keyall.c.

Let me show you the new one I have in keyall.c.

keyall.c:
C:
void main(){
    int player = getlocalvar("player");
    //variableFlag(player);
    //variableChange(player);
    variTest(player);
    variPause(player);
    variChangeStage(player);
    newSelectMusic(player); // NEW
}

void newSelectMusic(int player){
    if(getglobalvar("newSelectMusic") == 1){
        int moveright   = playerkeys(player, 1, "moveright");
        int moveleft    = playerkeys(player, 1, "moveleft");
        int attack      = playerkeys(player, 1, "attack");
        void variable_try   = getglobalvar("variable_try");
        //int variable_numba    = getglobalvar("variable_numba");
        int volume      = openborvariant("effectvol");
        int speed       = 100;
        int loop        = 0;
        if(moveright){
            //playsample(openborconstant("SAMPLE_BEEP"), 0, volume, volume, speed, loop);
            //if(variable_numba >= min && variable_numba < max){setglobalvar("variable_try", variable_try);}
            //if(variable_numba == max){setglobalvar("variable_try", variable_try);}
      
            if(variable_try == "Beach"){setglobalvar("variable_try", "Italy");}
            if(variable_try == "Italy"){setglobalvar("variable_try", "Normal");}
            if(variable_try == "Normal"){setglobalvar("variable_try", "Beach");}
        }
        if(moveleft){
            //playsample(openborconstant("SAMPLE_BEEP"), 0, volume, volume, speed, loop);
        //if(variable_numba > min && variable_numba <= max){setglobalvar("variable_numba", variable_numba-add);}
        //if(variable_numba == min){setglobalvar("variable_numba", max);}
            if(variable_try == "Beach"){setglobalvar("variable_try", "Normal");}
            if(variable_try == "Normal"){setglobalvar("variable_try", "Italy");}
            if(variable_try == "Italy"){setglobalvar("variable_try", "Beach");}
        }
        /*if(attack){
            if(variable_try == "Beach"){
                //vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
            }
            if(variable_try == "Italy"){
                //vSpawn = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
            }
            if(variable_try == "Normal"){
                fademusic(0.5, "data/music/remix.bor", 1, 1);
            }
        }*/
    }
}


Yeah. I know my code looks weird with left and right commands in keyall.c, but it's working with up/down in both update.c and keyall.c really fine. I'm not minding the left/right commands, so I will change it later. Thanks for your big help, Kratus.
It will work in the keyall.c but don't forget that the native pause menu still is active and depending on how you code your script, you can allow players to change the native pause menu options together with your custom menu options, causing undesired side effects.
 
I was so wrong for mentioning that keyall.c would fix the problem for the menus, so you are absolutely right about starting the "menuSong" global variable with value 0 which I missed doing it in the first place, Kratus. I'm very sorry for misinterpreting things because I was in a rush to leave. After testing this time, I just realized now that keyall.c is not the one that helps with highlighting fonts. It's from the new menu alone I created only in update.c! :LOL:

update.c:
C:
void main()
{
    //NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN
    if(openborvariant("in_titlescreen")){
        if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
    }
    //CHECK IF THE PLAYER IS IN A LEVEL
    if(openborvariant("in_level")){
        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;
        int menuPause    = getglobalvar("menuPause");
        int max            = 4;
        int min            = 0;
        int add            = 1;
        //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
        //if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") == NULL()){
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == NULL()){
            //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
            if(    playerkeys(0, 1, "movedown")||
                playerkeys(1, 1, "movedown")||
                playerkeys(2, 1, "movedown")||
                playerkeys(3, 1, "movedown")){
           
                if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
                if(menuPause == max){setglobalvar("menuPause", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
           
                if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
                if(menuPause == min){setglobalvar("menuPause", max);}
            }
            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if(    playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
           
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);
                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
                //OPTIONS
                if(menuPause == 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }
                //HOW TO PLAY
                if(menuPause == 2){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    setglobalvar("menuPause", 0);
                    playgif("data/scenes/howto.gif");
                }
                //NEW MENU FLAG
                if(menuPause == 3){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    //setglobalvar("newMenu", 1);
                    setglobalvar("newSelectMusic", 1);
                }
                //END GAME
                if(menuPause == 4){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }
            }
            //TEXTS, IMAGES AND EFFECTS
            void str;
            float hRes        = openborvariant("hresolution");
            int align;
            int yPos        = 80;
            int fontPause    = 3;
            int font0        = 0;
            int font1        = 0;
            int font2        = 0;
            int font3        = 0;
            int font4        = 0;
            int yAdd        = 11;
            int layer        = -1000000003;
            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
            if(getglobalvar("menuPause") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPause") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPause") == 2){font2 = 1;}else    //IS HOW TO PLAY HIGHLIGHTED??
            if(getglobalvar("menuPause") == 3){font3 = 1;}else    //IS NEW MENU HIGHLIGHTED??
            if(getglobalvar("menuPause") == 4){font4 = 1;}        //IS END GAME HIGHLIGHTED??
            str = "Pause";align = (hRes-(strwidth(str, fontPause)))/2;
            drawstring(align, yPos, fontPause, str, layer);
            yPos = yPos+yAdd*3;
            str = "Continue";align = (hRes-(strwidth(str, font0)))/2;
            drawstring(align, yPos, font0, str, layer);
            yPos = yPos+yAdd;
            str = "Options";align = (hRes-(strwidth(str, font1)))/2;
            drawstring(align, yPos, font1, str, layer);
            yPos = yPos+yAdd;
            str = "How To Play";align = (hRes-(strwidth(str, font2)))/2;
            drawstring(align, yPos, font2, str, layer);
            yPos = yPos+yAdd;
            str = "New Menu";align = (hRes-(strwidth(str, font3)))/2;
            drawstring(align, yPos, font3, str, layer);
            yPos = yPos+yAdd;
            str = "End Game";align = (hRes-(strwidth(str, font4)))/2;
            drawstring(align, yPos, font4, str, layer);
        }
        //DEFINE CONDITIONS TO ACTIVATE THE NEW MENU
        //if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newMenu") != NULL()){
        //    newMenu();
        //}
        //DEFINE CONDITIONS TO ACTIVATE THE NEW MENU
        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") != NULL()){
            newSelectMusic();
        }
        //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
        if(openborvariant("game_paused") && openborvariant("in_options")){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
        }
        //NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
        //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
        if(!openborvariant("game_paused") && !openborvariant("in_options")){
            //END GAME
            if(menuPause == 4){gameover();}
        }
   
    }
}
void newMenu()
{
    //DRAW CONTENT ON THE SCREEN
    drawstring(50, 50, 0, "New Menu");
    drawstring(50, 60, 0, "Press any key to back");
    if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
        playerkeys(1, 1, "anybutton")||
        playerkeys(2, 1, "anybutton")||
        playerkeys(3, 1, "anybutton")||
        playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
        playerkeys(1, 1, "esc")||
        playerkeys(2, 1, "esc")||
        playerkeys(3, 1, "esc")){
   
        //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
        setglobalvar("newMenu", NULL());
        //DISABLE ANY ACTION KEY NATIVE EFFECT
        changeplayerproperty(0, "newkeys", 0);
        changeplayerproperty(1, "newkeys", 0);
        changeplayerproperty(2, "newkeys", 0);
        changeplayerproperty(3, "newkeys", 0);
    }
}

void newSelectMusic(){
    int volume        = openborvariant("effectvol");
    int speed        = 100;
    int loop        = 0;
    int menuSong    = getglobalvar("menuSong");
    int max            = 2;
    int min            = 0;
    int add            = 1;
    if(menuSong == NULL()){
        setglobalvar("menuSong", 0);
    }
    if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == 1){
        if( playerkeys(0, 1, "movedown") ||
            playerkeys(1, 1, "movedown") ||
            playerkeys(2, 1, "movedown") ||
            playerkeys(3, 1, "movedown") ){
            if(menuSong >= min && menuSong < max){setglobalvar("menuSong", menuSong+add);}
            if(menuSong == max){setglobalvar("menuSong", min);}
        }
        if( playerkeys(0, 1, "moveup") ||
            playerkeys(1, 1, "moveup") ||
            playerkeys(2, 1, "moveup") ||
            playerkeys(3, 1, "moveup") ){
            if(menuSong > min && menuSong <= max){setglobalvar("menuSong", menuSong-add);}
            if(menuSong == min){setglobalvar("menuSong", max);}
        }
        if( playerkeys(0, 1, "anybutton") ||
            playerkeys(1, 1, "anybutton") ||
            playerkeys(2, 1, "anybutton") ||
            playerkeys(3, 1, "anybutton") ){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
            if(menuSong == 0){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
            }
            if(menuSong == 1){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
            }
            if(menuSong == 2){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/remix.bor", 1, 1);
            }
        }
   
        void str;
        float hRes        = openborvariant("hresolution");
        int align;
        int yPos        = 50;
        int fontPause    = 3;
        int font0        = 0;
        int font1        = 0;
        int font2        = 0;
        int yAdd        = 11;
        int layer        = -1000000003;
            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
        if(getglobalvar("menuSong") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
        if(getglobalvar("menuSong") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
        if(getglobalvar("menuSong") == 2){font2 = 1;}
        str = "Select Song";align = (hRes-(strwidth(str, fontPause)))/2;
        drawstring(align, yPos, fontPause, str, layer);
        yPos = yPos+yAdd*3;
        str = "Beach";align = (hRes-(strwidth(str, font0)))/2;
        drawstring(align, yPos, font0, str, layer);
        yPos = yPos+yAdd;
        str = "Italy";align = (hRes-(strwidth(str, font1)))/2;
        drawstring(align, yPos, font1, str, layer);
        yPos = yPos+yAdd;
        str = "Normal";align = (hRes-(strwidth(str, font2)))/2;
        drawstring(align, yPos, font2, str, layer);


        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == 1){
            if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")||
                playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
                playerkeys(1, 1, "esc")||
                playerkeys(2, 1, "esc")||
                playerkeys(3, 1, "esc")){
   
                //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
                setglobalvar("newSelectMusic", NULL());
                //DISABLE ANY ACTION KEY NATIVE EFFECT
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);
            }
        }
 
    }
}

I'm not using keyall.c at all for this.

In the video from my previous post here, I did press any button to play music, but escape button to not play music in the new menu. This is so cool!

Now that I got this working, how can I escape the native pause menu straight after selecting one song? I selected the first song with the "menuPause" 0 value, but I'm reverted back to the pause menu after.

C:
            if(menuSong == 0){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81); // Play music
                setglobalvar("menuPause", 0); // Revert to highlight "Continue" option
            }

It will work in the keyall.c but don't forget that the native pause menu still is active and depending on how you code your script, you can allow players to change the native pause menu options together with your custom menu options, causing undesired side effects.
You're absolutely right. Now I'm aware the native pause menu is always active and I want to skip it, but I also want to avoid any unwanted side effects.

EDIT: In case it's not possible to skip the native pause menu for an unpause, I have a better idea on what to do with it. But I'm going to need your help with transitioning the previous level background back to normal stage, depending on the last level transition to the home background. For example, if you have three options and choose "Miami/Beach" over "Italy", and you go back to home ("Normal"), that "Beach" background will fade out like I showed in the video. But if the "Normal" background is chosen when you're in the "Normal" area, it shouldn't fade in or out since it's a home background. You leave it as it is.

EDIT 2: With this new menu being possible, is it okay if I could have 2 or 3 columns of some options as a menu? Could it be done the same way I did with the previous attempts of the new menu script? I'm worried about the limit number of min-max for pressing left, right, down, and up directional buttons.

EDIT 3: Never mind in EDIT 1. I finally did it and figured out what to do on the level fade-out transition so far. I believe it's working really fine as I wanted. So, I will show the video when I have time. I'm waiting for an answer on the columns.

EDIT 4: OK. Now I do need help with EDIT 1. I encountered some problems with the level transition going wrong. I'll make some video later.
 
Last edited:
The first time I did it, it went great. But when I did it again going around (without direction both), the level transition started to go wrong as I selected certain option(s) to change. Before I started my first attempt of coding transitioning levels, I felt that there would be something wrong because I have the two summoned backgrounds that would fade out with the same animations at the same time.



Here's what I have so far.
C:
void newSelectMusic(){
    int volume        = openborvariant("effectvol");
    int speed        = 100;
    int loop        = 0;
    int menuSong    = getglobalvar("menuSong");
    int max            = 2;
    int min            = 0;
    int add            = 1;
    void vSpawn; void vSpawn2;
    clearspawnentry();
    loadmodel("Bakraun1");
    loadmodel("Bakraun2");
    setspawnentry("name", "Bakraun1");
    setspawnentry("name", "Bakraun2");
    if(menuSong == NULL()){
        setglobalvar("menuSong", 0);
    }
    if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == 1){
        if( playerkeys(0, 1, "movedown") ||
            playerkeys(1, 1, "movedown") ||
            playerkeys(2, 1, "movedown") ||
            playerkeys(3, 1, "movedown") ){
            if(menuSong >= min && menuSong < max){setglobalvar("menuSong", menuSong+add);}
            if(menuSong == max){setglobalvar("menuSong", min);}
        }
        if( playerkeys(0, 1, "moveup") ||
            playerkeys(1, 1, "moveup") ||
            playerkeys(2, 1, "moveup") ||
            playerkeys(3, 1, "moveup") ){
            if(menuSong > min && menuSong <= max){setglobalvar("menuSong", menuSong-add);}
            if(menuSong == min){setglobalvar("menuSong", max);}
        }
        if( playerkeys(0, 1, "anybutton") ||
            playerkeys(1, 1, "anybutton") ||
            playerkeys(2, 1, "anybutton") ||
            playerkeys(3, 1, "anybutton") ){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
            if(menuSong == 0){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                //fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
                setglobalvar("menuPause", 0);
                vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0); // Beach's fade-in
                if(getentityproperty(vSpawn2, "animationid") == openborconstant("ANI_IDLE") && getentityproperty(vSpawn2, "animpos") == 10 || getentityproperty(vSpawn2, "animpos") == 11){ // Italy's fade-in
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1")); // Italy's fade-out
                }
                /*if(setglobalvar("menuSong", 1)){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                    vSpawn = spawn004("Bakraun1", "Bakraun1", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                    //fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
                    setglobalvar("menuPause", 0);
                }else if(setglobalvar("menuSong", 2)){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    //fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
                    setglobalvar("menuPause", 0);
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                }*/
            }
            if(menuSong == 1){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                //fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
                setglobalvar("menuPause", 0);
                vSpawn2 = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                if(getentityproperty(vSpawn, "animationid") == openborconstant("ANI_IDLE") && getentityproperty(vSpawn, "animpos") == 10 || getentityproperty(vSpawn, "animpos") == 11){
                    changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
                }
                /*if(setglobalvar("menuSong", 0)){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                    vSpawn2 = spawn004("Bakraun2", "Bakraun2", 0, 10, 0, 163, 0, 3, openborconstant("ANI_IDLE"), 0);
                    //fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
                    setglobalvar("menuPause", 0);
                }else if(setglobalvar("menuSong", 2)){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    //fademusic(0.5, "data/music/dojo2/miami.bor", 1, 628476.81);
                    setglobalvar("menuPause", 0);
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                }*/
            }
            if(menuSong == 2){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                //fademusic(0.5, "data/music/remix.bor", 1, 1);
                setglobalvar("menuPause", 0);
                //changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                //changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
                if(getentityproperty(vSpawn2, "animationid") == openborconstant("ANI_IDLE") && getentityproperty(vSpawn2, "animpos") == 10 || getentityproperty(vSpawn2, "animpos") == 11){ // Italy's fade-in
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1")); // Italy's fade-out
                }
                if(getentityproperty(vSpawn, "animationid") == openborconstant("ANI_IDLE") && getentityproperty(vSpawn, "animpos") == 10 || getentityproperty(vSpawn, "animpos") == 11){
                    changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
                }
                /*if(getentityproperty(vSpawn, "animationid") == openborconstant("ANI_IDLE")){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    changeentityproperty(vSpawn2, "animation", openborconstant("ANI_FOLLOW1"));
                    //fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
                    setglobalvar("menuPause", 0);
                }if(getentityproperty(vSpawn2, "animationid") == openborconstant("ANI_IDLE")){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                    //fademusic(0.5, "data/music/dojo2/italy.bor", 1, 372394.78);
                    setglobalvar("menuPause", 0);
                    changeentityproperty(vSpawn, "animation", openborconstant("ANI_FOLLOW1"));
                }*/
            }
        }
        
        void str;
        float hRes        = openborvariant("hresolution");
        int align;
        int yPos        = 50;
        int fontPause    = 3;
        int font0        = 0;
        int font1        = 0;
        int font2        = 0;
        int yAdd        = 11;
        int layer        = -1000000003;
            //DEFINE FONTS TO HIGHLIGHTED OPTIONS
        if(getglobalvar("menuSong") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
        if(getglobalvar("menuSong") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
        if(getglobalvar("menuSong") == 2){font2 = 1;}
        str = "Select Song";align = (hRes-(strwidth(str, fontPause)))/2;
        drawstring(align, yPos, fontPause, str, layer);
        yPos = yPos+yAdd*3;
        str = "Miami";align = (hRes-(strwidth(str, font0)))/2;
        drawstring(align, yPos, font0, str, layer);
        yPos = yPos+yAdd;
        str = "Italy";align = (hRes-(strwidth(str, font1)))/2;
        drawstring(align, yPos, font1, str, layer);
        yPos = yPos+yAdd;
        str = "Normal";align = (hRes-(strwidth(str, font2)))/2;
        drawstring(align, yPos, font2, str, layer);


        if(openborvariant("game_paused") && !openborvariant("in_options") && getglobalvar("newSelectMusic") == 1){
            if(    playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")||
                playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
                playerkeys(1, 1, "esc")||
                playerkeys(2, 1, "esc")||
                playerkeys(3, 1, "esc")){
        
                //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
                setglobalvar("newSelectMusic", NULL());
                //DISABLE ANY ACTION KEY NATIVE EFFECT
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);
            }
        }
    
    }
}

Summoned models as level transitions.

Code:
name    bakraun1
type    none
health  1
speed   0
facing 1
setlayer -2
gfxshadow 0
subject_to_wall 0
palette none

anim idle #Fade in to appear as next background to change
     loop      0
     delay     5
     offset    10 163
     drawmethod alpha 6
     drawmethod channel 0.10
     @cmd changeopenborvariant "nopause" 1
     frame     data/bgs/dojo2/beach.png #0
     drawmethod alpha 6
     drawmethod channel 0.20
     #@cmd fademusic 0.5 "data/music/dojo2/miami.bor" 1 628476.81
     frame     data/bgs/dojo2/beach.png #1
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/beach.png #2
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/beach.png #3
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/beach.png #4
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/beach.png #5
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/beach.png #6
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/beach.png #7
     drawmethod alpha 6
     drawmethod channel 0.90
     frame     data/bgs/dojo2/beach.png #8
     #drawmethod off
     drawmethod alpha 0
     drawmethod channel 0
     frame     data/bgs/dojo2/beach.png #9
     delay 30
     @cmd changeopenborvariant "nopause" 0
     frame     data/bgs/dojo2/beach.png #10
     delay 5
     frame     data/bgs/dojo2/beach.png #11

anim follow1 #Background fades out after going back to its original training base
     loop      0
     delay     5
     offset    10 163
     @cmd changeopenborvariant "nopause" 1
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.90
     #@cmd fademusic 0.5 "data/music/remix.bor" 1 1
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.20
     frame     data/bgs/dojo2/beach.png
     drawmethod alpha 6
     drawmethod channel 0.10
     frame     data/bgs/dojo2/beach.png
     @cmd changeopenborvariant "nopause" 0
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/beach.png

anim follow2 #Acting as previous background after next background starts
     delay     50
     offset    10 163
     @cmd    changeentityproperty getlocalvar("self") "setlayer" -10000
     frame     data/bgs/dojo2/beach.png
     delay 5
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/beach.png

Code:
name    bakraun2
type    none
health  1
facing 1
speed   0
setlayer -2
gfxshadow 0
subject_to_wall 0

anim idle #Fade in to appear as next background to change
     loop      0
     delay     5
     offset    10 163
     drawmethod alpha 6
     drawmethod channel 0.10
     frame     data/bgs/dojo2/italy.png #0
     drawmethod alpha 6
     drawmethod channel 0.20
     #@cmd fademusic 0.5 "data/music/dojo2/italy.bor" 1 372394.78
     frame     data/bgs/dojo2/italy.png #1
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/italy.png #2
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/italy.png #3
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/italy.png #4
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/italy.png #5
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/italy.png #6
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/italy.png #7
     drawmethod alpha 6
     drawmethod channel 0.90
     frame     data/bgs/dojo2/italy.png #8
     drawmethod alpha 0
     drawmethod channel 0
     frame     data/bgs/dojo2/italy.png #9
     delay 30
     frame     data/bgs/dojo2/italy.png #10
     delay 5
     frame     data/bgs/dojo2/italy.png #11

anim follow1 #Background fades out after going back to its original training base
     loop      0
     delay     5
     offset    10 163
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.90
     #@cmd fademusic 0.5 "data/music/remix.bor" 1 1
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.80
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.70
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.60
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.50
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.40
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.30
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.20
     frame     data/bgs/dojo2/italy.png
     drawmethod alpha 6
     drawmethod channel 0.10
     frame     data/bgs/dojo2/italy.png
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/italy.png

anim follow2 #Acting as previous background after next background starts
     delay     50
     offset    10 163
     @cmd    changeentityproperty getlocalvar("self") "setlayer" -10000
     frame     data/bgs/dojo2/italy.png
     delay 5
     @cmd killentity getlocalvar("self")
     frame     data/bgs/dojo2/italy.png
 
Now I'm aware the native pause menu is always active and I want to skip it
You can skip the native pause by triggering the ESC key effect to "anybutton", like the original pause menu does if the "continue" option is highlighted.

C:
            //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
            //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
            if( playerkeys(0, 1, "anybutton")||
                playerkeys(1, 1, "anybutton")||
                playerkeys(2, 1, "anybutton")||
                playerkeys(3, 1, "anybutton")){
                
                //LOCK NATIVE KEYS
                changeplayerproperty(0, "newkeys", 0);
                changeplayerproperty(1, "newkeys", 0);
                changeplayerproperty(2, "newkeys", 0);
                changeplayerproperty(3, "newkeys", 0);

                //CONTINUE
                if(menuPause == 0){
                    changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                    changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
                }

EDIT 2: With this new menu being possible, is it okay if I could have 2 or 3 columns of some options as a menu? Could it be done the same way I did with the previous attempts of the new menu script? I'm worried about the limit number of min-max for pressing left, right, down, and up directional buttons.
You can use the SOR2X "extra menu" codes as a guide, they have two columns. Basically it follows the same increment/decrement logic used by the up/down keys to highlight options, but using the left/right keys to change the second column variables.
 
You can use the SOR2X "extra menu" codes as a guide, they have two columns. Basically it follows the same increment/decrement logic used by the up/down keys to highlight options, but using the left/right keys to change the second column variables.
Nice. I could try that. I plan to do that. But I was referring to parts of 3 or more columns where you're allowed to press any of 4 directional keys to highlight and then select one of them from the columns with any button.

You can skip the native pause by triggering the ESC key effect to "anybutton", like the original pause menu does if the "continue" option is highlighted.
Oops. I meant escaping straight without directly going back to pause menu, but I get your point. What's funny is that I have the "ESC" button for only escaping the new menu straight to the pause menu. The "ESC" button works fine like you're not selecting anything from there, but still it reverts back to the pause menu. :)

C:
        if( playerkeys(0, 1, "anybutton") ||
            playerkeys(1, 1, "anybutton") ||
            playerkeys(2, 1, "anybutton") ||
            playerkeys(3, 1, "anybutton") ){
            changeplayerproperty(0, "newkeys", 0);
            changeplayerproperty(1, "newkeys", 0);
            changeplayerproperty(2, "newkeys", 0);
            changeplayerproperty(3, "newkeys", 0);
            if(menuSong == 0){
                changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
                changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
 
Oops. I meant escaping straight without directly going back to pause menu
Like I said before, the ESC key effect does the trick. In the example below I maintained the ESC detection in case you want to apply other effects, but you can remove it once it already had the desired effect.

C:
void newMenu()
{
    //DRAW CONTENT ON THE SCREEN
    drawstring(50, 50, 0, "New Menu");
    drawstring(50, 60, 0, "Press any key to quit");

    if( playerkeys(0, 1, "anybutton")|| //DETECT ANY ACTION KEY PRESS
        playerkeys(1, 1, "anybutton")||
        playerkeys(2, 1, "anybutton")||
        playerkeys(3, 1, "anybutton")||
        playerkeys(0, 1, "esc")|| //DETECT ESC KEY PRESS
        playerkeys(1, 1, "esc")||
        playerkeys(2, 1, "esc")||
        playerkeys(3, 1, "esc")){
        
        //DISABLE THE NEW MENU IF ANY ACTION KEY IS PRESSED
        setglobalvar("newMenu", NULL());
        setglobalvar("menuPause", 0);

        //DISABLE ANY ACTION KEY NATIVE EFFECT AND APPLY THE ESC KEY EFFECT
        changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
        changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
        changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
        changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
    }
}

 
Back
Top Bottom