Animated screens - the easy way.

For this tutorial, we use script.txt, not script.c. And you should need to put it under the DATA folder.
And no, it doesn't need main or anything like that.
Understood, thanks alot.
For now, I am just going through your tutorial index list one by one to see which one I can use in my new game. I will start working on it in November or so.
 
Understood, thanks alot.
For now, I am just going through your tutorial index list one by one to see which one I can use in my new game. I will start working on it in November or so.
I just started applying this script to my updated.c for the title screen animation, but somehow it keeps on adding an entity on the screen everytime the engine goes from the intro to the title screen.
Is there something missing such as killentity with globalvar?
I added the globalvar for spawned entity and kill it with the killentity function, and it seemed to prevent from the addition.

Thank you
 
I added the globalvar for spawned entity and kill it with the killentity function, and it seemed to prevent from the addition.
You don't need a globalvar for that. This is handled by this loop:

C-like:
if(openborvariant("in_titlescreen"))
    {  
        void counter = getlocalvar("counter");
        counter = setlocalvar("counter",0);
    }
 
You don't need a globalvar for that. This is handled by this loop:

C-like:
if(openborvariant("in_titlescreen"))
    {
        void counter = getlocalvar("counter");
        counter = setlocalvar("counter",0);
    }
What I meant was
I want the spawned entity to disappear completely in the intro, then reappears whenever the engine is back to the title screen again.
Basically, it disappears when the engine runs the intro.txt, then appears during the title screen, and repeat..
I had this in the intro script, but this code does not killentity I don't think, basically the spawned entity is still in the memory.

Code:
        void counter = getlocalvar("counter");

        counter = setlocalvar("counter",0);

BTW, is there a way to detect the player currently in the options menu?
I had this but it does not detect it for some reasons,
Code:
openborvariant("in_options")

Thank you
 
I want the spawned entity to disappear completely in the intro, then reappears whenever the engine is back to the title screen again.
Then you have to change the code - this code is spawning an entity on the select screen, not in the title screen.

Here is an update version I am using on my MMPR project - I have different entities for TITLE and SELECT screen:
 
Then you have to change the code - this code is spawning an entity on the select screen, not in the title screen.

Here is an update version I am using on my MMPR project - I have different entities for TITLE and SELECT screen:
I had this code in the title screen:
Code:
    {   
 
        void counter = getlocalvar("counter");
        void vSpawn;
        while(counter!=1)
        {
            void subent;
            loadmodel("bgfx"); // name of the entity to be loaded
            clearspawnentry(); // clean the spawn entry
            setspawnentry("name", "bgfx"); // define the entity to be spawn
            setspawnentry("coords", 1,0,-1); // set the position of the entity
            subent=spawn();  //  spawn the entity
            changeentityproperty(subent, "position", 1,0,-1); //for safe, set again the position
            counter = setlocalvar("counter",1); // turn on the variable, blocking a new spawn to be made
            }

    }

and this code in the intro and menu screens:
Code:
        void counter = getlocalvar("counter");
        counter = setlocalvar("counter",0);

It kept on adding 1 entity to the title screen everytime the engine switches from title screen to the intro screen then back to the title screen.
Basically, there would be 5 entities on the title screen after it switches back and forth 5 times.
I had to add the globalvar and killentity to stop it from happening.

isn't this function clearspawnentry(); supposed to kill the previous spawned entity?
I don't know why it is not working for me.

Thank you
 
I'm having trouble getting the select screen background(s) after I added the new "animated" title background for the title screen, but I made the animated select screen solo before which worked. What am I missing for this setup? I have forgotten how to set up this one. This one is part of updated.c.

