How do I make a type of object that holds variables and truth states?

Hi everybody I'm kinda new to Quest 5, and I'm trying to make a type of object that have variables and truth states. I'm doing this because so I can save time when copy and pasting things.

Unfortunately, the attributes and inherited sections did not helped me, it only made me even more confused.

(If you have no idea what I'm talking about let just say I'm trying to make a type system.)


Io

Attributes are basically the way Quest calls 'instance variables', for some reason. Make an object. Click its Attributes tab. Add an attribute and change its type to whatever you want; String, Integer, Boolean, etc.


Uhh thanks lo, but what I'm tying to say is that I want a type of object, the type that holds variables and truth states so that it can save me some time copying and pasting the variables to every object.


Hello.

If you are using the desktop version of Quest, you can create 'types'.

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


Also, I highly recommended going all the way through the tutorial before trying to create your first Quest game.

http://docs.textadventures.co.uk/quest/tutorial/creating_a_simple_game.html


on the left side's 'Tree of Stuff', under 'advanced' is the 'Object Types / Types', which you create/add a new 'Object Type / Type', name it, and add/create whatever Attributes you want to it. Think of the 'Object Type / Type' as your 'class/group', or like a 'basket' (the 'Object Type / Type') that holds a bunch of 'eggs' (your 'Attributes')

then, to add that 'Object Type / Type' (aka, your 'basket of eggs') to the Objects that you want:

