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:
This is my first time I created my own sub-menu after selecting it from the pause menu. However, what I created doesn't show in game. Here's what I have so far but let me show you important ones I'm attempting, not all scripts I have.

update.c:
C:
void main()
{

    testingPause();


   
    //TITLE SCREEN, CLEAR AND START A LOT OF VARIABLES IF "NULL()"
    if(openborvariant("in_titlescreen")){
        loadAll();
    }

    //MENU SCREEN, SET THE "CLEARALL" FLAG TO 1
    if(openborvariant("in_menuscreen")){
        if(getglobalvar("clearAll") == NULL()){setglobalvar("clearAll", 1);}
    }
   
    //IN LEVEL
    if(openborvariant("in_level")){
        //menuPartners();
        musicPlaylist();
    }

    //COMPLETE SCREEN, RESET SOME PARTNER VARIABLES
    if(openborvariant("in_showcomplete")){
        if(getglobalvar("partnerFull") != 1){setglobalvar("partnerFull", 1);}
    }


}

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

    //CHECK IF THE PLAYER IS IN A LEVEL
    if(openborvariant("in_level") && openborvariant("current_set") == 2){
        int volume        = openborvariant("effectvol");
        int speed        = 100;
        int loop        = 0;
        int menuPause    = getglobalvar("menuPause");
        int menuPausing = getglobalvar("menuPausing");
        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")){

            //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(menuPausing >= min && menuPausing < max){setglobalvar("menuPausing", menuPausing+add);}
                if(menuPausing == max){setglobalvar("menuPausing", min);}
            }
            if(    playerkeys(0, 1, "moveup")||
                playerkeys(1, 1, "moveup")||
                playerkeys(2, 1, "moveup")||
                playerkeys(3, 1, "moveup")){
               
                if(menuPausing > min && menuPausing <= max){setglobalvar("menuPausing", menuPausing-add);}
                if(menuPausing == min){setglobalvar("menuPausing", 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(menuPausing == 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(menuPausing== 1){
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
                    options();
                }

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

                 //SUMMON PARTNER TEST
                if(menuPausing == 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"));
                }

                //END GAME
                if(menuPausing == 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("menuPausing") == 0){font0 = 1;}else    //IS CONTINUE HIGHLIGHTED??
            if(getglobalvar("menuPausing") == 1){font1 = 1;}else    //IS OPTIONS HIGHLIGHTED??
            if(getglobalvar("menuPausing") == 2){font2 = 1;}else    //IS HOW TO PLAY HIGHLIGHTED??
            if(getglobalvar("menuPausing") == 3){font3 = 1;}else    //IS SELECT MUSIC TEST HIGHLIGHTED??
            if(getglobalvar("menuPausing") == 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 = "Select Music Test";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);
        }

        //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(menuPausing == 4){gameover();}
        }
    }
}

void loadAll()
{//Load all necessary variables

    //SCRIPT USED TO CLEAR ALL VARIABLES AND ASSETS
    if(getglobalvar("clearAll") != NULL()){clearAssets();clearlocalvar();clearglobalvar();}

    //PARTNER MENU FUNCTIONS
    if(getglobalvar("activeText") == NULL()){
        setglobalvar("highlight", 0);
        setglobalvar("selectPartner", "JoeNPC");
        setglobalvar("partnerAlive", 0);
        setglobalvar("partnerMode", "balanced");
        setglobalvar("partnerAggression", "*****");
        setglobalvar("partnerGetFood", "yes");
        setglobalvar("partnerFollow", "automatic");
        setglobalvar("partnerRespawn", "instantly");
        setglobalvar("partnerLifeBar", "full_hud");
        setglobalvar("activeText", 0);
    }

    //MUSIC MENU FUNCTIONS
    //if(getglobalvar("playList") == NULL()){
    //    setglobalvar("highlight", 0);
    //    setglobalvar("playList", 0);
    //}
   
    //LOAD ALL NECESSARY ASSETS (SPRITES, SOUNDS, ETC)
    saveAssets();
}

void saveAssets()
{//Load global assets for further use

    if(getglobalvar("saveAssets") == NULL()){ //TRIGGER TO ALLOW ALL VARIABLES TO BE DEFINED ONCE
       
        //CAUTION!! ALL GLOBAL VARIABLES BELOW WILL CHANGE ALL ASSETS USED IN MANY SCRIPTS
       
        //GLOBAL USAGE (PUT ALL NECESSARY SPRITES TO BE LOADED HERE)
        setglobalvar("parrow5", loadsprite("data/sprites/parrow5.png"));
       
        //TRIGGER TO STOP THE SCRIPT AFTER RUN ONCE, SAVE CPU POWER
        setglobalvar("saveAssets", 1);
    }
}

void clearAssets()
{//Clear all used assets to save memory

    if(getglobalvar("clearAssets") == NULL()){ //TRIGGER TO CLEAR ALL VARIABLES
   
        //GLOBAL USAGE (PUT ALL PREVIOUS LOADED SPRITES HERE TO SAVE MEMORY)
        free(getglobalvar("parrow5"));

        //TRIGGER TO STOP THE SCRIPT AFTER RUN ONCE, SAVE CPU POWER
        setglobalvar("clearAssets", 1);
    }
}

