• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Text writer object stops recognising variables when duplicated ( Doesn't use global variables )

It works when it's the same object, or multiple of the same object in the room, but as soon as I duplicate it, the duplicated object doesn't recognise ANY of the variables.
Error:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Draw Event
for object object7:

Variable object7.endtextbox(100016, -2147483648) not set before reading it.
at gml_Object_object7_DrawGUI_1 (line 1) - if endtextbox = false{
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_object7_DrawGUI_1 (line 1)

Create:
GML:
endtextbox = true
begintext = false
draw_set_font(font0)
txt_num = 0
draw_set_color(c_white)
//this is how long the text can beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee//
txt[1] = 'This is a text test :)'
txt[2] = ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ."
amountoftxts = 2 
time = 0
txt1 = ""
exited = true
textbox = false
textboxopen = false
canskip = false
textboxdown = false
Step:
GML:
if place_meeting(x,y,Frisk){
if endtextbox = false{
textboxopen = false
if begintext = true{
if keyboard_check_pressed(ord("X")) or keyboard_check_pressed(vk_shift){
time = time + 100000
}
else{
if txt1 != txt[current]{
time = time + 1.5
}}
if txt1 = txt[current]{
canskip = true
}
else{
canskip = false
}
if keyboard_check_pressed(ord("Z"))
if canskip = true{
{
    time = 0
    txt_num = txt_num + 1
    current += 1
    global.textbox = true
    txt1 = ""
}}

if txt_num < amountoftxts{
    global.canwalk = false
    global.textbox = true
}

if txt_num > amountoftxts{
    global.canwalk = true
    global.textbox = false
    textboxopen = false
    endtextbox = true
    textbox = false
}
else{txt1 = string_copy(txt[txt_num], 0, time/3)}}
if begintext = true{
Frisk.image_index = 0
}
}
}
if Frisk.y > room_height / 2 {
textboxdown = true
}
else{
textboxdown = false
}
Interact with player object ("Frisk"):
GML:
if txt_num = 0 {
if keyboard_check_pressed(ord('Z')){
if textboxopen = false{
begintext = true
txt_num = 1
global.canwalk = false
endtextbox = false
current = 1
}}
}
if txt_num > amountoftxts{
if keyboard_check_pressed(ord('Z')){
begintext = true
global.canwalk = true
endtextbox = true
current = 0
txt_num = 0
}
}
Draw GUI:
GML:
if endtextbox = false{
if textboxdown = 0{ // Draw the text box below//
draw_set_font(font0)
draw_set_color(c_white)
draw_rectangle(32,320,609,471,0)
draw_set_color(c_black)
draw_rectangle(38,326,603,465,0)
draw_set_color(c_white)
draw_text_ext(60,340,"*",40,450)
draw_text_ext(90,340,txt1,36,475)
}
if textboxdown = 1{ //Draw the text box on top
draw_set_font(font0)
draw_set_color(c_white)
draw_rectangle(32,10,609,161,0)
draw_set_color(c_black)
draw_rectangle(38,16,603,155,0)
draw_set_color(c_white)
draw_text_ext(60,30,"*",40,450)
draw_text_ext(90,30,txt1,36,475)
}
}
 

TailBit

Member
When there are errors that appear after changing the files, then you might want to press the broom icon to clean the chache

Clean - GameMaker Studio 2 keeps a Cache of files to help speed up compile time when testing. However sometimes a "stale" cache can lead to odd and unexpected errors in your game, in which case the first thing you should do is clean the cache from here and re-test. It is also a good idea to clean the cache before you create a final executable for the target platform. Note that this command is the same as pressing the Clean Cache button in the IDE.
 

Ommn

Member
If you want to call a variable from another object, you must write the name of the variable before adding it
like this:
GML:
if opjPlayer.endtextbox
{

}
 

chamaeleon

Member
It works when it's the same object, or multiple of the same object in the room, but as soon as I duplicate it, the duplicated object doesn't recognise ANY of the variables.
If you are doing nothing wrong, and all variables are accessed as they should, it seems to me there are a number of posts by people being bitten by unexplained behavior when they duplicate resources. As an experiment, instead of using duplicate, just create a new object and copy/paste the text content of each event that you would have duplicated and see if this works. If so, you have run into a bug in GMS that would warrant reporting with as much detail as possible so YYG can replicate and fix it.
 
If you are doing nothing wrong, and all variables are accessed as they should, it seems to me there are a number of posts by people being bitten by unexplained behavior when they duplicate resources. As an experiment, instead of using duplicate, just create a new object and copy/paste the text content of each event that you would have duplicated and see if this works. If so, you have run into a bug in GMS that would warrant reporting with as much detail as possible so YYG can replicate and fix it.
Transferring the code over to a new object instead of duplicating it worked, that's so weird..
How would I go about reporting the bug?
Edit: Duplicating the new object worked... Lmao im so confused, thank you for your help :)
 

chamaeleon

Member
How would I go about reporting the bug?
Click Report a Bug in the Help menu in GMS. In order for you to get the proper choices on the page that opens, you'll need to sign into your Yoyogames account (same you use for GMS) on the website.

As to why it works to duplicate the new object, who can say? Such is the nature of obscure bugs.
 
Top