'WHATEVER' Object -> 'Attributes' Tab -> 'Inherited' Attributes (I think it's the middle box) -> 'Add' -> (select/add the name of the 'Object Type / Type' that you had just created)

this way, the Object gets that 'Object Type / Type', and thus all of those 'eggs': the Attributes of/within/add-to that 'Object Type / Type', instead of individually adding every Attribute to that Object (and/or other/more Objects: you only have to add the 'Object Type / Type' via adding the 'Inherited' Attribute, the name of your 'Object Type / Type' to whatever other/more Objects that you want)

for example in code:


notice these codes line seen further below in my below/other code boxes:

<inherit name="editor_room" />
<inherit name="editor_player" />
<inherit name="editor_object" />

this is a built-in Object Type / Type, for the GUI/Editor to have its correct Tabs/Options/Controls/Settings for the type of object that you want it to be:

editor_room: <inherit name="editor_room" />
editor_player: <inherit name="editor_player" />
editor_object: <inherit name="editor_object" />

which, disappear (are destroyed) once your game begins (so you can't use these as references, you got to create your own String or Inherit Attributes for that: like if you want to check if the Object is a 'room' vs a 'player' vs a 'non-room and non-player' Object)

not using Object Types / Types / Inherited Attributes (YUCK!):

<object name="room">

  <inherit name="editor_room" />

  <attr name="type_of_object" type="string">room</attr>

</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">player</attr>

</object>

<object name="orc_1">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">orc</attr>

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

<object>

<object name="orc_2">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">orc</attr>

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

<object>

<object name="orc_3">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">orc</attr>

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

<object>

<object name="dragon_1">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">dragon</attr>

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

<object>

<object name="dragon_2">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">dragon</attr>

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

<object>

<object name="dragon_3">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="type_of_object" type="string">dragon</attr>

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

<object>

vs

using 'Object Types / Types' (much better):

<object name="room">

  <inherit name="editor_room" />

  <inherit name="room_type" />

</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <inherit name="player_type" />

  <attr name="parent" type="object">room</attr>

</object>

<object name="orc_1">

  <inherit name="editor_object" />

  <inherit name="orc_type" />

  <attr name="parent" type="object">room</attr>

<object>

<object name="orc_2">

  <inherit name="editor_object" />

  <inherit name="orc_type" />

  <attr name="parent" type="object">room</attr>

<object>

<object name="orc_3">

  <inherit name="editor_object" />

  <inherit name="orc_type" />

  <attr name="parent" type="object">room</attr>

<object>

<object name="dragon_1">

  <inherit name="editor_object" />

  <inherit name="dragon_type" />

  <attr name="parent" type="object">room</attr>

<object>

<object name="dragon_2">

  <inherit name="editor_object" />

  <inherit name="dragon_type" />

  <attr name="parent" type="object">room</attr>

<object>

<object name="dragon_3">

  <inherit name="editor_object" />

  <inherit name="dragon_type" />

  <attr name="parent" type="object">room</attr>

<object>

<type name="room_type">

  <attr name="type_of_object" type="string">room</attr>

</type>

<type name="player_type">

  <attr name="type_of_object" type="string">player</attr>

</type>

<type name="orc_type">

  <attr name="type_of_object" type="string">orc</attr>

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

</type>

<type name="dragon_type">

  <attr name="type_of_object" type="string">dragon</attr>

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

</type>

vs

can be even more better than (and/or along with also) using Object Types (in my example, you notice that all of the stats/Attributes are the same for the 'orc' Objects and also for the 'dragon' Objects, so why have all those Attributes for all of the Objects, when you can have a single Object, 'dragon_type_object' and 'orc_type_object' and 'player_type_object' and 'room_type_object', hold those Attributes instead, and just reference that when you need to do so? see below for what I mean)

<object name="room">

  <inherit name="editor_room" />

  <attr name="pointer_attribute" type="object">room_type_object</attr>

</object>

<object name="player">

  <inherit name="editor_object" />
  <inherit name="editor_player" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">player_type_object</attr>

</object>

<object name="orc_1">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">orc_type_object</attr>

<object>

<object name="orc_2">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">orc_type_object</attr>

<object>

<object name="orc_3">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">orc_type_object</attr>

<object>

<object name="dragon_1">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">dragon_type_object</attr>

<object>

<object name="dragon_2">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">dragon_type_object</attr>

<object>

<object name="dragon_3">

  <inherit name="editor_object" />

  <attr name="parent" type="object">room</attr>

  <attr name="pointer_attribute" type="object">dragon_type_object</attr>

<object>

<object name="room_type_object">

  <inherit name="editor_object" />

  <attr name="type_of_object" type="string">room</attr>

</object>

<object name="player_type_object">

  <inherit name="editor_object" />

  <attr name="type_of_object" type="string">player</attr>

</object>

<object name="orc_type_object">

  <inherit name="editor_object" />

  <attr name="type_of_object" type="string">orc</attr>

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

</object>

<object name="dragon_type_object">

  <attr name="type_of_object" type="string">dragon</attr>

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

</object>

Lastly, there is a big issue/problem/negative with using any 'Object Types / Types / Inherited Attributes':

since we're working with Inherited (nested) Attributes, their Values can't be changed during game play (as Inherited, being nested, Attributes are locked/protected), unless you create/add the (same named) Attribute to that Object (which can defeat the whole purpose in using the 'Object Types / Types / Inherited Attributes' in the first place), which will over-ride/over-write the Inherited Attribute (of the same name), allowing you to now be able to change that Attribute's Value during game play

for a quick example of over-riding/over-writing Attributes:

<object name="room">

  <inherit name="editor_room" />

</object>

<object name="orc_1">

  <inherit name="editor_object" />

  <inherit name="orc_type" />

  <attr name="parent" type="object">room</attr>

</object>

<object name="orc_king_1">

  <inherit name="editor_object" />

  <inherit name="orc_type" />

  <attr name="parent" type="object">room</attr>

  <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="luck" type="int">50</attr>

</object>

<type name="orc_type">

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

</type>

// what their stats would be:

orc_1:

Strength: 10
Endurance: 10
Dexterity: 10
Agility: 10
Speed: 10
Piety: 10
Intelligence: 10
Spirituality: 10
Mentality: 10
Creativity: 10
Personality: 10
Charisma: 10
Leadership: 10
Alignment: 10
Luck: 10

orc_king_1:

Strength: 50
Endurance: 50
Dexterity: 50
Agility: 50
Speed: 50
Piety: 10
Intelligence: 10
Spirituality: 10
Mentality: 10
Creativity: 10
Personality: 10
Charisma: 10
Leadership: 10
Alignment: 10
Luck: 50

and, during game play, you can change the Values of the

orc_king_1's Attributes:

strength, endurance, dexterity, agility, speed, and luck

but, if you were to try to change the Values of orc_king_1's other Attributes, and/or any of orc_1's Attributes, during game play, you'd get an error


PS:

your 'variables' (character/whatever stats: amounts: Integer and/or Double Attributes, and non-amounts: String and/or List/Dictionary Attributes) would be:

Integers, Doubles, and/or String Attributes, examples (in direct code scripting):

player.strength = 100 // Integer Attribute
player.damage = 34.7 // Double Attribute
player.condition = "normal" // String Attribute

// String List Attribute example:

create ("condition_object")

condition_object.condition_stringlist_attribute = NewStringList ()

list add (condition_object.condition_stringlist_attribute, "normal")
list add (condition_object.condition_stringlist_attribute, "asleep")
list add (condition_object.condition_stringlist_attribute, "unconscious")
list add (condition_object.condition_stringlist_attribute, "dead")
list add (condition_object.condition_stringlist_attribute, "alive")
list add (condition_object.condition_stringlist_attribute, "undead")
list add (condition_object.condition_stringlist_attribute, "stunned")
list add (condition_object.condition_stringlist_attribute, "poisoned")
list add (condition_object.condition_stringlist_attribute, "paralyzed")
list add (condition_object.condition_stringlist_attribute, "petrified")
list add (condition_object.condition_stringlist_attribute, "silenced")
list add (condition_object.condition_stringlist_attribute, "blinded")
list add (condition_object.condition_stringlist_attribute, "crippled")
list add (condition_object.condition_stringlist_attribute, "afraid")
// etc etc etc conditions you might or might not have in/for your game, lol

and your 'truth states' can be Boolean Attributes or Integer Attributes:

// Boolean Attributes:
player.flying = false
player.flying = true
player.dead = false
player.dead = true
player.poisoned = false
player.poisoned = true
// etc etc etc

// or as Integers (same effect/thing, using Integers in this way, are known as 'flags' in Network/Packet Programming and/or in Assembly Language Programming):

(usually you'd use '0' and '1', but you can use any two integer numbers, well with quest you can anyways, as the required/standard is '0' and '1' if/when doing any "real" programming, such as Network/Packet Programming and/or Assembly Language Programming, as ultimately, computers do use the '0' and '1' Integer Values: everything ultimately gets converted/broken-down into '0' and '1' Integer Values at the hardware-software/machine-language level, for example, the Boolean values of 'true' and 'false' get converted/broken-down into the Integer Values of '1' and '0', but we like using Boolean Values of 'true' and 'false' as those are more human-friendly than '1' and '0', this is what is known as higher languages: being human friendly, whereas lower languages aren't human-friendly)

// Integer Attributes:
player.flying = 0 // not flying
player.flying = 1 // flying
player.dead = 0 // not dead
player.dead = 1 // dead
player.poisoned = 0 // not poisoned
player.poisoned = 1 / poisoned


PSS

here are the built-in 'Object Types / Types / Inherited Attributes' of quest:

https://docs.textadventures.co.uk/quest/elements/object.html (scroll down to the very bottom, the last section: Object Types defined by Core.aslx)


also, forget to mention this:

'Object Types / Types' can hold Attributes and/or other 'Object Types / Types' (Inherited Attributes)

so, you can have 'Object Types / Types / Inherited Attributes' nested within 'Object Types / Types / Inherited Attributes'

you can have multiple levels/layers/nesting of 'Object Types / Types / Inherited Attributes'

for quick example:

organism taxonomy:

the older (religious: chirstianity) mnemonic (memory trick): "King Paul Cried Out For Good Soup"

Kingdom > Phylum > Class > Order > Family > Genus > Species

human taxonomy: https://en.wikipedia.org/wiki/Human (see the box on the right side)

<object name="human">

  <inherit name="human_type" />

</object>

<type name="human_type">

  <inherit name="homo_type" />

  <attr name="species" type="string">human</attr>

</type>

<type name="homo_type">

  <inherit name="ape_type" />

  <attr name="genus" type="string">homo</attr>

</type>

<type name="ape_type">

  <inherit name="primate_type" />

  <attr name="family" type="string">ape</attr>

</type>

<type name="primate_type">

  <inherit name="mammal_type" />

  <attr name="order" type="string">primate</attr>

</type>

<type name="mammal_type">

  <inherit name="chordata_type" />

  <attr name="class" type="string">mammal</attr>

</type>

<type name="chordata_type">

  <inherit name="animal_type" />

  <attr name="phylum" type="string">chordata</attr>

</type>

<type name="animal_type">

  <attr name="kingdom" type="string">animal</attr>

</type>

// Attributes:

human (Object):

kingdom: animal
phylum: chordata
class: mammal
order: primate
family: ape
genus: homo
species: human


Log in to post a reply.

Support

Forums