Jump to content


Photo

Assign every object type a number


  • Please log in to reply
2 replies to this topic

#1 zeldarules28

zeldarules28

    GMC Member

  • New Member
  • 214 posts

Posted 10 September 2011 - 09:52 PM

I'm working on a code that will allow me to save and load custom-built levels. Basically, it's just running through each 50x50 grid square and checking to see what type of object is there. Then it returns a certain number based on what the object type is..

objectid = collision_rectangle(xpos,ypos,xpos+45,ypos+45,all,true,true) // Get & save D # of the object

// Determine what type of object it is
switch(object_get_name(objectid)) // I need something to put HERE that will return the object name of an instance
{

case 'block1': {
show_message('block1') 
newtype = 1;
break
}


default: {
//show_message('Could not return TYPE')
newtype = -1;
break
}

}




I must be missing something. How do I get the object name from a specific instance ID. I'm sure it's a simple function but I can't seem to find it.
  • 0

#2 @Alex@

@Alex@

    Retired GMC Reviewer

  • Reviewer
  • 3075 posts
  • Version:Unknown

Posted 10 September 2011 - 09:55 PM

collision_* functions return instance ids , you can use these like object names id.object_index returns the type of object that id is you can then use object_get_name to get its name.
  • 1

#3 zeldarules28

zeldarules28

    GMC Member

  • New Member
  • 214 posts

Posted 10 September 2011 - 09:59 PM

Aha! I knew it was something simple like that. Thanks a bunch!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users