Hey guys, I'm trying to reference an attribute of the room that the player is currently in for a script that triggers every time the player enters a room. I'm not sure what syntax would be used to do this. There are multiple attributes I'd like to reference, some are booleans, some are integers.
How would I go about this?
You could use something like:
room = player.parent
if (room.attribute1) {
room.attrubute2 = room.attribute2+1
}
Is that what you mean?
as has already been explained on the other thread, just to recap/explain it:
NAME_OF_OBJECT.parent = stores and thus can be used to get/return the Object containing the 'NAME_OF_OBJECT' Object, which would then be applied to a further attached Attribute, for example:
<object name="father">
<attr name="alias" type="string">jeff</attr>
</object>
<object name="son">
<attr name="parent" type="object">father</attr>
<attr name="alias" type="string">bill</attr>
</object>
msg (father.alias)
// outputs: jeff
msg (son.alias)
// outputs: bob
msg (son.parent.alias)
// outputs: jeff
//
// effectively it is doing this:
// msg (<son.parent>.alias)
// son.parent = father
// msg (<father>.alias)
// msg (father.alias)
// outputs: jeff
you may be interested in a neat application of this, Sgrieg's 'follower' code (or it could just further demonstrate/explain how using 'OBJECT.ATTRIBUTE.ATTRIBUTE' can/does work):
<object name="player">
<attr name="parent" type="object">room</attr>
<attr name="team_objectlist_attribute" type="objectlist">player2;player3</attr>
<attr name="changedparent" type="script">
foreach (team_member_object_variable, this.team_objectlist_attribute) {
team_member_object_variable.parent = this.parent
}
</attr>
</object>
<object name="player2">
<attr name="parent" type="object">room</attr>
</object>
<object name="player3">
<attr name="parent" type="object">room</attr>
</object>
<object name="room">
</object>
<object name="room2">
</object>
// when the 'player' Player Object moves to 'room2' Room Object (player.parent = room2),
// the 'player2' and 'player3' Objects are also moved to the parent Room of the 'player' Player object, which is 'room2'