void musicPlaylist()
{
// Draw list of songs

    // DRAW MUSIC PLAYLIST

    if(getglobalvar("playList") == "Exist"){ // Does the music playlist exist?
        void str;
        float hRes    = openborvariant("hresolution");
        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 font0    = 0;                //ALL FONTS BELOW CHANGES FROM 0 TO 1 IF THE OPTION IS HIGHLIGHTED
        int font0    = 0;
        int font1    = 0;
        //int font2    = 0;
        //int font3    = 0;
        //int font4    = 0;
        //int font5    = 0;
        //int font6    = 0;
        int yAdd    = 11;
        int layer    = 1000000003;

        //DEFINE FONTS TO HIGHLIGHTED OPTIONS
        if(getglobalvar("highlight") == 0){    font0 = 1;}else    // BOSS MUSIC
        if(getglobalvar("highlight") == 1){    font1 = 1;}else    // STAGE 

        str = "Boss";//align = xPos1-strwidth(str, font0);
        align = (hRes-(strwidth(str, font0)))/2;
        drawstring(align, yPos, font0, str, layer);
        //str = getglobalvar("partnerMode");
        //drawstring(xPos2, yPos, font0, str, layer);

        yPos = yPos+yAdd;
        str = "Stage 1";align = (hRes-(strwidth(str, font0)))/2; //align = xPos1-strwidth(str, font0);
        drawstring(align, yPos, font1, str, layer);
        //str = getglobalvar("partnerAggression");
        //drawstring(xPos2, yPos, font1, str, layer);

    }

}

If I uncomment the following values from the music menu, it's gonna crash.

keyall.c:
C:
void main()
{//Global keyall scripts, detects player index
    int player = getlocalvar("player");
   
    musicPlaylist(player);

    if(player == 0 && openborvariant("count_players") <= 1){
        //menuPartners(player);
        //musicPlaylist(player);
    }
}

