Creating Types Tab

I still do not deal with types. I try to use the "using types" and "using inherited types". It uses spells for an example and loses me. So tab creation is a no go.

Tried to add using Object types in the advanced but kept giving error of reference object does not exist. so before I pushed everything off my desk, I thought I'd ask.

You know I've searched the forums but I could not find the proper hand to hold in this process.

I'm trying to create a tab that will hold "room" types. Be it inside, outside, forest, mountain, cavern, tavern. It will decide the descriptions given for generic and specific descriptions.

Adding a floor to the items list does not describe every floor or it may even be the ground. If a player looks at floor outside I'd prefer the description to reflect that it is ground. An outside room does not have a roof.

Anyway, I would like someone who has absolutely nothing better to do than walk me through the setting up of a type. That type being "area" and will cover all the different types I mentioned.

Then continue the lesson with those types being added to a tab.
So I don't have to add a lot of stuff to each room I make. Click, click, mo'frick

If this causes you to cringe, swipe me to the left...
If your reaction is more like, I got your back Jack, then let's rock and roll.
If you are thinking something else then you should see a doctor.


(filler for getting my edited post, updated/posted)


An 'Object Type / Type' ( http://docs.textadventures.co.uk/quest/elements/type.html ) is like a group/class/family/"basket", which can hold (multiple) Attributes and/or other Object Types / Types. Instead of adding each Attribute to every Object that you need/want to do, you can instead, add Attributes to an Object Type / Type (think of it like a basket of multiple eggs/Attributes), and then only add the Object Type / Type, to those Objects you want/need (adding the entire "basket of eggs" instead of adding each of those "eggs/Attributes" individually to those Objects)

simple example

VERY YUCKY:

<object name="goblin1">

  <attr name="strength" type="int">25</attr>
  <attr name="endurance" type="int">25</attr>
  <attr name="dexterity" type="int">25</attr>
  <attr name="agility" type="int">25</attr>
  <attr name="speed" type="int">25</attr>
  <attr name="piety" type="int">25</attr>
  <attr name="intelligence" type="int">25</attr>
  <attr name="sprituality" type="int">25</attr>
  <attr name="mentality" type="int">25</attr>
  <attr name="creativity" type="int">25</attr>
  <attr name="personality" type="int">25</attr>
  <attr name="leadership" type="int">25</attr>
  <attr name="charisma" type="int">25</attr>
  <attr name="alignment" type="int">25</attr>
  <attr name="luck" type="int">25</attr>

</object>

<object name="goblin2">

  <attr name="strength" type="int">25</attr>
  <attr name="endurance" type="int">25</attr>
  <attr name="dexterity" type="int">25</attr>
  <attr name="agility" type="int">25</attr>
  <attr name="speed" type="int">25</attr>
  <attr name="piety" type="int">25</attr>
  <attr name="intelligence" type="int">25</attr>
  <attr name="sprituality" type="int">25</attr>
  <attr name="mentality" type="int">25</attr>
  <attr name="creativity" type="int">25</attr>
  <attr name="personality" type="int">25</attr>
  <attr name="leadership" type="int">25</attr>
  <attr name="charisma" type="int">25</attr>
  <attr name="alignment" type="int">25</attr>
  <attr name="luck" type="int">25</attr>

</object>

<object name="goblin3">

  <attr name="strength" type="int">25</attr>
  <attr name="endurance" type="int">25</attr>
  <attr name="dexterity" type="int">25</attr>
  <attr name="agility" type="int">25</attr>
  <attr name="speed" type="int">25</attr>
  <attr name="piety" type="int">25</attr>
  <attr name="intelligence" type="int">25</attr>
  <attr name="sprituality" type="int">25</attr>
  <attr name="mentality" type="int">25</attr>
  <attr name="creativity" type="int">25</attr>
  <attr name="personality" type="int">25</attr>
  <attr name="leadership" type="int">25</attr>
  <attr name="charisma" type="int">25</attr>
  <attr name="alignment" type="int">25</attr>
  <attr name="luck" type="int">25</attr>

</object>

<object name="orc1">

  <attr name="strength" type="int">50</attr>
  <attr name="endurance" type="int">50</attr>
  <attr name="dexterity" type="int">50</attr>
  <attr name="agility" type="int">50</attr>
  <attr name="speed" type="int">50</attr>
  <attr name="piety" type="int">50</attr>
  <attr name="intelligence" type="int">50</attr>
  <attr name="sprituality" type="int">50</attr>
  <attr name="mentality" type="int">50</attr>
  <attr name="creativity" type="int">50</attr>
  <attr name="personality" type="int">50</attr>
  <attr name="leadership" type="int">50</attr>
  <attr name="charisma" type="int">50</attr>
  <attr name="alignment" type="int">50</attr>
  <attr name="luck" type="int">50</attr>

</object>

<object name="orc2">

  <attr name="strength" type="int">50</attr>
  <attr name="endurance" type="int">50</attr>
  <attr name="dexterity" type="int">50</attr>
  <attr name="agility" type="int">50</attr>
  <attr name="speed" type="int">50</attr>
  <attr name="piety" type="int">50</attr>
  <attr name="intelligence" type="int">50</attr>
  <attr name="sprituality" type="int">50</attr>
  <attr name="mentality" type="int">50</attr>
  <attr name="creativity" type="int">50</attr>
  <attr name="personality" type="int">50</attr>
  <attr name="leadership" type="int">50</attr>
  <attr name="charisma" type="int">50</attr>
  <attr name="alignment" type="int">50</attr>
  <attr name="luck" type="int">50</attr>

</object>

<object name="orc3">

  <attr name="strength" type="int">50</attr>
  <attr name="endurance" type="int">50</attr>
  <attr name="dexterity" type="int">50</attr>
  <attr name="agility" type="int">50</attr>
  <attr name="speed" type="int">50</attr>
  <attr name="piety" type="int">50</attr>
  <attr name="intelligence" type="int">50</attr>
  <attr name="sprituality" type="int">50</attr>
  <attr name="mentality" type="int">50</attr>
  <attr name="creativity" type="int">50</attr>
  <attr name="personality" type="int">50</attr>
  <attr name="leadership" type="int">50</attr>
  <attr name="charisma" type="int">50</attr>
  <attr name="alignment" type="int">50</attr>
  <attr name="luck" type="int">50</attr>

</object>

<object name="ogre1">

  <attr name="strength" type="int">75</attr>
  <attr name="endurance" type="int">75</attr>
  <attr name="dexterity" type="int">75</attr>
  <attr name="agility" type="int">75</attr>
  <attr name="speed" type="int">75</attr>
  <attr name="piety" type="int">75</attr>
  <attr name="intelligence" type="int">75</attr>
  <attr name="sprituality" type="int">75</attr>
  <attr name="mentality" type="int">75</attr>
  <attr name="creativity" type="int">75</attr>
  <attr name="personality" type="int">75</attr>
  <attr name="leadership" type="int">75</attr>
  <attr name="charisma" type="int">75</attr>
  <attr name="alignment" type="int">75</attr>
  <attr name="luck" type="int">75</attr>

</object>

<object name="ogre2">

  <attr name="strength" type="int">75</attr>
  <attr name="endurance" type="int">75</attr>
  <attr name="dexterity" type="int">75</attr>
  <attr name="agility" type="int">75</attr>
  <attr name="speed" type="int">75</attr>
  <attr name="piety" type="int">75</attr>
  <attr name="intelligence" type="int">75</attr>
  <attr name="sprituality" type="int">75</attr>
  <attr name="mentality" type="int">75</attr>
  <attr name="creativity" type="int">75</attr>
  <attr name="personality" type="int">75</attr>
  <attr name="leadership" type="int">75</attr>
  <attr name="charisma" type="int">75</attr>
  <attr name="alignment" type="int">75</attr>
  <attr name="luck" type="int">75</attr>

</object>

<object name="ogre3">

  <attr name="strength" type="int">75</attr>
  <attr name="endurance" type="int">75</attr>
  <attr name="dexterity" type="int">75</attr>
  <attr name="agility" type="int">75</attr>
  <attr name="speed" type="int">75</attr>
  <attr name="piety" type="int">75</attr>
  <attr name="intelligence" type="int">75</attr>
  <attr name="sprituality" type="int">75</attr>
  <attr name="mentality" type="int">75</attr>
  <attr name="creativity" type="int">75</attr>
  <attr name="personality" type="int">75</attr>
  <attr name="leadership" type="int">75</attr>
  <attr name="charisma" type="int">75</attr>
  <attr name="alignment" type="int">75</attr>
  <attr name="luck" type="int">75</attr>

</object>

VS

MUCH BETTER:

<object name="goblin1">

  <inherit name="goblin_type" />

</object>

<object name="goblin2">

  <inherit name="goblin_type" />

</object>

<object name="goblin3">

  <inherit name="goblin_type" />

</object>

<object name="orc1">

  <inherit name="orc_type" />

</object>

<object name="orc2">

  <inherit name="orc_type" />

</object>

<object name="orc3">

  <inherit name="orc_type" />

</object>

<object name="ogre1">

  <inherit name="ogre_type" />

</object>

<object name="ogre2">

  <inherit name="ogre_type" />

</object>

<object name="ogre3">

  <inherit name="ogre_type" />

</object>

<type name="goblin_type">

  <attr name="strength" type="int">25</attr>
  <attr name="endurance" type="int">25</attr>
  <attr name="dexterity" type="int">25</attr>
  <attr name="agility" type="int">25</attr>
  <attr name="speed" type="int">25</attr>
  <attr name="piety" type="int">25</attr>
  <attr name="intelligence" type="int">25</attr>
  <attr name="sprituality" type="int">25</attr>
  <attr name="mentality" type="int">25</attr>
  <attr name="creativity" type="int">25</attr>
  <attr name="personality" type="int">25</attr>
  <attr name="leadership" type="int">25</attr>
  <attr name="charisma" type="int">25</attr>
  <attr name="alignment" type="int">25</attr>
  <attr name="luck" type="int">25</attr>

</type>

<type name="orc_type">

  <attr name="strength" type="int">50</attr>
  <attr name="endurance" type="int">50</attr>
  <attr name="dexterity" type="int">50</attr>
  <attr name="agility" type="int">50</attr>
  <attr name="speed" type="int">50</attr>
  <attr name="piety" type="int">50</attr>
  <attr name="intelligence" type="int">50</attr>
  <attr name="sprituality" type="int">50</attr>
  <attr name="mentality" type="int">50</attr>
  <attr name="creativity" type="int">50</attr>
  <attr name="personality" type="int">50</attr>
  <attr name="leadership" type="int">50</attr>
  <attr name="charisma" type="int">50</attr>
  <attr name="alignment" type="int">50</attr>
  <attr name="luck" type="int">50</attr>

</type>

<type name="ogre_type">

  <attr name="strength" type="int">75</attr>
  <attr name="endurance" type="int">75</attr>
  <attr name="dexterity" type="int">75</attr>
  <attr name="agility" type="int">75</attr>
  <attr name="speed" type="int">75</attr>
  <attr name="piety" type="int">75</attr>
  <attr name="intelligence" type="int">75</attr>
  <attr name="sprituality" type="int">75</attr>
  <attr name="mentality" type="int">75</attr>
  <attr name="creativity" type="int">75</attr>
  <attr name="personality" type="int">75</attr>
  <attr name="leadership" type="int">75</attr>
  <attr name="charisma" type="int">75</attr>
  <attr name="alignment" type="int">75</attr>
  <attr name="luck" type="int">75</attr>

</type>

you can add any type of Attribute (I just showed primary game stat Integer Attributes in my simple example): Integers, Doubles, Strings, Booleans, Object Pointers/References, Lists, Dictionaries, and Scripts


you can also have other Object Types (as/via Inherited Attributes) as well (deep nesting):

(extremely simply quick examples, there's a ton of stuff that can be done, not showing all of it, lol)

<object name="item">

  <inherit name="item_type" />

</object>

<object name="equipment">

  <inherit name="equipment_type" />

</object>

<object name="potion">

  <inherit name="healing_item_type" />

</object>

<object name="sword">

  <inherit name="weapon_type" />

</object>

<object name="plate_armor">

  <inherit name="armor_type" />

</object>

<type name="item_type">

  <attr name="quantity" type="int">0</attr>

  <attr name="use" type="script">
  </attr>

  <attr name="take" type="boolean">true</attr>

  <attr name="drop" type="boolean">true</attr>

</type>

<type name="healing_item_type">

  <inherit name="item_type" />

  <attr name="modifier" type="int">2</attr>

</type>

<type name="equipment_type">

  <inherit name="item_type" />

  <attr name="durability" type="int">100</attr>

  <attr name="equip" type="script">
  </attr>

  <attr name="unequip" type="script">
  </attr>

</type>

<type name="weapon_type">

  <inherit name="equipment_type" />

  <attr name="damage" type="int">0</attr>

</type>

<type name="armor_type">

  <inherit name="equipment_type" />

  <attr name="armor_class" type="int">0</attr>

</type>

the 'item' Object has these Attributes: quantity, use, take, drop

the 'equipment' Object has these Attributes: quantity, use, take, drop, durability, equip, unequip

the 'potion' Object has these Attributes: quantity, use, take, drop, modifier

the 'sword' Object has these Attributes: quantity, use, take, drop, durability, equip, unequip, damage

the 'plate_armor' Object has these Attributes: quantity, use, take, drop, durability, equip, unequip, armor_class


also, you can check if an Object has a specific Inherited Attribute via the 'DoesInherit (X)' Script/Function: http://docs.textadventures.co.uk/quest/functions/doesinherit.html

objectlist_variable = NewObjectList ()
list add (objectlist_variable, item)
list add (objectlist_variable, equipment)
list add (objectlist_variable, potion)
list add (objectlist_variable, sword)
list add (objectlist_variable, plate_armor)

object_variable = ObjectListItem (objectlist_variable, GetRandomInt (0, ListCount (objectlist_variable) - 1))

--------

if (DoesInherit (object_variable, "item_type")) {
  msg ("Yes, " + object_variable.name + ", is an 'item' Object")

  if (DoesInherit (object_variable, "equipment_type")) {
    msg ("Yes, " + object_variable.name + ", is an 'equipment' Object")

    if (DoesInherit (object_variable, "weapon_type")) {
      msg ("Yes, " + object_variable.name + ", is an 'weapon' Object")
    } else if (DoesInherit (object_variable, "armor_type")) {
      msg ("Yes, " + object_variable.name + ", is an 'armor' Object")
    }

  } else {

    if (DoesInherit (object_variable, "healing_item_type")) {
      msg ("Yes, " + object_variable.name + ", is a 'healing' Object")
    }

  }

}

I've not worked with creating the GUI/Editor Tabs/Controls in quite a long time, so I'll let others help with that stuff (I was able to learn how to do them through the tutorial section on them, but this was a long time ago, and I forgotten, as I never really worked with them)

here's the doc on Tabs/Controls: http://docs.textadventures.co.uk/quest/tabs_for_types.html (scroll down a bit past the library stuff)


LASTLY

VERY IMPORTANT about Attributes (Inherited Attributes) from Object Types / Types:

Pixie's doc explanation:

http://docs.textadventures.co.uk/quest/using_inherited_types.html

A Note About Lists and Dictionaries (from link above, at the bottom of the page):

It is worth noting that attributes on types are not mutable - they cannot be changed. You might never notice this, because if you have an object and you attempt to assign a value to an attribute that is set in the object’s type, it works fine - behind the scenes when you assign it, the attribute stops being on the type, and is now on the object, and as far as the game is concerned the attribute value has changed. The problem only arises if you try to change the content of a list or dictionary, so unless you are sure a list or dictionary will not change during a game, I would advise against having them in types.

so, this works fine:

<object name="orc">

  <attr name="kill" type="script">

    orc.life = orc.life - 25 // you're setting/creating/adding/initializing the 'life' Attribute, so it over-rides/over-writes the 'life' Inherited Attribute, making the 'life' Attribute just a normal (non-inherited) Attribute of the Object itself, so there's no error here

    orc.dead = true // you're setting/creating/adding/initializing the 'dead' Attribute, so it over-rides/over-writes the 'dead' Inherited Attribute, making the 'dead' Attribute just a normal (non-inherited) Attribute of the Object itself, so there's no error here

  </attr>

</object>

<type name="orc_type">

  <attr name="dead" type="boolean">false</attr>

  <attr name="life" type="int">100</attr>

</type>

as Pixie stated, the issue is with Lists/Dictionaries, as just doing the 'add/remove' of its items, doesn't add/create/initialize a list/dictionary upon the Object itself, and so the list/dictionary remains as an inherited attribute, and thus the error when you try to change its values (add/remove an item to the list/dictionary):

<object name="orc">

  <inherit name="orc_type" />

  <attr name="kill" type="script">

    // just doing these, would cause ERRORS:

    list remove (orc.displayverbs, "talk")
    list remove (orc.displayverbs, "attack")
    list add (orc.displayverbs, "loot")

  </attr>

</object>

<type name="orc_type">

  <displayverbs type="stringlist">

    <value>talk</value>
    <value>attack</value>

  </displayverbs"

</type>

I presume, if you do create/add/set/initial the list/dictionary, then it works fine:

<object name="orc">

  <inherit name="orc_type" />

  <attr name="kill" type="script">

    orc.displayverbs = NewStringList () // I presume, this would allow it to work, without ERRORS

    list add (orc.displayverbs, "talk") // ya, this isn't needed, but just showing/doing it so that it's the same as from the inherited attribute
    list add (orc.displayverbs, "attack") // ya, this isn't needed, but just showing/doing it so that it's the same as from the inherited attribute

    // now, these should (I hope) work fine, without errors:

    list remove (orc.displayverbs, "talk") // ya, this isn't needed, but showing/doing it, so you can see how to manipulate it as if you were doing so from the inherited attribute
    list remove (orc.displayverbs, "attack") // ya, this isn't needed, but showing/doing it, so you can see how to manipulate it as if you were doing so from the inherited attribute

    list add (orc.displayverbs, "loot") // we only need to do this for this specific example, as we're starting from a new blank list/dictionary, but I shown/did the other add/remove of items, so you can just see it, as if we were manipulating the inherited attribute

  </attr>

</object>

<type name="orc_type">

  <displayverbs type="stringlist">

    <value>talk</value>
    <value>attack</value>

  </displayverbs"

</type>

Admittedly, I have never used types so I don't really know all the pros and cons regarding them. But I just create an object (a master clone) with the specific attributes that I want, and then clone it in-game. That seems to me to be easier and more flexible than using types. If I'm making an object in the editor, I just copy and paste the master clone.


Good info, well explained for an old man to understand. Made several types today.


@ Forgewright:

I forgot to explain about precedence/over-riding/over-writing

<object name="orc1">

  <inherit name="orc_type" />

</object>

<object name="orc2">

  <inherit name="orc_type" />

  <attr name="strength" type="int">100</attr>

</object>

<type name="orc_type">

  <attr name="strength" type="int">25</attr>
  <attr name="endurance" type="int">50</attr>

</type>

the 'orc1' has '25' strength and '50' endurance
vs
the 'orc2' has '100' strength and '50' endurance

an Object's direct/own Attributes, over-rides/over-writes/take-precedence over its inherited Attributes


PS

I don't think (please correct me if this is incorrect) theres's a way to create an Object Type / Type through scripting, but you can through scripting create Objects with already (GUI/Editor) created Object Types / Types:

http://docs.textadventures.co.uk/quest/scripts/create.html

<asl version"550">

  <include ref="English.aslx" />
  <include ref="Core.aslx" />

  <game name="NAME_OF_GAME">

    <attr name="start" type="script">
      object_variable = create ("orc", "orc_type")
      object_variable.parent = room
    </attr>

  </game>

  <object name="room">
    <inherit name="editor_room" />
  </object>

  <object name="player">
    <inherit name="editor_object" />
    <inherit name="editor_player" />
    <attr name="parent" type="object">room</attr>
  </object>

  <type name="orc_type">
  </type>

</asl>

PSS

if you do work directly in-code (the asl/xml), be careful not to mix up the library reference 'include' key words-commands with the Object Type / Type / Inherited 'inherit' key words-commands, lol (HK was baffled on errors with his code, not realizing, he got the 'include' and 'inherit' usage messed up --- I think KV realized/found this for me, saved me even more hours of hair pulling, lol. Damn, simple stupid mistakes... lol. Why does both 'include' and 'inherit' have to start with 'in'... lol --- ya, HK is stupid and lazy, so I was mixing up the usage of 'include' with 'inherit' and vice versa... lol)

and also... make sure you type 'inherit' and not 'inherited'... HK makes lots of stupid mistakes...


Log in to post a reply.

Support

Forums