C:
void aniScreen(){
    void counter = getlocalvar("counter"); //Set a variable to trigger the spawn on and off (title)
    void counter2 = getlocalvar("counter2"); //Set a variable to trigger the spawn on and off (select)
    void counter3 = getlocalvar("counter3"); //Set a variable to trigger the spawn on and off (select)

    if(openborvariant("in_menuscreen")){
        counter = setlocalvar("counter", 0);      
    }

    if((openborvariant("in_titlescreen")) && (counter != 1)){
        void subent;
        loadmodel("bgmtitle");
        clearspawnentry();
        setspawnentry("name", "bgmtitle");
        setspawnentry("coords", 1, 0, -1);
        subent = spawn();
        void mStyle = getglobalvar("musicStyle");

        if(mStyle == 0){
            changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW1"));
        }else if(mStyle == 1){
            changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW2"));
        }else if(mStyle == 2){
            changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW3"));
        }

        //counter = setlocalvar("counter", 1);
    }

    if(openborvariant("in_menuscreen")){
        counter = setlocalvar("counter", 2);      
    }

    if(openborvariant("in_selectscreen") && (counter != 3)){
        //void counter = getlocalvar("counter");
        void vSpawn;
        while(counter!=3){
            void subent;
            loadmodel("scrSel");
            clearspawnentry();
            setspawnentry("name", "scrSel");

            void mStyle = getglobalvar("musicStyle");
            setspawnentry("coords", 1,0,-1); // set the position of the entity
            subent=spawn();  //  spawn the entity
            changeentityproperty(subent, "position", 1,0,-1); //for safe, set again the position
            counter = setlocalvar("counter",3); // turn on the variable, blocking a new spawn to be made
            //counter2 = setlocalvar("counter2",1);

            //cusent = spawn();
            //changeentityproperty(cusent, "position", 440,130,-1); //for safe, set again the position
            if(mStyle == 0){
                changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW1"));
                //counter = setlocalvar("counter",1);
            }else if(mStyle == 1){
                changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW3"));
                //counter = setlocalvar("counter",1);
            }else if(mStyle == 2){
                changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW2"));
                //counter = setlocalvar("counter",1);
            }
        }
    }
}

For title screen:
Code:
name bgmtitle
type none
facing 1
palette none
nomove 1 1
#setlayer -100000

anim spawn

    delay 5
    offset 1 1
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif

anim follow1 #green

    delay 2
    offset 0 0
    @cmd changeentityproperty getlocalvar("self") "direction" 1
    frame data/bgs/title/titleG.gif
    frame data/bgs/title/titleG.gif

anim follow2 #red

    delay 2
    offset 0 0
    @cmd changeentityproperty getlocalvar("self") "direction" 1
    frame data/bgs/title/titleR.gif
    frame data/bgs/title/titleR.gif

anim follow3 #blue

    delay 2
    offset 0 0
    @cmd changeentityproperty getlocalvar("self") "direction" 1
    frame data/bgs/title/titleB.gif
    frame data/bgs/title/titleB.gif

For select screen (this only worked until I added the title screen entity):
Code:
name scrSel
type none
facing 1
palette none
nomove 1 1
setlayer -100000

animationscript data/scripts/animation/default.c

load selection
load bgmgrid
load selectr
load selectg
load selectb
load zeus2

anim spawn
    offset 480 0
    delay 2
    @cmd projectile 1 "selection" 0 0 0
    #custentity zeus2
    #spawnframe 0 444 130 0 1
    frame data/chars/misc/empty.gif
    frame data/chars/misc/empty.gif

anim follow1 #Green
    delay 2
    offset 0 0
    @cmd spawn001 "bgmgrid" "bgmgrid" 0 3 0 1
    spawnframe 0 30 -40 0 0
    custentity selectg
    @cmd changeentityproperty getlocalvar("self") "direction" 1
    frame data/bgs/select/selectg.png
    frame data/bgs/select/selectg.png


anim follow2 #Blue

    delay 2
    offset 0 0
    spawnframe 0 0 0 0 0
    custentity selectb
    #@cmd spawn01 "selectb" 0 0 0
    @cmd spawn001 "bgmgrid" "bgmgrid" 2 3 0 1
    @cmd changeentityproperty getlocalvar("self") "direction" 1
    frame data/bgs/select/selectb.png
    frame data/bgs/select/selectb.png


anim follow3 #Red

    delay 2
    #offset 480 0
    offset 0 0
    spawnframe 0 30 0 0 0
    subentity selectr
    @cmd spawn001 "bgmgrid" "bgmgrid" 1 3 0 1
    @cmd changeentityproperty getlocalvar("self") "direction" 1
    frame data/bgs/select/selectr_.png
    frame data/bgs/select/selectr_.png

