GML Text Object Malfunctioning

R

Red Phantom

Guest
Down Press Event for created object obj_gravestone
Code:
if instance_exists(obj_Exit_Game) then exit

inst_grave = instance_place(x, y, obj_Meskhenet)
if inst_grave != noone
    {
    if global.inconversation = false
        {
        global.inconversation = true
        child = instance_create(0,0,obj_Grave_Text)
        if inst_grave.image_index = 0 then child.identification = 1
        if inst_grave.image_index = 3 and inst_grave.x = 120 then child.identification = 2
        if inst_grave.image_index = 3 and inst_grave.x = 296 then child.identification = 3
        if inst_grave.image_index = 4 then child.identification = 4
        if inst_grave.image_index = 1 then child.identification = 5
        if inst_grave.image_index = 2 then child.identification = 6
        }
    }
Draw Event for subsidiary object obj_grave_text
Code:
///Execute Script: scr_Draw_Grave_Text
if identification = 1 then script_execute(scr_Draw_Grave_Text,"GAMAL#103 AA, MARIS - 141 AA, DISAMBIR")
if identification = 2 then script_execute(scr_Draw_Grave_Text,"FUKAYNA#87 AA, DISAMBIR - 112 AA, SIBTAMBAR")
if identification = 3 then script_execute(scr_Draw_Grave_Text,"FADIL#61 AA, SHAHR NUFIMBIR#- 87 AA, 'AGHUSTUS")
if identification = 4 then script_execute(scr_Draw_Grave_Text,"FARID#65 AA, SIBTAMBAR -#101 AA, SHAHR FIBRAYIR")
if identification = 5 then script_execute(scr_Draw_Grave_Text,"NOUR#120 AA, SHAHR 'UKTUBAR#- 152 AA, QAD")
if identification = 6 then script_execute(scr_Draw_Grave_Text,"LAPIS#123 AA, YULIU -  152 AA, QAD")
Originally I had the numbers replaced with strings:
#1 ---- > grave_1_text
#2 -----> cross_grave_1_text
#3 -----> croos_grave_2_text.... and so on...

Neither seem to work, both causing different errors.

Originally I had separate text objects for each different string of text but I am determined to have solely one text object.

After I fix this I would like to further merge the obj_gravestone and obj_grave_text to one ultimate object
 

Rob

Member
instance_place returns real and what you want is an id, so you can access the info from the actual gravestone that's being collided with. You can check what a function returns by reading the manual page on it. Yes the id is a number but I doubt instance_place will return the right id and it doesn't return noone either.

In the gravestone instance creation code, but the text in there too (save the text in a variable called text), remove it from the grave's draw event.

Take out the down_press event from the graves and put it into Meshkhenet, then do something like this:

Code:
inst_grave = collision_point(x, y, obj_Graves)
if inst_grave != noone
    {
    if global.inconversation = false
        {
        global.inconversation = true
        child = instance_create(0,0,obj_Grave_Text)
        child.text = inst_grave.text
        }
    }
}

//If you really want to keep the code inside the grave objects then do this in the downpress event for the graves, pick one method or the other

if (collision_point(x, y, obj_Meshkhenet) != noone){
    if global.inconversation == false{
        global.inconversation = true
        child = instance_create(0,0,obj_Grave_Text)
        child.text = text
    }
}
Then inside the obj_Grave_Text draw_gui or draw event you can just tell it to

Code:
xx = //whatever coords you have for the text x
yy = //whatever coords you have for the text y

draw_text(xx, yy, text);
 
Top