void musicPlaylist(int player){
//Adjust CPU partner mode and aggression
    void self        = getplayerproperty(player, "entity");
    int highlight    = getglobalvar("highlight");
    int hasplayed    = getplayerproperty(player, "hasplayed");
    int dir            = getentityproperty(self, "direction");
    int max            = 1;
    int min            = 0;
    int add            = 1;
    float x            = getentityproperty(self, "x");
    float y            = getentityproperty(self, "y");
    float z            = getentityproperty(self, "z");

    if(hasplayed){
        if(openborvariant("in_level")){ //CHECK IF THE GAME IS IN ANY LEVEL AND ARCADE LOCK IS "0"
            if(hasplayed && !openborvariant("pause") && !openborvariant("in_options")){ //CHECK IF THE GAME IS NOT PAUSED OR IN OPTIONS
                if(getglobalvar("playList") == 0 && getglobalvar("menuPausing") == 3){ //CHECK IF ANY MENU IS ALREADY ON
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                    changeopenborvariant("nopause", 1); //LOCK PAUSE COMMAND
                    changeopenborvariant("textbox", 1); //CALL TEXTBOX TO FREEZE THE GAME
                    setglobalvar("highlight", 0); //SET TO THE FIRST HIGHLIGHTED OPTION
                    setglobalvar("playList", "Exist"); //SET ACTIVE TEXT ON SCREEN TO "EXTRA MENU" TO ACTIVATE OTHER SCRIPTS
                    setglobalvar("menuPausing", 0);
                }
                else
                if(getglobalvar("playList") == "Exist" && playerkeys(player, 1, "attack2")){ //CHECK IF EXTRA MENU IS ALREADY ON
                    playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                    changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
                    changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
                    setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
                    setglobalvar("playList", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
                }
            }
        }       
    }

    if(getglobalvar("playList") == "Exist"){
        //HIGHLIGHT OPTIONS WHEN MOVE DOWN
        if(playerkeys(player, 1, "movedown")){
            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
            if(highlight >= min && highlight < max){setglobalvar("highlight", highlight+add);}
            if(highlight == max){setglobalvar("highlight", min);}
        }
       
        //HIGHLIGHT OPTIONS WHEN MOVE UP
        if(playerkeys(player, 1, "moveup")){
            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
            if(highlight > min && highlight <= max){setglobalvar("highlight", highlight-add);}
            if(highlight == min){setglobalvar("highlight", max);}
        }   

        //SPAWN CPU PARTNER IN-GAME
        if(playerkeys(player, 1, "attack") && hasplayed){ //ATTACK BUTTON IS PRESSED??
            if(getglobalvar("playList") == 0){ //IS PARTNER SPAWN OPTION HIGHLIGHTED??
                //if(getglobalvar("partnerIndex") == NULL()){ //ONLY 1 PARTNER IS ALLOWED
                    playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                    fademusic(0.5, "data/music/boss.bor", 1, 26369.60);
                    setglobalvar("highlight", 0); //RESET THE HIGHLIGHT OPTION

                    //CLOSE PARTNER MENU INSTANTLY
                    if(getglobalvar("playList") == "Exist"){ //CHECK IF EXTRA MENU IS ALREADY ON
                        playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                        changeopenborvariant("nojoin", 1); //PREVENT OTHER PLAYERS TO ENTER IN THE GAME
                        changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
                        changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
                        setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
                        setglobalvar("playList", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
                    }
                //}
            }else
            if(getglobalvar("playList") == 1){ //IS PARTNER SPAWN OPTION HIGHLIGHTED??
                //if(getglobalvar("partnerIndex") == NULL()){ //ONLY 1 PARTNER IS ALLOWED
                    playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                   
                    fademusic(0.5, "data/music/miami.bor", 1, 628476.81);
                    setglobalvar("highlight", 0); //RESET THE HIGHLIGHT OPTION

                    //CLOSE PARTNER MENU INSTANTLY
                    if(getglobalvar("playList") == "Exist"){ //CHECK IF EXTRA MENU IS ALREADY ON
                        playsample(openborconstant("SAMPLE_BEEP2"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0); //PLAY SAMPLE
                        changeopenborvariant("nojoin", 1); //PREVENT OTHER PLAYERS TO ENTER IN THE GAME
                        changeopenborvariant("nopause", 0); //UNLOCK PAUSE COMMAND
                        changeopenborvariant("textbox", NULL()); //CLEAR TEXTBOX TO NOT FREEZE THE GAME
                        setglobalvar("highlight", 0); //RESET HIGHLIGHT VARIABLE TO DEFAULT
                        setglobalvar("playList", 0); //SET ACTIVE TEXT ON SCREEN TO "0" TO DEACTIVATE OTHER SCRIPTS
                    }
                //}
            }
        }
    }

}

EDIT: Here is what it looks like.


This is what happens if I replace "menuPausing" with "menuPause" global varname.


I will post a log of an error I mentioned after this.
 
Last edited:
When I uncomment this one, I receive a crash.

C:
    //MUSIC MENU FUNCTIONS
    if(getglobalvar("playList") == NULL()){
        setglobalvar("highlight", 0);
        setglobalvar("playList", 0);
    }

Log:
Code:
Total Ram: 4171603968 Bytes
 Free Ram: 917200896 Bytes
 Used Ram: 6291456 Bytes

debug:nativeWidth, nativeHeight, bpp, Hz  1366, 768, 24, 60
OpenBoR v3.0 Build 6391, Compile Date: Apr  8 2020

Game Selected: ./Paks/ROD MAXED OUT!.pak

FileCaching System Init......    Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video.............    480x272 (Mode: 1)

Loading menu.txt.............    Done!
Loading fonts................    1 2 3 4 5 6 Done!
Timer init...................    Done!
Initialize Sound..............    
Loading sprites..............    Done!
Loading level order..........    Done!
Loading model constants......    Done!
Loading script settings......    Done!
Loading scripts..............    Done!
Loading models...............

Joystick: "UNKNOWN" connected at port: 0 at 2023-09-10 08:14:56
Cacheing 'Flash' from data/chars/misc/flash.txt
Cacheing 'Stone' from data/chars/Stone/Stone.txt
Cacheing 'Mai_Frost' from data/chars/mai/mai.txt
Cacheing 'Rick' from data/chars/Terry/Terry.txt
Cacheing 'Aki' from data/chars/Aki/Aki.txt
Cacheing 'Shinryu' from data/chars/Shinryu/Shinryu.txt
Cacheing 'Clint' from data/chars/clark/clark.txt
Cacheing 'Sunrei' from data/chars/athena/athena.txt
Cacheing 'Mina_Inferno' from data/chars/mina/mina.txt
Cacheing 'Kim' from data/chars/kim/kim.txt
Cacheing 'Evy' from data/chars/Vanessa/Vanessa.txt
Cacheing 'Terry' from data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt
Cacheing 'coll1' from data/bgs/select/col1.txt
Cacheing 'coll1b' from data/bgs/select/col1b.txt
Cacheing 'coll2' from data/bgs/select/col2.txt
Cacheing 'coll2b' from data/bgs/select/col2b.txt
Cacheing 'coll3' from data/bgs/select/col3.txt
Cacheing 'coll3b' from data/bgs/select/col3b.txt
Cacheing 'coll4' from data/bgs/select/col4.txt
Cacheing 'coll4b' from data/bgs/select/col4b.txt
Cacheing 'coll5' from data/bgs/select/col5.txt
Cacheing 'coll5b' from data/bgs/select/col5b.txt
Cacheing 'TerrySel' from data/bgs/select/terrysel.txt
Cacheing 'powave' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/powave.txt
Cacheing 'burnknuc' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt
Cacheing 'JoeD' from data/chars/joe/joed.txt
Cacheing 'JoeNPC' from data/chars/joe/joenpc.txt
Cacheing 'ShermieNPC' from data/chars/shermie/shermienpc.txt
Cacheing 'K'NPC' from data/chars/k/knpc.txt
Cacheing 'Hotdog' from data/chars/misc/hotdog.txt
Cacheing 'Pizza' from data/chars/misc/pizza.txt
Cacheing '1upR' from data/chars/misc/1upR.txt
Cacheing '1upG' from data/chars/misc/1upG.txt
Cacheing '1upB' from data/chars/misc/1upB.txt
Cacheing '1up' from data/chars/misc/1up.txt
Cacheing 'Money' from data/chars/misc/money.txt
Cacheing 'Time' from data/chars/misc/time.txt
Cacheing 'Gold' from data/chars/misc/gold.txt
Cacheing 'Box' from data/chars/misc/box.txt
Cacheing 'Table' from data/chars/misc/table.txt
Cacheing 'Chair' from data/chars/misc/chair.txt
Cacheing 'Fence' from data/chars/misc/fence.txt
Cacheing 'Drum' from data/chars/misc/drum.txt
Cacheing 'Phone' from data/chars/misc/Pbooth.txt
Cacheing 'Joe' from data/chars/joe/joe.txt
Cacheing 'Jones' from data/chars/jones/jones.txt
Cacheing 'K'' from data/chars/k/k.txt
Cacheing 'Cheng' from data/chars/Cheng/Cheng.txt
Cacheing 'Eiji' from data/chars/eiji/eiji.txt
Cacheing 'Lin' from data/chars/lin/lin.txt
Cacheing 'Shermie' from data/chars/shermie/shermie.txt
Cacheing 'Hwa' from data/chars/hwa/hwa.txt
Cacheing 'Max' from data/chars/max/max.txt
Cacheing 'Genjuro' from data/chars/genjuro/genjuro.txt
Cacheing 'Lucky' from data/chars/lucky/lucky.txt
Cacheing 'Choi' from data/chars/choi/choi.txt
Cacheing 'Billy' from data/chars/billy/billy.txt
Cacheing 'Seth' from data/chars/seth/seth.txt
Cacheing 'Whip' from data/chars/whip/whip.txt
Cacheing 'Gato' from data/chars/gato/gato.txt
Cacheing 'Geese' from data/chars/Geese/Geese.txt
Cacheing 'no1' from data/chars/no1/no1.txt
Cacheing 'robot' from data/chars/robot/robot.txt
Cacheing 'Knife' from data/chars/misc/knife.txt
Cacheing 'Shot' from data/chars/misc/shot.txt
Cacheing 'Star' from data/chars/misc/star.txt
Cacheing 'light' from data/chars/misc/light.txt
Cacheing 'heli' from data/chars/misc/heli.txt
Cacheing 'rain' from data/chars/misc/rain.txt
Cacheing 'bridge' from data/chars/misc/bridge.txt

Loaded 'Flash' from data/chars/misc/flash.txt 
Loaded 'Stone' from data/chars/Stone/Stone.txt 
Loaded 'Mai_Frost' from data/chars/mai/mai.txt 
sound_load_sample can't load sample from file 'data/sounds/mai.wav'!
sound_load_sample can't load sample from file 'data/sounds/mai.wav'!
Loaded 'Rick' from data/chars/Terry/Terry.txt 
Loaded 'Aki' from data/chars/Aki/Aki.txt 
Loaded 'Shinryu' from data/chars/Shinryu/Shinryu.txt 
Loaded 'Clint' from data/chars/clark/clark.txt 
Loaded 'Sunrei' from data/chars/athena/athena.txt 
Loaded 'Mina_Inferno' from data/chars/mina/mina.txt 
Loaded 'Kim' from data/chars/kim/kim.txt 
sound_load_sample can't load sample from file 'data/sounds/diepla.wav'!
Loaded 'Evy' from data/chars/Vanessa/Vanessa.txt 
Loaded 'Terry' from data/chars/heroes/kof_2k3_terry_sprite.7z/terry.txt 
Loaded 'powave' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/powave.txt 
Loaded 'burnknuc' from data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt 
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command 'void' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command 'if(ani' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command 'killentity(self);' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command '}' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Command '@end_script' not understood in file 'data/chars/heroes/kof_2k3_terry_sprite.7z/effects/burnknuc.txt'!
Loaded 'coll1' from data/bgs/select/col1.txt 
Loaded 'coll1b' from data/bgs/select/col1b.txt 
Loaded 'coll2' from data/bgs/select/col2.txt 
Loaded 'coll2b' from data/bgs/select/col2b.txt 
Loaded 'coll3' from data/bgs/select/col3.txt 
Loaded 'coll3b' from data/bgs/select/col3b.txt 
Loaded 'coll4' from data/bgs/select/col4.txt 
Loaded 'coll4b' from data/bgs/select/col4b.txt 
Loaded 'coll5' from data/bgs/select/col5.txt 
Loaded 'coll5b' from data/bgs/select/col5b.txt 
Loaded 'TerrySel' from data/bgs/select/terrysel.txt 

Loading models...............    Done!
Object engine init...........    Done!
Input init...................    
1 joystick(s) found!
UNKNOWN - 2 axes, 10 buttons, 0 hat(s)
Done!
Create blending tables.......    Done!
Save settings so far........    Done!



Can't play music file 'data/music/remix'

Can't play music file 'data/music/remix'

Can't play music file 'data/music/menu'

Can't play music file 'data/music/remix'
Level Loading:   'data/levels/testing.txt'
Total Ram: 4171603968 Bytes
 Free Ram: 810172416 Bytes
 Used Ram: 49483776 Bytes

Loaded 'phone' from data/chars/misc/Pbooth.txt 
Loaded 'drum' from data/chars/misc/drum.txt 
Loaded 'bridge' from data/chars/misc/bridge.txt 
Loaded 'JoeD' from data/chars/joe/joed.txt 

Level Loaded:    'data/levels/testing.txt'
Total Ram: 4171603968 Bytes
 Free Ram: 809435136 Bytes
 Used Ram: 50642944 Bytes
Total sprites mapped: 1208

Error, strwidth({string}, {font}): Invalid or missing parameter.
Script function 'strwidth' returned an exception, check the manual for details.
 parameters: <VT_EMPTY>   Unitialized, 1,  
 
********** An Error Occurred **********
*            Shutting Down            *

There's an exception while executing script 'update' Total Ram: 4171603968 Bytes
 Free Ram: 810061824 Bytes
 Used Ram: 51232768 Bytes

Release level data...........
Level Unloading: 'data/levels/testing.txt'
Total Ram: 4171603968 Bytes
 Free Ram: 810061824 Bytes
 Used Ram: 51232768 Bytes

RAM Status:
Total Ram: 4171603968 Bytes
 Free Ram: 810061824 Bytes
 Used Ram: 51232768 Bytes

Done!

Release graphics data........    Done!
Release game data............

Unload 'Flash' ............Done.
Unload 'Stone' ............Done.
Unload 'Mai_Frost' ............Done.
Unload 'Rick' ............Done.
Unload 'Aki' ............Done.
Unload 'Shinryu' ............Done.
Unload 'Clint' ............Done.
Unload 'Sunrei' ............Done.
Unload 'Mina_Inferno' ............Done.
Unload 'Kim' ............Done.
Unload 'Evy' ............Done.
Unload 'Terry' ............Done.
Unload 'powave' ............Done.
Unload 'burnknuc' ............Done.
Unload 'coll1' ............Done.
Unload 'coll1b' ............Done.
Unload 'coll2' ............Done.
Unload 'coll2b' ............Done.
Unload 'coll3' ............Done.
Unload 'coll3b' ............Done.
Unload 'coll4' ............Done.
Unload 'coll4b' ............Done.
Unload 'coll5' ............Done.
Unload 'coll5b' ............Done.
Unload 'TerrySel' ............Done.
Unload 'Phone' ............Done.
Unload 'Drum' ............Done.
Unload 'bridge' ............Done.
Unload 'JoeD' ............Done.

Warning: 1 script variants are not freed, dumping...
openbor_loadsprite

Release game data............    Done!
Release timer................    Done!
Release input hardware.......    Done!
Release sound system.........    Done!
Release FileCaching System...    Done!

**************** Done *****************

There's an exception while executing script 'update'
 
Here's a concept of how the music menu is gonna play like every time you select a certain song with background change. I also do want to save memory from leaking for memory optimization.

concept for chosen specific songs.png
 
Hi. I'm back. This time, I got the music menu via pause menu working well, but there are two issues that are not working right. First issue is the missing texts that are supposed to show the name of the songs after choosing the music menu option from the pause menu. Second issue is the one that has two out of three songs, not looping right and it just loops to the very beginning instead of looping to its respective offset. However, the other one loops correctly.

I must be missing something in both update.c and keyall.c. There must be something wrong I did as well.

I will come back with a video of these issues. As of now, I leave the codes here. Take a look at customPauseTest() function.

update.c:

keyall.c:
 
@Kratus Here are my issues that I described from my previous post along with the codes.


EDIT: The code kind of seems correct but its execution loops in a weird way on 2 songs, specifically 000 and 001. 002 is the only one that is looping correctly.

Do you mind if I can send you a PM about this?
 
Last edited:
:rolleyes: I made this (not boring, really) video which I struggled to access the select music option. I had to press start and go back to it for displaying the menu. But it was a text type entity that showed the song names in the list. This was before I started to change to a new pause menu for better access.

 
Last edited:
I'm starting all over again this time. I started with custom pause menu first, but I also added a new dummy option here. Here is my update.c for adding a new option along with these.

update.c:
C:
void main(){
    cusPause();
}

void cusPause()
{
    //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")){

            //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");
                }

                //TESTING
                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"));
                    setglobalvar("menuPause", 0);
                }

                //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 TESTING 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 = "Testing";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);
        }

        //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();}
        }
    }
}

