Use on object, Attribute of object to determine result.
Talon
13 Dec 2017, 17:24I'm trying to make a cage that can be used to capture any NPC with the species dragon, using this code on the selfuseanything attribute, It seems like it should be very simple
The intended effect is using the dragon cage on a dragon would capture it(testing stage just trying to make sure it recognizes and fires when its used on a dragon)
if (object.species = Dragon) {
msg ("You throw the cage at "+ object.alias ", it impacts on his snout, he looks at it in confusion.. then stares at you, takes a deep breath....just as the cage grows to enormous size, wrapping around the dragon and ensnaring it tightly..The cage levitates nearby and follows you...neat...the dragon is not happy though.")
}
else {
msg ("That is not a dragon")
}
and it comes back with
Error running script: Error compiling expression 'object.species = Dragon': Unknown object or variable 'Dragon
Just getting back into working with quest so maybe i've forgotten a few things

K.V.
13 Dec 2017, 17:38Hello.
Try if (object.species = "Dragon") {
.
jmnevil54
13 Dec 2017, 18:05This is it.
if (object.species = Dragon) {
msg ("")
}
The problem is most likely a typo in the attribute things...
Talon
13 Dec 2017, 20:26Yep, I feel foolish now, been so long I forgot that the " " around the string name since that's how the attribute works, thank you for your help KV
hegemonkhan
13 Dec 2017, 20:51you can also use 'Object Types' (and you can nest layers of them), which let's you add other Attributes, which will be shared/given-to all your dragons:
(you can still use a String Attribute instead of the 'DoesInherit', while still using Object Types, as well)
// scripting:
if (DoesInherit (OBJECT, "dragon_type")) {
// cage dragon scripting
} else {
msg ("The magical cage can only capture dragons")
}
or (while still using Object Types):
(not a good design using 'ORs', but it's just an example)
if (GetString (OBJECT, "species_string_attribute") = "dragon" or GetString (OBJECT, "species_string_attribute") = "dark dragon" or GetString (OBJECT, "species_string_attribute") = "fire dragon") {
// cage dragon scripting
} else {
msg ("The magical cage can only capture dragons")
}
------------
<object name="gleok">
<inherit name="dragon_type" />
</object>
<object name="bahamut">
<inherit name="dragon_type" />
</object>
<object name="salamander">
<inherit name="fire_dragon_type" />
</object>
<object name="tiamat">
<inherit name="dark_dragon_type" />
</object>
<type name="dark_dragon_type">
<inherit name="dragon_type" />
// whatever Attributes you want, which will be shared to all Objects given this 'dark_dragon_type' Inherited Attribute
<!--
this (the below) will over-write/over-ride/replace the 'dragon' species string attribute of the 'dragon_type' Inherited Attribute, with the species string attribute's value being 'dark dragon'
-->
<attr name="species_string_attribute" type="string">dark dragon</attr>
</type>
<type name="fire_dragon_type">
<inherit name="dragon_type" />
// whatever Attributes you want, which will be shared to all Objects given this 'fire_dragon_type' Inherited Attribute
<!--
this (the below) will over-write/over-ride/replace the 'dragon' species string attribute of the 'dragon_type' Inherited Attribute, with the species string attribute's value being 'fire dragon'
-->
<attr name="species_string_attribute" type="string">fire dragon</attr>
</type>
<type name="dragon_type">
// whatever Attributes you want, which will be shared to all Objects given this 'dragon_type' Inherited Attribute
<attr name="species_string_attribute" type="string">dragon</attr>
</type>
I don't think there's any way to create Object Types through scripting, you got to create them in the GUI/Editor or directly in code, yourself.
but, you can create objects having Object Types via scripting:
create (salamander, "fire_dragon_type")
create (tiamat, "dark_dragon_type")
create (bahamut, "dragon_type")
create (gleok, "dragon_type")