Legacy GM [SOLVED]Creation code?!?

Tonydaderp

Member
Guys, I'm currently programming a "slide_wall" something which you see in A link to the past. The code works fine. I am trying to have less objects by making the slide_wall object have states. If the player collides with it and it's state is "topright", something happens.
eg: if (slide_wall.qaud == "topright"){
blah blah blah..
}



If its state is "topleft", it will do something different. I am trying to handle this by setting a creation code in the room for object "slide_wall", but it doesn't work. Am I supposed to use enums for .'s? Plz respond if you know what to do. Thx!
 

obscene

Member
Well enums could help.

The problem is "topright" means nothing. It has no value. 0? 1? What is it? How can quad equal it?

So you can make contants (macros on the resource tree) to give topright a value, or you can create enumators.
 

TheouAegis

Member
If slide_wall is the name of the object, that's your problem. You should never, ever reference variables with the ID of the object the variable is in like that.
 

TheouAegis

Member
Well, it might not be your only problem, but it'd be one problem. If slide_wall is the name of the object, then saying slide_wall.quad doesn't tell GM which slide_wall you want to look up, so it's getting the value of quad from a different slide_wall than the one you are colliding with. You need to use the id of the instance of slide_wall that you're colliding with.
 

Tonydaderp

Member
Well, it might not be your only problem, but it'd be one problem. If slide_wall is the name of the object, then saying slide_wall.quad doesn't tell GM which slide_wall you want to look up, so it's getting the value of quad from a different slide_wall than the one you are colliding with. You need to use the id of the instance of slide_wall that you're colliding with.
The ID? Okay, ill try!

So I say:
Code:
//right collision{move up}
if (inst_C17BB11F.qaud == "topright"){
if (place_meeting(x+1,y,slidewall1)) && (keyboard_check(vk_right))  && (!keyboard_check(vk_up))   && (dir == "right")    {

    
      
        if (place_free(x, y-2,)) {
            y -= 2;
        }
    }
    }
 
Last edited:

TheouAegis

Member
No, you need to find the ID of the instance using one of the functions that returns the ID, such as instance_place() or collision_rectangle().
 

Tonydaderp

Member
Like this?:
Code:
//collision event with slidewall
instance_place(x,y,slidewall1)
slidewall1.id = "IDOFWALL";
then:
Code:
//right collision{move up}
if ("IDOFWALL".qaud == "topright"){
if (place_meeting(x+1,y,slidewall1)) && (keyboard_check(vk_right))  && (!keyboard_check(vk_up))   && (dir == "right")    {

    
      
        if (place_free(x, y-2,)) {
            y -= 2;
        }
    }
  }
 
Top