Screenshot 2024-03-16 213338.png

I got my first step finished already.
 
Last edited:
I got update.c updated. Here's what I go so far, as well as keyall.c. But I will show keyall.c later.

update.c:
C:
#import "data/scripts/musicmenu_update.c"

One part that I changed.
C:
                //TESTING
                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"));
                    setglobalvar("menuPause", 0);
                    menuMusic();
                }

musicmenu_update.c:
C:
void menuMusic()
{
    void finished;
    void music = getglobalvar("bgmTest");
    void str;
    int align;
    int xPos1 = 151;
    int xDif = 20;
    int xPos2 = xPos1+xDif;
    int yPos = 70;

    int font0 = 0;
    int font1 = 0;
    int yAdd = 11;
    int layer = 1000000003;

    if(getglobalvar("highlight") == 1){ font0 = 1;}

    //ADD A "0" ALGARISM TO THE MUSIC NAME IF THE TRACK IS BELOW FROM 9
    if(music <= 9){music = "0"+getglobalvar("bgmTest");}

    if(getglobalvar("menuPause") == 3){
            str  = "bgm_test:";align = xPos1-strwidth(str, font0);
            drawstring(align, yPos, font0, str, layer);
            drawstring(xPos2, yPos, font0, music, layer);
    }

}

Sometimes, the menu shows but it only appears in less than a second and then disappears. Most of the times, the menu doesn't show. I'm not sure if I'm in the 2nd step or not since I'm always lost on what step to go with. At least I just started with update.c. I'm not good in making up globalvars, as well as file streams.


