Can't delete sequences

Kami

Member
I have two sequences that I create when I press the right button of the mouse in an object, right after that, I create an object, and I tried to make that when I click in it, I delete the sequences, but for some reason they just don't delete.

Code below in my step event:

GML:
if(place_meeting(x,y,oPaperIn)) && (mouse_clickR) && (detailIn = false)
{
    var _paperIn = layer_sequence_create("detail",room_width/2,360,ssPaperIn);
    var _overlayIn = layer_sequence_create("overlay",room_width/2,360,ssOverlayIn);
    instance_create_layer(1230,50,"overlay",oClose);
    detailIn = true;
    
    if(place_meeting(x,y,oClose))
    {
        layer_sequence_destroy(_paperIn);   
        layer_sequence_destroy(_overlayIn);   
    }
    
    
}
This detailIn variable is to make sure that when I click to create the sequence, I can't create it again
 

Nidoking

Member
So, what you're doing is creating two sequences and then either immediately destroying them (so that they effectively never existed) or throwing away the handles (because they're vars) and never calling destroy. Once you set detailIn to true, this part will never happen again. I'm pretty sure that's not what you wanted to happen, but it's what you wrote.
 

Kami

Member
So, what you're doing is creating two sequences and then either immediately destroying them (so that they effectively never existed) or throwing away the handles (because they're vars) and never calling destroy. Once you set detailIn to true, this part will never happen again. I'm pretty sure that's not what you wanted to happen, but it's what you wrote.
I tried this:

step event:

GML:
if(place_meeting(x,y,oPaperIn)) && (mouse_clickR) && (detailIn = false)
{
    var _paperIn = layer_sequence_create("detail",room_width/2,360,ssPaperIn);
    var _overlayIn = layer_sequence_create("overlay",room_width/2,360,ssOverlayIn);
    instance_create_layer(1230,50,"overlay",oClose);
  
    if(layer_sequence_exists(layer,ssPaperIn)) exists = true;
  
  
}
Draw event:

Code:
draw_self();
draw_text(0,0,exists);
As you say, the number that I drew was always 0, that means that the sequence never existed, but it's weird, since the sequence happens in the same way.

Code:
if(sequence_exists(ssPaperIn)) exists = true;
I tried this too, and the number went to 1, which means that the sequence was created, but I never used sequence_create() in anywhere, and when I tried to destroy it using sequence_destroy(), I couldn't.
 

Kami

Member
If the layer variable is the same layer as "detail", then why are you using a string to specify the layer? If it doesn't, then why would the sequence you created on "detail" be on layer?
I wrote layer for no specific reason, because layer means all layers, I guess. I tried with "detail" now and still nothing.
 

Kami

Member
I think you may need to pass _paperIn to layer_sequence_exists rather than ssPaperIn.
It returned true, but every time I try to write an If with some conditions to destroy (even when I dont user layer_sequence_destroy), the number not returns true in any moment, I tried to create another variable who confirms if my If is true, but that didn't returns true either

GML:
    if(place_meeting(x,y,oClose))
    {
        if(layer_sequence_exists("detail",_paperIn))
        {
            exists = true;
        }
       colliding = true;

    }
I drew this colliding variable, and it returns false, which mean that even the If is false, and so the layer_sequence_exists will be false too. After I tried to confirm if when I press space it will return true, but it appears that every if returns false
 

Nidoking

Member
So, you're saying that place_meeting(x,y,oClose) is false? Well, is the instance running that check an instance with a bounding box that overlaps the bounding box of an instance of oClose?
 

Kami

Member
So, you're saying that place_meeting(x,y,oClose) is false? Well, is the instance running that check an instance with a bounding box that overlaps the bounding box of an instance of oClose?
I ended up finding out what is wrong. This step event is in object that follows my cursor (in that case, a mouse for the game), I tried to collide with oClose with another object that is a platform player system, and it returns true, so for some reason my mouse is wrong.

GML:
    if(place_meeting(x,y,oClose))
    {
        var _paperIn = layer_sequence_create(layer,room_width/2,360,ssPaperIn);
        if(layer_sequence_exists(layer, _paperIn))
        {
            exists = true;
        }
      
        colliding = true;
    }
I tried this in my player object and both variables returned true, so the code is actually working, but I'm doing something wrong with my mouse object, but I don't see where.

Actually, I tried to put the layer_sequence_create line in create event and change the var _paperIn to just a variable, and after write the command to delete the sequence outside the if(place_meeting(x,y,oPaperIn)) && (mouse_clickR) and it worked, I just don't know what's wrong. it'll work if I write all outside the if, but that way my code won't work, maybe if I write to create the sequence inside the oPaperIn object.
 
Last edited:

Yal

šŸ§ *penguin noises*
GMC Elder
In my experiences, object instances in a sequence exist in their own pocket dimension and won't be included in loops (e.g. with), so unless you only want their own events + collision events to act upon them, you need a workaround where they create a new instance of the same object and destroy themselves. (This makes the new object unable to follow the sequence, of course)
 

Kami

Member
In my experiences, object instances in a sequence exist in their own pocket dimension and won't be included in loops (e.g. with), so unless you only want their own events + collision events to act upon them, you need a workaround where they create a new instance of the same object and destroy themselves. (This makes the new object unable to follow the sequence, of course)
I found a way to solve that when I click to create the sequences, it actually creates an object that has the commands to create the sequences in its create event, it does not change anything in creating sequences at all, but this way I can destroy them without problem.

Anyway, thank you so much for trying to help :)
 
Top