Quick question about type varibble

Ok, in my tile objects, I have a type variable .

Code:
type = "woods"

//etc.
However when I try to reference a tile's type via

Code:
if(obj_tile.type = "woods")
The word "type" turns red and throws a error when I run the game that type is a unknown object, doing some research on the topic, it looks like type is now a built in variable for sequences. This kinda stinks, as old gms1 tutorials used the type variable a lot in them. So I guess I want to know if there is a simple workaround or if I just need to rename my type vars to tiletype.

And yes i know about search and replace but i just want to know if there is a way around built in varibles.
Thanks!
 

FrostyCat

Redemption Seeker
As of GMS 2.3.4, I don't see anything in the Manual or AutoComplete that suggests type is a built-in keyword. If it turns red in your project, chances are you have a resource, macro, or enum in your project already using that name. You would need to use another name.

Also, if you are getting your code from pre-2.3 tutorials and there are errors coming from "unknown" objects, see this:
Also, given that you are trying to reference obj_tile.type, you also need to read this article:
NEVER access a single instance by object ID if multiple instances of the object exist. This includes attempts to reference or set object.variable (which is inconsistent across exports) and using with (object) to apply actions to it (this encompasses all instances of the object instead of just the one you want). Verbally, "Dog's colour" makes sense with one dog, but not with multiple dogs.

Corollary: NEVER set or use an instance's own variables with object.variable. An instance's own variables can be referenced as-is without dot prefixes. DO NOT use self. If multiple instances of the object exists, you might end up setting the value for all instances or for some other instance (depending on the export).
 
Top