Is there something wrong?
 
I got update.c updated. Here's what I go so far, as well as keyall.c. But I will show keyall.c later.

update.c:
C:
#import "data/scripts/musicmenu_update.c"

One part that I changed.
C:
                //TESTING
                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"));
                    setglobalvar("menuPause", 0);
                    menuMusic();
                }

musicmenu_update.c:
C:
void menuMusic()
{
    void finished;
    void music = getglobalvar("bgmTest");
    void str;
    int align;
    int xPos1 = 151;
    int xDif = 20;
    int xPos2 = xPos1+xDif;
    int yPos = 70;

    int font0 = 0;
    int font1 = 0;
    int yAdd = 11;
    int layer = 1000000003;

    if(getglobalvar("highlight") == 1){ font0 = 1;}

    //ADD A "0" ALGARISM TO THE MUSIC NAME IF THE TRACK IS BELOW FROM 9
    if(music <= 9){music = "0"+getglobalvar("bgmTest");}

    if(getglobalvar("menuPause") == 3){
            str  = "bgm_test:";align = xPos1-strwidth(str, font0);
            drawstring(align, yPos, font0, str, layer);
            drawstring(xPos2, yPos, font0, music, layer);
    }

}

Sometimes, the menu shows but it only appears in less than a second and then disappears. Most of the times, the menu doesn't show. I'm not sure if I'm in the 2nd step or not since I'm always lost on what step to go with. At least I just started with update.c. I'm not good in making up globalvars, as well as file streams.


