an issue creating a type with an object variable

<type name="path">
  <inherit name="editor_object" />
  <displayverbs type="stringlist">
		<value>Move to</value>
  </displayverbs>
  <is_visible type="boolean">true</is_visible>
  <show_connected_location type="boolean"></show_connected_location>
  <access_requirement type="string"></access_requirement>
  <action_description type="string"></action_description>
  <cardinal_direction type="string"></cardinal_direction>
  <display_when_out_of_combat type="string"></display_when_out_of_combat>
  <display_during_close_combat type="string"></display_during_close_combat>
  <connected_location type="object"></connected_location>
  </type>

when I try and run the program I get this error message:
Failed to load game due to the following errors:
* Error: Error adding attribute 'connected_locations' to element 'path': Element not found: "

Is this because I didn't initialize it? If so what is the proper way to initialize it? I have tried null but that doesn't seem to work.


If you want to create the attribute, you need to put an object in it. Attributes which don't exist are treated as having the value null, so you can't have an object attribute which doesn't reference an object. If you want it to start as null, don't include it.


Attributes which don't exist are treated as having the value null, so you can't have an object attribute which doesn't reference an object

Is this unique to attributes with type object? Are there any other attributes that don't initialize with null?

if you want it to start as null, don't include it.

I am in the process of making a user interface that helps a developer (mainly me) set up these unique types and their variables in Quest's user interface. Should I make a dummy object as a placeholder for these variables? Or is there another way to create the variable using tab-controls?


Is this unique to attributes with type object? Are there any other attributes that don't initialize with null?

An attribute that doesn't exist is the same as an attribute containing the object null. (In fact, doing object.attribute = null in your code will delete the attribute).

That's why if you do something like if (someobject.someattribute = "pink") { when that attribute hasn't been created yet, it complains that the operator = can't compare an object to a string. Until you give it a value of another type, an attribute is null, which counts as an object.

The normal way to deal with object attributes is not to give them a default value unless there is a sensible default for them to have. (The types in CoreTypes.aslx do not contain any object attributes; because the sensible default for an object attribute is null, which is achieved by omitting it from the type).


I have decided to simply use the object's name and store it in a string and when I need it simply use GetObject() to create a pointer to the object. I really appreciate you taking your time to explain this to me.


Log in to post a reply.

Support

Forums