How to check what room an object is in?
falconesabc
24 Jun 2016, 13:31Is there a way to see if an object is in the same room as another object?
HegemonKhan
24 Jun 2016, 14:23you use the built-in 'parent' Attribute, for an example:
(relevent part from a) default new game's code:
is the exact same as:
---------
Quest's 'Object' Elements work exactly like the folders on your computer and/or an outline:
C:\\ Drive
-> Programs Folder
->-> Quest Folder
->->-> quest.exe File
HK
-> pants
->-> wallet
->->-> $1
Earth
-> North America
->-> United States
->->-> California
->->->-> San Francisco
-> Asia
->-> China
->->-> ??? (I don't know if China have states/provinces/territories? I don't know much about China, sighs)
->->->-> Beijing
Quest uses a html/xml (webpage languages) like code for its "actual physical stuff" of its game code, so that means you have start and end tags:
a "thing" block shown vertically:
(start tag)
-> contents
(end tag)
a "thing" block shown horizontally:
(start tag) contents (end tag)
<asl version="550"> // (start tag)
-> <include ref="English.aslx" /> // (start+end tags)
-> <include ref="Core.aslx" /> // (start+end tags)
-> <game name="blah"> // (start tag)
->-> // contents (start+end tags)
-> </game> // (end tag)
-> <object name="room"> // (start tag)
->-> <object name="player"> // (start tag)
->->-> // contents (start+end tags)
->-> </object> // (end tag)
-> </object> // (end tag)
</asl> // (end tag)
conceptually, what these would look like with having start and end tags (being tag "blocks"):
C:\\ Drive (start)
-> Programs Folder (start)
->-> Quest Folder (start)
->->-> quest.exe File (start+end)
->-> Quest Folder (end)
-> Programs Folder (end)
C:\\ Drive (end)
HK (start)
-> pants (start)
->-> wallet (start)
->->-> $1 (start+end)
->-> wallet (end)
-> pants (end)
HK (end)
Earth (start)
-> North America (start)
->-> United States (start)
->->-> California (start+end)
->-> United States (end)
-> North America (end)
Earth (end)
containment (Child-Parent) heirarchy:
grandfather
-> father
->-> son
->->-> grandson
grandfather is the main (root) parent
grandfather is the direct parent of father
grandfather in the indirect parent of son and grandson
father is the direct child of grandfather
father is the direct parent of son
father is the indirect parent of grandson
son is the indirect child of grandfather
son is the direct child of father
son is the direct parent of grandson
grandson is the direct child of son
grandson is the indirect child of grandfather and father
grandfather.parent = null
father.parent = grandfather
son.parent = father
grandson.parent = son
------------------------
what would the heirarchy look like if I did this?
grandfather.parent = null
father.parent = grandfather
son.parent = father
grandson.parent = grandfather
Answer:
grandfather
-> father
->-> son
-> grandson
and this?
grandfather.parent = null
father.parent = son
son.parent = grandfather
grandson.parent = father
Answer:
grandfather
-> son
->-> father
->->-> grandson
and this?
grandfather.parent = father
father.parent = son
son.parent = grandson
grandson.parent = null
Answer:
grandson
-> son
->-> father
->->-> grandfather
------------------------
anyways, back to your question... lol
-------
besides the built-in 'parent' Object Attribute, there's also the:
'Got', 'Contains', 'ListContains', and/or 'DictionaryContains' Scripts/Functions too
(relevent part from a) default new game's code:
<object name="room">
<object name="player">
</object>
</object>
is the exact same as:
<object name="room">
</object>
<object name="player">
<attr name="parent" type="object">room</attr>
</object>
---------
Quest's 'Object' Elements work exactly like the folders on your computer and/or an outline:
C:\\ Drive
-> Programs Folder
->-> Quest Folder
->->-> quest.exe File
HK
-> pants
->-> wallet
->->-> $1
Earth
-> North America
->-> United States
->->-> California
->->->-> San Francisco
-> Asia
->-> China
->->-> ??? (I don't know if China have states/provinces/territories? I don't know much about China, sighs)
->->->-> Beijing
Quest uses a html/xml (webpage languages) like code for its "actual physical stuff" of its game code, so that means you have start and end tags:
a "thing" block shown vertically:
(start tag)
-> contents
(end tag)
a "thing" block shown horizontally:
(start tag) contents (end tag)
<asl version="550"> // (start tag)
-> <include ref="English.aslx" /> // (start+end tags)
-> <include ref="Core.aslx" /> // (start+end tags)
-> <game name="blah"> // (start tag)
->-> // contents (start+end tags)
-> </game> // (end tag)
-> <object name="room"> // (start tag)
->-> <object name="player"> // (start tag)
->->-> // contents (start+end tags)
->-> </object> // (end tag)
-> </object> // (end tag)
</asl> // (end tag)
conceptually, what these would look like with having start and end tags (being tag "blocks"):
C:\\ Drive (start)
-> Programs Folder (start)
->-> Quest Folder (start)
->->-> quest.exe File (start+end)
->-> Quest Folder (end)
-> Programs Folder (end)
C:\\ Drive (end)
HK (start)
-> pants (start)
->-> wallet (start)
->->-> $1 (start+end)
->-> wallet (end)
-> pants (end)
HK (end)
Earth (start)
-> North America (start)
->-> United States (start)
->->-> California (start+end)
->-> United States (end)
-> North America (end)
Earth (end)
containment (Child-Parent) heirarchy:
grandfather
-> father
->-> son
->->-> grandson
grandfather is the main (root) parent
grandfather is the direct parent of father
grandfather in the indirect parent of son and grandson
father is the direct child of grandfather
father is the direct parent of son
father is the indirect parent of grandson
son is the indirect child of grandfather
son is the direct child of father
son is the direct parent of grandson
grandson is the direct child of son
grandson is the indirect child of grandfather and father
grandfather.parent = null
father.parent = grandfather
son.parent = father
grandson.parent = son
------------------------
what would the heirarchy look like if I did this?
grandfather.parent = null
father.parent = grandfather
son.parent = father
grandson.parent = grandfather
Answer:
grandfather
-> father
->-> son
-> grandson
and this?
grandfather.parent = null
father.parent = son
son.parent = grandfather
grandson.parent = father
Answer:
grandfather
-> son
->-> father
->->-> grandson
and this?
grandfather.parent = father
father.parent = son
son.parent = grandson
grandson.parent = null
Answer:
grandson
-> son
->-> father
->->-> grandfather
------------------------
anyways, back to your question... lol
// object_X.parent = room
// object_Y.parent = room
if (object_X.parent = object_Y.parent) {
msg ("object_X and object_Y are both contained within the same object)
} else {
msg ("object_X and object_Y are not both contained within the same object")
}
// output: object_X and object_Y are both contained within the same object (room)
VS
// object_X.parent = room
// object_Y.parent = room2
if (object_X.parent = object_Y.parent) {
msg ("object_X and object_Y are both contained within the same object)
} else {
msg ("object_X and object_Y are not both contained within the same object")
}
// output: object_X and object_Y are not both contained within the same object (room vs room2)
VS
// object_X.parent = room2
// object_Y.parent = room2
if (object_X.parent = object_Y.parent) {
msg ("object_X and object_Y are both contained within the same object)
} else {
msg ("object_X and object_Y are not both contained within the same object")
}
// output: object_X and object_Y are both contained within the same object (room2)
-------
besides the built-in 'parent' Object Attribute, there's also the:
'Got', 'Contains', 'ListContains', and/or 'DictionaryContains' Scripts/Functions too