Is there something wrong?
Are you trying to trigger the test menu inside the music menu?
 
Are you trying to trigger the test menu inside the music menu?
I think so. Just trying to make the test menu display the text of the music menu after selecting it. Problem is, I don't know what step I am taking for this. I do believe I finished step 1, but I don't know if I'm in the next step or not. What should I change?
 
I think so. Just trying to make the test menu display the text of the music menu after selecting it. Problem is, I don't know what step I am taking for this. I do believe I finished step 1, but I don't know if I'm in the next step or not. What should I change?
@maxman

According to your video there's something that is closing the pause menu. In your code you are triggering the ESC key during the test menu (option 3), this has the same effect as pressing the real ESC, which will close the pause menu.

1711228042685.png
 
Thanks. I just removed the ESC commands from there. I just excluded/removed setglobalvar("menuPause", 0) line, leaving only menuMusic function in it for testing. As I press buttons several times, it says something like this.

bgm test: <VT EMPTY> Uninitialized

Here's my keyall.c for this.

C:
#import "data/scripts/musicmenu_playlist.c"
#import "data/scripts/musicmenu_mainkey.c"

void main(){
    int player = getlocalvar("player");
    menuMusic(player);
}

musicmenu_mainkey.c:
C:
#import "data/scripts/musicmenu_playlist.c"

void menuMusic(int player)
{

    int highlight = getglobalvar("highlight");
    int hasplayed = getplayerproperty(player, "hasplayed");
    int max = 1;
    int min = 0;
    int add = 1;
    int firstBgm = 0;
    int lastBgm = 10;

    if(getglobalvar("menuPause") == 3)
    {

        if(playerkeys(player, 1, "moveright"))
        {

            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);

            if(getglobalvar("highlight") == 1)
            {
                if(getglobalvar("bgmTest") >= firstBgm && getglobalvar("bgmTest") < lastBgm)
                {
                    setglobalvar("bgmTest", getglobalvar("bgmTest")+1);
                }else
                if(getglobalvar("bgmTest" == lastBgm))
                {
                    setglobalvar("bgmTest", firstBgm);
                }
                bgmTest();
                playList();
            }
        }

        if(playerkeys(player, 1, "moveleft"))
        {

            playsample(openborconstant("SAMPLE_BEEP"), 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);

            if(getglobalvar("highlight") == 1)
            {
                if(getglobalvar("bgmTest") > firstBgm && getglobalvar("bgmTest") <= lastBgm)
                {
                    setglobalvar("bgmTest", getglobalvar("bgmTest")-1);
                }else
                if(getglobalvar("bgmTest" == firstBgm))
                {
                    setglobalvar("bgmTest", lastBgm);
                }
                bgmTest();
                playList();
            }
        }

    }

}

musicmenu_playlist.c:
C:
void playList()
{
    if(openfilestream("data/music/dojo/playlist.txt") == -1){
        void file = createfilestream();
        void list = openfilestream("data/music/dojo/playlist.txt");

        changeTrack(file, list, 1); // TRACK 000
        changeTrack(file, list, 0); // TRACK 001
        changeTrack(file, list, 0); // TRACK 002
        changeTrack(file, list, 0); // TRACK 003
        changeTrack(file, list, 0); // TRACK 004
        changeTrack(file, list, 0); // TRACK 005
        changeTrack(file, list, 0); // TRACK 006
        changeTrack(file, list, 0); // TRACK 007
        changeTrack(file, list, 0); // TRACK 008
        changeTrack(file, list, 0); // TRACK 009
        changeTrack(file, list, 0); // TRACK 010
    }
}

void changeTrack(void file, void list, int newLine){
    int add = 1;
    int pos = 0;

    setfilestreamposition(file, pos);
    filestreamappend(file, getfilestreamargument(list, pos, "string"), newLine);
    pos = pos+add;
    setfilestreamposition(file, pos);
    filestreamappend(file, getfilestreamargument(list, pos, "string"), 1);
    pos = 0;
}

void bgmTest(){
    void music = getglobalvar("bgmTest");

    if(getglobalvar("highlight") == 1){
        if(music <= 9){music = music+".ogg";}
        playmusic("data/music/dojo"+music, 1);
    }
}
 
