[SOLVED] Text Box not Working (GMS 1.4)

K

Koro

Guest
Code:
///Create
text0 = "Hey, this is HQ, do you hear us?"
text1= "You: Yeah, I hear you."
text2= "Now commander, what are these memes we have to get? They didn't give a great# explanation back at base."
text3 = "Commander: These memes are a highly dangerous drug. A stimulant and a steroid,# the terrorists are using them to grow stronger."
text4 = "Your mission is to aqquire the memes, and take out the three terrorist leaders.# The Pope, The Doctor, and The 💩💩💩💩poster."
text5 = "By the way, your code name is Spice."
text6 = "Spice: Alright, commencing mission."
str = text0
Code:
///Step
if global.bar_activate = true
{visible = true}
if global.bar_activate = false
{visible = false}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text0
{str = text1}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text1
{str = text2}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text2
{str = text3}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text3
{str = text4}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text4
{str = text5}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text5
{str = text6}
Code:
//Draw GUI
draw_set_colour(c_white);
draw_set_font(fnt_textbox);
draw_text(40, 40, str );
It starts off at the first text box but then skips all the way to the end when i press space
 
T

TonyZh

Guest
Code:
///Create
text0 = "Hey, this is HQ, do you hear us?"
text1= "You: Yeah, I hear you."
text2= "Now commander, what are these memes we have to get? They didn't give a great# explanation back at base."
text3 = "Commander: These memes are a highly dangerous drug. A stimulant and a steroid,# the terrorists are using them to grow stronger."
text4 = "Your mission is to aqquire the memes, and take out the three terrorist leaders.# The Pope, The Doctor, and The ****poster."
text5 = "By the way, your code name is Spice."
text6 = "Spice: Alright, commencing mission."
str = text0
Code:
///Step
if global.bar_activate = true
{visible = true}
if global.bar_activate = false
{visible = false}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text0
{str = text1}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text1
{str = text2}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text2
{str = text3}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text3
{str = text4}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text4
{str = text5}
if global.bar_activate = true
&& keyboard_check_pressed(vk_space)
&& str = text5
{str = text6}
Code:
//Draw GUI
draw_set_colour(c_white);
draw_set_font(fnt_textbox);
draw_text(40, 40, str );
It starts off at the first text box but then skips all the way to the end when i press space
I think every value becomes true simultaneously. That's why it will skip to the end. So you will have to find a way to fix that.
 
Read through the code step by step:
Code:
Step 1: Is global.bar_active true and is space being held and is str equal to text0?
Step 2: Ok, that's all true, so now I'll set str to text1.
Step 3: Is global.bar_active true and is space being held and is str equal to text1?
Step 4: Ok, that's all true, so now I'll set str to text2.
Step 5: Is global.bar_active true and is space being held and is str equal to text2?
Step 6: Ok, that's all true, so now I'll set str to text2.
This all happens in a single step, which on default settings happens 30 times a second. I hope you can see where this leads. As soon as your first statement is true, then every other statement will also turn out to be true in that step, so the only value you'll ever see is the last value, as str is first being set to text1 then text2 then text3 and so on until text6 every single step.
 
K

Koro

Guest
Ok i just tested it out i used a different key for each page and it worked, but I want it so that it will only proceed with the space bar so i trying to set an alarm
 
A very simple way to fix it would be to change keyboard_check_pressed to keyboard_check_released.

EDIT: Actually, that might not work cuz it's all processing in one step.
 
K

Koro

Guest
A very simple way to fix it would be to change keyboard_check_pressed to keyboard_check_released.

EDIT: Actually, that might not work cuz it's all processing in one step.
Alright I tried the keyboard_check_pressed to keyboard_check_released.thing that didn't work
but I added a timer and alarm to the text box and it works just fine now
 
Top