GMS 2.3+ is this a bug?

tomlee2020

Member
create code
--------------------
GML:
state="HOUTUI";

HOUTUI_state=0;
---------------------
step code
--------------------
GML:
if (state=="HOUTUI") {

    if (HOUTUI_state==0) {

    HOUTUI_state=1;

           show_debug_message("2222")



    }

    else {

       image_index+=0.18;

             show_debug_message("1111")

        Script5();

        //HOUTUI_state=0

    }



}
--------------------
Script5 code
------------------------
GML:
function Script5(){
                        
state="HOUTUi";
HOUTUI_state=0; }
i run this code output only show "
222
1111"
"
But I think he should loop print 222 and 1111
if i do not use Script5 i change code like this
GML:
if (state=="HOUTUI") {
if (HOUTUI_state==0) {
HOUTUI_state=1;
show_debug_message("2222")

}
else {
image_index+=0.18;
show_debug_message("1111")
HOUTUI_state=0
}

}
------------------------
it will loop print 222 and 1111

who can help me?is this a bug? or i do now know how to use Script? thank you!
 
Last edited:

Roldy

Member
Your code is a mess and it is hard to read.
When you post code use the 'Code' Tool provided in this forum:
1606241403109.png
e.g.
GML:
function Script5() {
    state="HOUTUi";
    HOUTUI_state=0;
}
Writing code is more for humans and less for computers. A computer can read machine language and doesn't care what your code looks like. Take the time and write out your thoughts and code so people can easily understand it. More importantly, take the time to write and structure your code so YOU can easily understand it; today, a week or month or a year from now.

In the function Script5():

GML:
function Script5() {
    state="HOUTUi";  // Is this a typo?   A lower case 'i'. "HOUTUi" is not the same as "HOUTUI"
    HOUTUI_state=0;
}
 

tomlee2020

Member
Your code is a mess and it is hard to read.
When you post code use the 'Code' Tool provided in this forum:
View attachment 35879
e.g.
GML:
function Script5() {
    state="HOUTUi";
    HOUTUI_state=0;
}
Writing code is more for humans and less for computers. A computer can read machine language and doesn't care what your code looks like. Take the time and write out your thoughts and code so people can easily understand it. More importantly, take the time to write and structure your code so YOU can easily understand it; today, a week or month or a year from now.

In the function Script5():

GML:
function Script5() {
    state="HOUTUi";  // Is this a typo?   A lower case 'i'. "HOUTUi" is not the same as "HOUTUI"
    HOUTUI_state=0;
}
i have changed code ,please help me
 

Roldy

Member
i have changed code ,please help me

That looks better. I did help you in my original post:


GML:
// Step code

if (state=="HOUTUI") {
    ///
}

// Script5 code

function Script5() {
    state="HOUTUi";  // <------ "HOUTUi" does not equal "HOUTUI".
    HOUTUI_state=0;
}
 
Top