Last edited:
Thanks. I just removed the ESC commands from there. I just excluded/removed setglobalvar("menuPause", 0) line, leaving only menuMusic function in it for testing. As I press the attack button several times, it says something like this.
Same as I said before, try to make the music menu to work separately before mixing it in the pause menu. And I suggest saving a variable as a flag to turn the music menu on/off instead of just declaring the entire music menu while the option 3 is highlighted (this is the same logic I'm using with the "activeText" variable in the SOR2X).

Another idea is to play the music directly at option 3 without entering into a new menu only for music, same as I'm doing with the bgm option in the SORX. This way just by pressing left/right will be enough to change and play music.

musicmenu_playlist.c:
Why are you using the playlist scripts?
 
Why are you using the playlist scripts?
I thought it's required for the music playlist because I wanna include all the songs that are in the specific folder so I can play any of them from the menu.

Same as I said before, try to make the music menu to work separately before mixing it in the pause menu. And I suggest saving a variable as a flag to turn the music menu on/off instead of just declaring the entire music menu while the option 3 is highlighted (this is the same logic I'm using with the "activeText" variable in the SOR2X).
I don't know how I can separate the music menu, but you are right. I started mixing it like a newb. (I'm still terrible with globalvars).

Here's where I already set for option 3.

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



Another idea is to play the music directly at option 3 without entering into a new menu only for music, same as I'm doing with the bgm option in the SORX. This way just by pressing left/right will be enough to change and play music.
OK. Sounds good. I will try it out. Thank you.
 
Another idea is to play the music directly at option 3 without entering into a new menu only for music, same as I'm doing with the bgm option in the SORX. This way just by pressing left/right will be enough to change and play music.
You know what, Kratus? I'm gonna go with something way easier and more different this time right after I tested with the easiest suggestion you gave me, by playing the music in option 3. How about display a few rows of texts after selecting option 3 with a pause being active until you press a certain button to exit? I know I have to use keyall.c for this, but I'm waiting for your recommendation or suggestion on what better step to follow. I'm learning to separate it now, though it's hard to know which ones to separate. I get used to looking at how the structures go and start modifying to fit what I want it to look like, but sometimes in the end, I get some incorrect results. As of now, I have this part for update.c updated. Just selecting many times for displaying the given text, but it's okay.

C:
void menuMusic()
{
    void finished;
    void music = getglobalvar("bgmTest");
    void str;
    int align;
    int xPos1 = 151;
    int xDif = 20;
    int xPos2 = xPos1+xDif;
    int yPos = 70;
    int font0 = 0;
    int font1 = 0;
    int yAdd = 11;
    int layer = 1000000003;
    int player = getlocalvar("player");
    if(getglobalvar("highlight") == 0){ font0 = 1;}
    //ADD A "0" ALGARISM TO THE MUSIC NAME IF THE TRACK IS BELOW FROM 9
    //if(music <= 9){music = getglobalvar("bgmTest");}
    //if(getglobalvar("menuPause") == 3 && getglobalvar("activeText") == 0){
            //str  = "bgm_test:";align = xPos1-strwidth(str, font1);
            //drawstring(align, yPos, font0, str, layer);
            //drawstring(xPos2, yPos, font0, music, layer);
            drawstring(xPos1, yPos, font0, "Test_the_music", layer);
            drawstring(146, 100, 1, "001", layer);
            drawstring(176, 100, 0, "002", layer);
            drawstring(116, 100, 0, "000", layer);
            playmusic("data/music/dojo/001.ogg", 1, 470767.5);
    //}
}

Just displaying 3 texts on screen without an active pause after selecting option 3. I'm just getting started.

Same as I said before, try to make the music menu to work separately before mixing it in the pause menu. And I suggest saving a variable as a flag to turn the music menu on/off instead of just declaring the entire music menu while the option 3 is highlighted (this is the same logic I'm using with the "activeText" variable in the SOR2X).
How do you save a variable as a flag? Is it by declaring something like this: setglobalvar("iNeedThisSavedOrReceivedHere", 1)? If that is so, then where? In "activeText" variable or somewhere? Sorry for this one, but it's just that I get clueless/lost when it comes to separating things of the music menu from scratch before mixing it/them.
 
Last edited:
I know I have to use keyall.c for this, but I'm waiting for your recommendation or suggestion on what better step to follow
@maxman For menus I always sugges to use the keyall.c

I get used to looking at how the structures go and start modifying to fit what I want it to look like
This is the problem, I don't recommend going this way because will end with a lot of unnecessary stuff in your game, turning everything more complex than it really is and indeed without understanding how it works in the roots. It's ok for small and simple scripts, but if you plan to add big systems in your project I don't recommend it.

Instead, I recommend first reading my script, making some changes as a test in order to understand the flow, and then build yours from scratch line by line. Trust me, in the long term it's a lot easier to keep updating a project where you created the codes from scratch instead of updating a project with a lot of other people's codes.

In short, my menus are working with two main pillars:
- updated.c, used to draw everything to the screen
- keyall.c, used to detect key presses and change variables

That said, the first recommended step is to draw a simple content on the screen and change it through variables using the keyall.c.
Something like this:

Updated.c
C:
void main()
{
    variableDraw();
}

void variableDraw()
{//Draw a single variable on the screen
    void var    = getglobalvar("variable"); //GET THE VARIABLE
    void flag    = getglobalvar("flag"); //GET THE VARIABLE
    int xPos    = 50; //X POSITION ON THE SCREEN
    int yPos    = 100; //Y POSITION ON THE SCREEN
    int ySpace    = 20; //Y SPACING BETWEEN EACH LINE
    int font    = 0; //DEFAULT FONT
    int layer    = 1001; //DEFAULT LAYER

    //START VARIABLE IF NULL
    if(var == NULL()){
        setglobalvar("variable", 0);
    }

    //DRAW ALL INFO ON THE SCREEN
    drawstring(xPos, yPos, font, var, layer);
    drawstring(xPos, yPos+ySpace, font, flag, layer);
}

Keyall.c
C:
void main()
{
    int player = getlocalvar("player");
    
    variableFlag(player);
    variableChange(player);
}

void variableFlag(int player)
{//Change a global variable as a flag
    int flag = getglobalvar("flag"); //GET THE FLAG VARIABLE

    //ENABLE OR DISABLE THE GLOBAL VARIABLE AS A FLAG
    if(playerkeys(player, 1, "jump")){
        if(flag == NULL()){
            setglobalvar("flag", 1);
        }
        else
        {
            setglobalvar("flag", NULL());
        }
    }
}

void variableChange(int player)
{//Change a single variable on the screen
    int variable    = getglobalvar("variable"); //GET THE VARIABLE
    int max            = 5; //MAXIMUM VARIABLE INCREMENT
    int min            = 0; //MINIMUM VARIABLE DECREMENT
    int add            = 1; //INCREMENT-DECREMENT AMOUNT PER KEY PRESS

    //INCREMENT IF RIGHT IS PRESSED
    if(playerkeys(player, 1, "moveright")){

        //INCREMENT
        if(variable >= min && variable < max){
            setglobalvar("variable", variable+add);
        }

        //BACK TO THE MINIMUM VALUE IF MAXIMUM IS REACHED
        if(variable == max){
            setglobalvar("variable", 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);
        }
    }
}


With this example you are able to build big and complex menus just repeating these small steps.
 
Much appreciated!! I tested the sample, and it works very fine. Thank you very much for this! 🫂 This step-by-step process is really helpful.

I guess it would be fine to move the custom pause menu from update.c to updated.c (without it being modified in the first place). Tested it with updated.c in ROD, which has usually four options, and it works fine. Do I have any more step before I start creating a new menu?

EDIT: @Kratus, you are right. I'm going to need "activeText" variable for going to option 3. But I need/have to wait for the next step from you before moving to the new menu and registering to a certain option.
 
Last edited:
move the custom pause menu from update.c to updated.c
No, in the example I posted I was having a separated "music menu" in mind, but the pause menu is an exception and must stay in the update.c because this event works before an engine cycle is completed, unlike the updated.c which works when an engine cycle is completed. In this case both the content drawn and the key presses work together in the same script.

This is because some key presses are "canceled" in order to not activate some events in the default pause menu, a thing that is not possible to do in the updated.c

In short, the examples in my previous posts are for any other menu except the pause menu. However, in the v4 you have the inputall.c event which works before any input takes effect, replacing the update.c in this case.

Exclusively for the pause menu:
- in the v4 you can use inputall.c together with updated.c
- in the v3 you must use everything inside the update.c

For other menus:
- both v3/v4 can use updated.c together with keyall.c in case you don't need to disable/skip any default engine behaviour.

1711564461406.png

EDIT: @Kratus, you are right. I'm going to need "activeText" variable for going to option 3. But I need/have to wait for the next step from you before moving to the new menu and registering to a certain option.
No need to replicate the same "activeText" I'm using in the SOR2X, instead you can use a simple flag like I mentioned in my previous post in order to activate a specific event.

In short:
- if "variable" value is NULL(), event disabled
- if "variable" value is 1, event enabled

Using this logic, you can create a separated music menu which only works if the variable value is 1. And you can enable/disable it every time you press a key if the option 3 is highlighted, but don't forget to create another condition in your pause menu to hide it if the flag is 1, otherwise you will have both menus on the screen.
Something like...

C:
//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()){
 
I am having a blast with these global variables after creating them from scratch and setting them to suit my needs in keyall.c. Sooner or later, I can mix these after learning all the basics of globalvars for menus.

C:
void main(){
    int player = getlocalvar("player");

    variableFlag(player);
    variableChange(player);
    variTest(player); // NEW
    variPause(player); // NEW
}

void variableFlag(int player)
{// Change a global variable as a flag
    int flag = getglobalvar("flag");
    
    //ENABLE OR DISABLE THE GLOBAL VARIABLE AS A FLAG
    if(playerkeys(player, 1, "jump")){
        if(flag == NULL()){
            setglobalvar("flag", 1);
        }else{
            setglobalvar("flag", NULL());
        }
    }
}
void variTest(int player){
    int vartest = getglobalvar("vartest");
    if(openborvariant("in_level")){
        if(playerkeys(player, 1, "attack2")){
            if(vartest == NULL()){
                setglobalvar("vartest", 1);
                playmusic("data/music/dojo2/miami.bor", 1, 628476.81);
            }else if(vartest == 1){
                setglobalvar("vartest", 2);
                playmusic("data/music/dojo2/italy.bor", 1, 372394.78);
            }else{
                setglobalvar("vartest", NULL());
                //playmusic("data/music/dojo/001.ogg", 1, 470767.5);
                playmusic("data/music/remix.bor", 1);
            }
        }
    }
}
void variPause(int player){
    if(openborvariant("in_level")){
        int varPause = getglobalvar("varPause");
        if(playerkeys(player, 1, "attack3")){
            if(varPause == NULL()){
                setglobalvar("varPause", 1);
                changeopenborvariant("textbox", 1);
            }else{
                setglobalvar("varPause", NULL());
                changeopenborvariant("textbox", 0);
            }
        }
    }
}
void variableChange(int player)
{//Change a single variable on the screen
    int variable    = getglobalvar("variable"); //GET THE VARIABLE
    int max            = 5; //MAXIMUM VARIABLE INCREMENT
    int min            = 0; //MINIMUM VARIABLE DECREMENT
    int add            = 1; //INCREMENT-DECREMENT AMOUNT PER KEY PRESS
    //INCREMENT IF RIGHT IS PRESSED
    if(playerkeys(player, 1, "moveright")){
        //INCREMENT
        if(variable >= min && variable < max){
            setglobalvar("variable", variable+add);
        }
        //BACK TO THE MINIMUM VALUE IF MAXIMUM IS REACHED
        if(variable == max){
            setglobalvar("variable", 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);
        }
    }
}


I use one button for playing music, while I use the other button for freezing the gameplay. This is a lot of fun!😁

And you can enable/disable it every time you press a key if the option 3 is highlighted, but don't forget to create another condition in your pause menu to hide it if the flag is 1, otherwise you will have both menus on the screen.
Something like...

C:
//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()){
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. Even if I want to display the texts for the menu, I will have to use update.c for this as you said. I'm not sure what to do with the paused game though.

Thank you @Kratus for this amazing menu script example.
 
Back
Top Bottom