Edit: I am quite lost on where to get the select screen part working. It crashes every time I select a game mode which has select screen scripted.
 
Last edited:
Edit: I am quite lost on where to get the select screen part working. It crashes every time I select a game mode which has select screen scripted.
I would need to see your log, but from my experience, this happens because you simply refer to a localvar without ever describe it on the first place.

Like this:
C-like:
void aniScreen(){
    void counter = getlocalvar("counter"); //Set a variable to trigger the spawn on and off (title)
    void counter2 = getlocalvar("counter2"); //Set a variable to trigger the spawn on and off (select)
    void counter3 = getlocalvar("counter3"); //Set a variable to trigger the spawn on and off (select)

Since you are using a localvar inside a function, it will be available only in the local scope, not outside it.
Put the variables outside the function, like on my example on the first post.

And notice that I always declare the variable - void counter = getlocalvar("counter") - before accessing it

C-like:
void main(){

if(openborvariant("in_titlescreen"))
    {   
        void counter = getlocalvar("counter");
        counter = setlocalvar("counter",0);
    }
    
if(openborvariant("in_selectscreen"))
    {   
 
        void counter = getlocalvar("counter");
        void vSpawn;
        while(counter!=1)
 
Since you are using a localvar inside a function, it will be available only in the local scope, not outside it.
Put the variables outside the function, like on my example on the first post.

Minor correction here. Localvars (set/getlocalvar())are always local to the script instance, not the individual function. It doesn't matter when or how you declare them.

DC
 
The log says, "Out of memory!"j in the attachment. (Maybe I still have trouble with getlocalvar("counter")?)

I have other entities loaded within an entity that has 'palette none' in the select screen area (depending on the chosen music style).

I made my changes using getlocalvar("counter") and it seems to work. But accessing to the select screen is still a problem due to memory leaking out.

C:
void aniScreen(){
    //void counter = getlocalvar("counter"); //Set a variable to trigger the spawn on and off (title)
    //void counter2 = getlocalvar("counter2"); //Set a variable to trigger the spawn on and off (select)
    //void counter3 = getlocalvar("counter3"); //Set a variable to trigger the spawn on and off (select)

    if(openborvariant("in_titlescreen")){
        void counter = getlocalvar("counter");
        counter = setlocalvar("counter", 0);      
    }

    if(openborvariant("in_titlescreen") || openborvariant("in_menuscreen")){
        void counter = getlocalvar("counter");
        void subent;
        loadmodel("bgmtitle");
        clearspawnentry();
        setspawnentry("name", "bgmtitle");
        setspawnentry("coords", 1, 0, -1);
        subent = spawn();
        changeentityproperty(subent, "position", 1,0,-1);
        void mStyle = getglobalvar("musicStyle");

        if(mStyle == 0){
            changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW1"));
        }else if(mStyle == 1){
            changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW2"));
        }else if(mStyle == 2){
            changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW3"));
        }

        //counter = setlocalvar("counter", 1);
    }

    //if(openborvariant("in_menuscreen")){
    //    counter = setlocalvar("counter", 2);      
    //}

    if(openborvariant("in_selectscreen")){
        void counter = getlocalvar("counter");
        void vSpawn;
        while(counter!=1){
            void counter = getlocalvar("counter");
            void subent;
            loadmodel("scrSel");
            clearspawnentry();
            setspawnentry("name", "scrSel");

            void mStyle = getglobalvar("musicStyle");
            setspawnentry("coords", 1,0,-1); // set the position of the entity
            subent=spawn();  //  spawn the entity
            changeentityproperty(subent, "position", 1,0,-1); //for safe, set again the position
            //counter = setlocalvar("counter",3); // turn on the variable, blocking a new spawn to be made
            //counter2 = setlocalvar("counter2",1);

            //cusent = spawn();
            //changeentityproperty(cusent, "position", 440,130,-1); //for safe, set again the position
            if(mStyle == 0){
                changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW1"));
                //counter = setlocalvar("counter",1);
            }else if(mStyle == 1){
                changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW3"));
                //counter = setlocalvar("counter",1);
            }else if(mStyle == 2){
                changeentityproperty(subent, "animation", openborconstant("ANI_FOLLOW2"));
                //counter = setlocalvar("counter",1);
            }
        }
    }
}
 

Attachments

The log says, "Out of memory!"j in the attachment. (Maybe I still have trouble with getlocalvar("counter")?)

I have other entities loaded within an entity that has 'palette none' in the select screen area (depending on the chosen music style).
May @DCurrent corrects me but, as far as I know, those "palette none" entites won't add too much to the memory consumption, unless you really do something serious - as this will cost 768 bytes per image. But scritp is a whole different animal. Probably you are setting the same varible over and over.

And I took a look at your log and I can see some issues:
1751662934609.png
 
Something I noticed when implementing this, actually:

When I enter a character select screen and then return to the title screen with esc, the background entity disappears. Whereas if I'm in a level and end the game, the bg entity reappears just fine. I feel like I'm overlooking something though.

Here's what I have for reference in my updated.c


Code:
void main()
{
    
if(openborvariant("in_titlescreen")){
drawstring(110,10,3,"Version 1.10");
        drawstring(110,250,2,"MysticalMist 2024-2026");
        void counter = getlocalvar("counter");
        void vSpawn;
        void counter2 = getlocalvar("counter2");
        counter2 = setlocalvar("counter2",0);
        while(counter!=1)
        {
            void subent;
            loadmodel("bgfx"); // name of the entity to be loaded
            clearspawnentry(); // clean the spawn entry
            setspawnentry("name", "bgfx"); // define the entity to be spawn
            setspawnentry("coords", 1,0,-1); // set the position of the entity
            subent=spawn();  //  spawn the entity
            changeentityproperty(subent, "position", 1,0,-1); //for safe, set again the position
            counter = setlocalvar("counter",1); // turn on the variable, blocking a new spawn to be made
            }
}

  if(openborvariant("in_level")){
    displayContinue();
//Announcer
processRushCount();
  }

if(openborvariant("in_menuscreen"))
    {   
          drawstring(110,10,3,"Version 1.10");
        drawstring(110,250,2,"MysticalMist 2024-2026");
        void counter = getlocalvar("counter");
        void vSpawn;
        void counter2 = getlocalvar("counter2");
        counter2 = setlocalvar("counter2",0);
        while(counter!=1)
        {
            void subent;
            loadmodel("bgfx"); // name of the entity to be loaded
            clearspawnentry(); // clean the spawn entry
            setspawnentry("name", "bgfx"); // define the entity to be spawn
            setspawnentry("coords", 1,0,-1); // set the position of the entity
            subent=spawn();  //  spawn the entity
            changeentityproperty(subent, "position", 1,0,-1); //for safe, set again the position
            counter = setlocalvar("counter",1); // turn on the variable, blocking a new spawn to be made
            }
    }
if(openborvariant("in_halloffamescreen"))
    {   
          drawstring(110,10,3,"Version 1.10");
        drawstring(110,250,2,"MysticalMist 2024-2026");
        void counter2 = getlocalvar("counter2");
        void vSpawn;
        void counter = getlocalvar("counter");
        counter = setlocalvar("counter",0);
        while(counter2!=1)
        {
            void subent;
            loadmodel("bgfx"); // name of the entity to be loaded
            clearspawnentry(); // clean the spawn entry
            setspawnentry("name", "bgfx"); // define the entity to be spawn
            setspawnentry("coords", 1,0,-1); // set the position of the entity
            subent=spawn();  //  spawn the entity
            changeentityproperty(subent, "position", 1,0,-1); //for safe, set again the position
            counter2 = setlocalvar("counter2",1); // turn on the variable, blocking a new spawn to be made
            }

    }
}
 
When I enter a character select screen and then return to the title screen with esc, the background entity disappears. Whereas if I'm in a level and end the game, the bg entity reappears just fine. I feel like I'm overlooking something though.
That is because you need to reset the "counter" variable to 0 in your "in_selectscreen".
When you exit from the game normally, it will trigger the "in_halloffame", where you can see this line:
Code:
counter = setlocalvar("counter",0);

You can just add this to your code (inside of the main() loop of course):
C-like:
if(openborvariant("in_selectscreen"))
    {   
        counter = setlocalvar("counter",0);
    }
 
Back
Top Bottom