Checking if object is in same room as player
Marzipan
11 May 2015, 21:51This is another one of those incredibly simple questions I feel dumb for even having to post, but I'm having trouble with the exact syntax needed. All I want to do is use some {if} text that will change descriptions based on whether you're in the room with a certain NPC.
I've tried about half a dozen different variations of {if game.pov.parent=BLAHBLAH:} and even more complicated stuff like(ListContains(ScopeReachable(), NPC NAME GOES HERE)) and I keep getting errors.
It's not a huge deal because I can make it work with an if/else script, I'd just prefer not to have to mess with those constantly when half the time all I'm doing is slapping down an extra line of text.
I've tried about half a dozen different variations of {if game.pov.parent=BLAHBLAH:} and even more complicated stuff like(ListContains(ScopeReachable(), NPC NAME GOES HERE)) and I keep getting errors.
It's not a huge deal because I can make it work with an if/else script, I'd just prefer not to have to mess with those constantly when half the time all I'm doing is slapping down an extra line of text.

XanMag
12 May 2015, 01:06Here comes the dumbest answer ever... but, I'm trying to help =)
Of course, this depends on HOW you move the NPC to the room with your player...
*Brace yourself*
I just left the room description blank and put the room description in the 'when entering' in GUI. But, that may be worse than using your if/else script. That is how a non-coder using Quest would solve it.
I toyed around with simply running an if/else script in the room description and I couldn't figure out how to make it work... after some bumbling, I came up with this helpless tidbit.
Happy gaming and good luck.
Of course, this depends on HOW you move the NPC to the room with your player...
*Brace yourself*
<object name="A">
<inherit name="editor_room" />
<enter type="script">
if (RandomChance(50)) {
MoveObject (Ned, A)
msg ("You are in Room A with Ned.")
}
else {
msg ("You are in Room A all by yourself.")
}
I just left the room description blank and put the room description in the 'when entering' in GUI. But, that may be worse than using your if/else script. That is how a non-coder using Quest would solve it.
I toyed around with simply running an if/else script in the room description and I couldn't figure out how to make it work... after some bumbling, I came up with this helpless tidbit.

Happy gaming and good luck.
Marzipan
12 May 2015, 02:08Well that's...definitely an original method. 
But I guess I wasn't clear in my original post, it's mainly object descriptions that need to be added to. If the NPC is with you she has comments on some of the things you're looking at, and at one point the player gets a hold of an object that changes the way they see certain things.
I'll probably just stick with the scripts for now unless someone comes up with something obvious that I missed. Right now I'm just using 'if object is reachable' for the NPC and 'if player is carrying object' for the other. Simple enough but all the clicking gets annoying after awhile.

But I guess I wasn't clear in my original post, it's mainly object descriptions that need to be added to. If the NPC is with you she has comments on some of the things you're looking at, and at one point the player gets a hold of an object that changes the way they see certain things.
I'll probably just stick with the scripts for now unless someone comes up with something obvious that I missed. Right now I'm just using 'if object is reachable' for the NPC and 'if player is carrying object' for the other. Simple enough but all the clicking gets annoying after awhile.
HegemonKhan
12 May 2015, 02:20the GUI~EDitor's 'MoveObject()' Function ( http://docs.textadventures.co.uk/quest/ ... bject.html ), actually works based upon (well, I'm not sure about that, lol, but still) the true underlying code actually (is):
http://docs.textadventures.co.uk/quest/ ... arent.html
and it's a built-in Object Attribute (another is 'game.pov', which you're probably familiar with):
http://docs.textadventures.co.uk/quest/ ... bject.html ( http://docs.textadventures.co.uk/quest/types/ )
similiar to custom Object Attributes, such as:
player.left_hand = shield
player.right_hand = sword
<object name="player">
</object>
<object name="sword">
</object>
<object name="shield">
</object>
path to finding its (an Object's 'parent' Attribute) location in the wiki:
http://docs.textadventures.co.uk/quest/
V
http://docs.textadventures.co.uk/quest/elements/
V
http://docs.textadventures.co.uk/quest/ ... bject.html
V
http://docs.textadventures.co.uk/quest/ ... arent.html
---------------------
~OR (using the default 'player' Player Object) ~
explanation of this concept of Sgreig's 'follower' code, conceptually:
HK.parent = planet earth
Marzipan.parent = planet earth
HK.parent = planet earth = Marzipan.parent
so, if HK.parent (planet earth) = Marzipan.parent (planet earth), then both HK and Marzipan are on~in planet earth (usually a Room Object).
-----------
Sgreig's 'follower' code:
on the left side of the equals, have the 'Object_name.parent' that is the FOLLOWER~MOVING OBJECT
on the right side of the equal, have the 'Object_name.parent' that is the LEADER~DESTINATION OBJECT
in this example, we're having something (such as a 'party_member' character) FOLLOW the 'player' (game.pov) Player Object:
~OR, the reverse, such as you following a 'guide' character ~
-----------------
if you need to dynamically or what~how ever select the Object(s), then the coding will obviously be more complex...
http://docs.textadventures.co.uk/quest/ ... arent.html
and it's a built-in Object Attribute (another is 'game.pov', which you're probably familiar with):
http://docs.textadventures.co.uk/quest/ ... bject.html ( http://docs.textadventures.co.uk/quest/types/ )
similiar to custom Object Attributes, such as:
player.left_hand = shield
player.right_hand = sword
<object name="player">
</object>
<object name="sword">
</object>
<object name="shield">
</object>
path to finding its (an Object's 'parent' Attribute) location in the wiki:
http://docs.textadventures.co.uk/quest/
V
http://docs.textadventures.co.uk/quest/elements/
V
http://docs.textadventures.co.uk/quest/ ... bject.html
V
http://docs.textadventures.co.uk/quest/ ... arent.html
---------------------
if (Object_name.parent = game.pov.parent) {
// scripts
} else {
// scripts
}
~OR (using the default 'player' Player Object) ~
if (Object_name.parent = player.parent) {
// scripts
} else {
// scripts
}
explanation of this concept of Sgreig's 'follower' code, conceptually:
HK.parent = planet earth
Marzipan.parent = planet earth
HK.parent = planet earth = Marzipan.parent
so, if HK.parent (planet earth) = Marzipan.parent (planet earth), then both HK and Marzipan are on~in planet earth (usually a Room Object).
-----------
Sgreig's 'follower' code:
on the left side of the equals, have the 'Object_name.parent' that is the FOLLOWER~MOVING OBJECT
on the right side of the equal, have the 'Object_name.parent' that is the LEADER~DESTINATION OBJECT
in this example, we're having something (such as a 'party_member' character) FOLLOW the 'player' (game.pov) Player Object:
if (not party_member_1.parent = game.pov.parent) {
party_member_1.parent = game.pov.parent
msg ("The party member follows you where~what ever Room Object you go to.")
}
~OR, the reverse, such as you following a 'guide' character ~
if (not game.pov.parent = guide_1.parent) {
game.pov.parent = guide_1.parent
msg ("You follow the guide character Object to what~where ever Room Object he~she goes to.")
}
-----------------
if you need to dynamically or what~how ever select the Object(s), then the coding will obviously be more complex...
HegemonKhan
12 May 2015, 02:28or you can do this too:
http://docs.textadventures.co.uk/quest/ ... tains.html
if you need to do more complex stuff, such as dynamic Objects, again that's more complex, probably using two 'foreach' and comparing them (string matching) ~ see Chase's Wearables (Equipment) Library, or whatever other advanced code methods~designs.
http://docs.textadventures.co.uk/quest/ ... tains.html
if (Contains (room,HK) and Contains (room,Marzipan)) {
// scripts
} else if (Contains (room,HK) and not Contains (room,Marzipan)) {
// scripts
} else if (not Contains (room,HK) and Contains (room,Marzipan)) {
// scripts
} else if (not Contains (room,HK) and not Contains (room,Marzipan)) {
// scripts
} else {
// scripts
}
if you need to do more complex stuff, such as dynamic Objects, again that's more complex, probably using two 'foreach' and comparing them (string matching) ~ see Chase's Wearables (Equipment) Library, or whatever other advanced code methods~designs.
HegemonKhan
12 May 2015, 02:53more explanation of it:
player: the (Player) OBJECT
player.parent: the (usually) ROOM that the (Player) Object is within
team_member_1: the (non-player non-room) OBJECT
team_member_1.parent: the (usually) ROOM that the (team_member_1) Object is within
and for what you want spefically (but not in full form ~ just a sample example):
--------------
even more explanation of it:
you both start out in the same room:
HK is going to be the LEADER, and Marzipan, the FOLLOWER, hehe.
HK.parent = room
Marzipan = room
I move to another room, 'room2' :
HK.parent = room2
and, in knowing what room, you can simply do the same:
Marzipan.parent = room2
HOWEVER... what if HK can move to any one of these rooms: room2, room3, or room4 ???
we can *NO* longer do the 'static' simple method of:
Marzipan.parent = ... (BECAUSE: what room is HK in ~ what room did HK moved to, ????)
so, instead, we're simply going to SET Marzipan to being in whatever room that HK is in, via:
Marzipan.parent = HK.parent
the 'parent' Room that Marzipan is (put~moved~set with)-in, is to be whatever the 'parent' Room that HK is (set) within.
if HK.parent = room2, then, conceptually:
Marzipan.parent = HK.parent = room2
~OR~
Marzipan.parent = room2 = HK.parent
if HK.parent = room 4, then conceptually:
Marzipan.parent = HK.parent = room4
~OR~
Marzipan.parent = room4 = HK.parent
so, this is how:
Marzipan.parent = HK.parent
works for when DYNAMIC usage is needed~done.
----------
STATIC situation:
HK.parent = room2
thus we can do:
Marzipan.parent = room2
--------
DYNAMIC situation:
HK and Marzipan both begin in the same ROOM: 'room',
but then HK is randomly (set ~ re-set ~ moved to) either: room2, room3, or room4:
HK.parent = ObjectListItem (global_data_object.room_objectlist_attribute, GetRandomInt (0, ListCount (global_data_object.room_objectlist_attribute) - 1) )
~ OR (this is the exact same thing as above) ~
thus we MUST do:
Marzipan.parent = HK.parent
player: the (Player) OBJECT
player.parent: the (usually) ROOM that the (Player) Object is within
team_member_1: the (non-player non-room) OBJECT
team_member_1.parent: the (usually) ROOM that the (team_member_1) Object is within
if (not team_member_1.parent = player.parent) { // if the Room that team_member_1 is in, is not the same Room as the 'player' is in,
team_member_1.parent = player.parent // set~move the team_member_1's Room that he~she~it is in, BE the Room that the 'player' is in.
}
and for what you want spefically (but not in full form ~ just a sample example):
if (team_member_1.parent = player.parent) { // if the Room that 'team_member_1' is in, is the same Room that 'player' is in,
// your Room 'description' Scripts or npc (team_member_1) 'look~lookat' Scripts or your 'pc~you~player' commenting 'msg' Scripts or whatever other description scripts based upon the two Objects being there together
} else {
// the description scripts for being there alone
}
--------------
even more explanation of it:
you both start out in the same room:
HK is going to be the LEADER, and Marzipan, the FOLLOWER, hehe.
HK.parent = room
Marzipan = room
I move to another room, 'room2' :
HK.parent = room2
and, in knowing what room, you can simply do the same:
Marzipan.parent = room2
HOWEVER... what if HK can move to any one of these rooms: room2, room3, or room4 ???
we can *NO* longer do the 'static' simple method of:
Marzipan.parent = ... (BECAUSE: what room is HK in ~ what room did HK moved to, ????)
so, instead, we're simply going to SET Marzipan to being in whatever room that HK is in, via:
Marzipan.parent = HK.parent
the 'parent' Room that Marzipan is (put~moved~set with)-in, is to be whatever the 'parent' Room that HK is (set) within.
if HK.parent = room2, then, conceptually:
Marzipan.parent = HK.parent = room2
~OR~
Marzipan.parent = room2 = HK.parent
if HK.parent = room 4, then conceptually:
Marzipan.parent = HK.parent = room4
~OR~
Marzipan.parent = room4 = HK.parent
so, this is how:
Marzipan.parent = HK.parent
works for when DYNAMIC usage is needed~done.
----------
STATIC situation:
HK.parent = room2
thus we can do:
Marzipan.parent = room2
--------
DYNAMIC situation:
HK and Marzipan both begin in the same ROOM: 'room',
but then HK is randomly (set ~ re-set ~ moved to) either: room2, room3, or room4:
HK.parent = ObjectListItem (global_data_object.room_objectlist_attribute, GetRandomInt (0, ListCount (global_data_object.room_objectlist_attribute) - 1) )
<object name="room">
<object name="HK">
// done by the quest engine (hidden from you): <parent type="object">room</attr>
</object>
<object name="Marzipan">
// done by the quest engine (hidden from you): <parent type="object">room</attr>
</object>
</object>
<object name="room2">
</object>
<object name="room3">
</object>
<object name="room4">
</object>
<object name="global_data_object">
<attr name="room_objectlist_attribute" type="objectlist">room2;room3;room4</attr>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
HK.parent = ObjectListItem (global_data_object.room_objectlist_attribute, GetRandomInt (0, ListCount (global_data_object.room_objectlist_attribute) - 1) )
</turnscript>
~ OR (this is the exact same thing as above) ~
<object name="room">
</object>
<object name="room2">
</object>
<object name="room3">
</object>
<object name="room4">
</object>
<object name="HK">
<parent type="object">room</attr>
</object>
<object name="Marzipan">
<parent type="object">room</attr>
</object>
<object name="global_data_object">
<attr name="room_objectlist_attribute" type="objectlist">room2;room3;room4</attr>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
HK.parent = ObjectListItem (global_data_object.room_objectlist_attribute, GetRandomInt (0, ListCount (global_data_object.room_objectlist_attribute) - 1) )
</turnscript>
thus we MUST do:
Marzipan.parent = HK.parent
<turnscript name="global_turnscript">
<enabled />
<script>
HK.parent = ObjectListItem (global_data_object.room_objectlist_attribute, GetRandomInt (0, ListCount (global_data_object.room_objectlist_attribute) - 1) )
Marzipan.parent = HK.parent
</turnscript>
Marzipan
12 May 2015, 03:29Okay, I'll have a look at that method, but it may be getting a tad bit complex for me. What I'm doing now may wind up being what I stick with, hacky and tedious as it is.

Yep, gonna get old reeeeaaaal fast. May just have to scale it back to only cover the most plot relevant objects.
The bit about follower/leader NPCs will definitely be helpful though.

Yep, gonna get old reeeeaaaal fast. May just have to scale it back to only cover the most plot relevant objects.
The bit about follower/leader NPCs will definitely be helpful though.
HegemonKhan
12 May 2015, 03:36the 'follower~leader' is applicable to your topic desire~question of descriptions based upon what Objects are in (usually) a Room, for the scripts, you just do the variation description scripts that you want, as opposed to doing a 'move~parent' Script for the literally 'following' functionality, which is off-topic.
--------
I've edited in and added a few posts (sorry for multiple postings), which try to explain what is going on with this 'following' (Object_1_name.parent = Object_2_name.parent) code method, hopefully after reading all of them or one of them, will help it make sense for~to you... HK crosses his fingers. They're just different ways of me trying to explain the concept taking place, so (hopefully you) don't get confused by them... HK crosses his fingers.
--------
I've edited in and added a few posts (sorry for multiple postings), which try to explain what is going on with this 'following' (Object_1_name.parent = Object_2_name.parent) code method, hopefully after reading all of them or one of them, will help it make sense for~to you... HK crosses his fingers. They're just different ways of me trying to explain the concept taking place, so (hopefully you) don't get confused by them... HK crosses his fingers.
HegemonKhan
12 May 2015, 04:07unfortunately, there's really no way to shorten up stuff...
if you want dynamic descriptions for each location based upon what Objects are there... you got to do so, there's no real way to do less work, aside from if the variation descriptions are the same, then you can put them into a function, and just have the Room descriptions call that function.
for example, if you got a lantern, and you want it to display the same message (and~or do the same acts~events~stuff) regardless of what location~room you're in, then you could put those scripts into a function, and have each room description call that function.
however, if you want dynamic variations, then you got to do the 'if~else if~else' and like scripting for those variances...
unfortunately, you just can't shorten up the work needed for complexity~dynamicness, sighs. So the more combinations of complexities~dynamic'ies, the more work you got to do, and it's exponential~quadratic....
the more combinations~paths~variations~dynamicness~etc you have in your game (which might seem no big deal to you, is a big deal with~for the computer, and thus you, to code it in) ...
1,2,4,8,32,64,128,256,512,1024,etc
1,3,9,27,81,243,etc
1,4,16,64,etc
1,5,25,125,etc
for example, this doesn't seem like a big deal, but it is as it requires exponential~quadratically more work:
species: human, elf, dwarf, halfing
classes: warrior, wizard,cleric,thief
then, TIMES all the instances where these are involved, and TIMES again for all the variations involved, and etc TIMES stuff....
VS
species: human;elf;dwarf;halfing
races: european;asian;arabian;african;american;ljosalfar;dokkalfar;svartalfar;wood elf;high elf;dwarf1;dwarf2;etc;hobbit;halfing2;etc
classes: warrior;knight;barbarian;ranger;druid;berserker;paladin;ninja;samurai;monk;cleric;wizard;mage;witch;amazon;pirate;bard;etc
then, TIMES all the instances where these are involved, and TIMES again for all the variations involved, and etc TIMES stuff....
the amount of work needed is unfathomable... (and I the idiot am doing just this... laughs)
------------
maybe, good programmers, can craft really brilliant 'omni~ 1 inch long theory of everything ~ 1 inch long e=mc^2' like structural~organizational code designs, which reduce a degree of the amount of work (actual coding~writing~typing ~ character length) needed, but we're both no-where near that level of coding, laughs. We can't craft super parsing scriptings that can deal with any situation... that's really high level coding ability, lol.
------------
some words of wisdom from my own work~attempts at our level of coding (noob level):
do NOT care how long~repetitive~redundant your code is !!!
only care about:
1. functionality (it works correctly lol)
2A. simplicity and quickness (it's fast and easy for you to craft code, and then just copy+paste + small easy quick changes)
2B. seperate everything out, make it as simple as possible, 'compartmentalize' your code into simple code blocks, don't try to do super omni parsing script blocks, keep it as simple and separate as you can, it'll keep you from pulling your hair out, laughs.
later on, you can go back and try to reduce the amount of character length of your game code, try to make better code design systems, that don't have redundant copy and paste code block after code block, having instead fewer but more advanced~complex code blocks that do the same thing, but this is only after you coding ability has improved drastically, and you're able to do such more complex~advanced code designs which actually work, and don't take you much time to figure out nor to craft~write it's syntax correctly, lol.
if you want dynamic descriptions for each location based upon what Objects are there... you got to do so, there's no real way to do less work, aside from if the variation descriptions are the same, then you can put them into a function, and just have the Room descriptions call that function.
for example, if you got a lantern, and you want it to display the same message (and~or do the same acts~events~stuff) regardless of what location~room you're in, then you could put those scripts into a function, and have each room description call that function.
however, if you want dynamic variations, then you got to do the 'if~else if~else' and like scripting for those variances...
unfortunately, you just can't shorten up the work needed for complexity~dynamicness, sighs. So the more combinations of complexities~dynamic'ies, the more work you got to do, and it's exponential~quadratic....
the more combinations~paths~variations~dynamicness~etc you have in your game (which might seem no big deal to you, is a big deal with~for the computer, and thus you, to code it in) ...
1,2,4,8,32,64,128,256,512,1024,etc
1,3,9,27,81,243,etc
1,4,16,64,etc
1,5,25,125,etc
for example, this doesn't seem like a big deal, but it is as it requires exponential~quadratically more work:
species: human, elf, dwarf, halfing
classes: warrior, wizard,cleric,thief
then, TIMES all the instances where these are involved, and TIMES again for all the variations involved, and etc TIMES stuff....
VS
species: human;elf;dwarf;halfing
races: european;asian;arabian;african;american;ljosalfar;dokkalfar;svartalfar;wood elf;high elf;dwarf1;dwarf2;etc;hobbit;halfing2;etc
classes: warrior;knight;barbarian;ranger;druid;berserker;paladin;ninja;samurai;monk;cleric;wizard;mage;witch;amazon;pirate;bard;etc
then, TIMES all the instances where these are involved, and TIMES again for all the variations involved, and etc TIMES stuff....
the amount of work needed is unfathomable... (and I the idiot am doing just this... laughs)
------------
maybe, good programmers, can craft really brilliant 'omni~ 1 inch long theory of everything ~ 1 inch long e=mc^2' like structural~organizational code designs, which reduce a degree of the amount of work (actual coding~writing~typing ~ character length) needed, but we're both no-where near that level of coding, laughs. We can't craft super parsing scriptings that can deal with any situation... that's really high level coding ability, lol.
------------
some words of wisdom from my own work~attempts at our level of coding (noob level):
do NOT care how long~repetitive~redundant your code is !!!
only care about:
1. functionality (it works correctly lol)
2A. simplicity and quickness (it's fast and easy for you to craft code, and then just copy+paste + small easy quick changes)
2B. seperate everything out, make it as simple as possible, 'compartmentalize' your code into simple code blocks, don't try to do super omni parsing script blocks, keep it as simple and separate as you can, it'll keep you from pulling your hair out, laughs.
later on, you can go back and try to reduce the amount of character length of your game code, try to make better code design systems, that don't have redundant copy and paste code block after code block, having instead fewer but more advanced~complex code blocks that do the same thing, but this is only after you coding ability has improved drastically, and you're able to do such more complex~advanced code designs which actually work, and don't take you much time to figure out nor to craft~write it's syntax correctly, lol.
Marzipan
12 May 2015, 04:32Thanks for all the explanations, but for now I'll probably just keep changing the individual object descriptions like in the screenshot I posted. Though your method of making the NPC follow the player (or vice versa) will simplify things for me there and in other areas and I'll definitely be using it.
HegemonKhan
12 May 2015, 04:48if you want to do it in the GUI~Editor, an example:
'forest' Room Object -> '?Setup? or ?room description?' Tab -> 'description' -> run as script -> add a~new script -> scripts -> 'if' Script -> [EXPRESSION] -> (see below)
Marzipan.parent = player.parent
-> then, -> add a script -> output -> 'msg' Script -> [EXPRESSION] -> (see below)
HK and Marzipan look around the forest nervously, afraid of all the dangers that are lurking about, and both decide that it would be best to put aside their differences and work together, in order to survive.
else,
-> add a script -> output -> 'msg' Script -> [EXPRESSION] -> (see below)
HK looks around the forest nerverously, afraid of all the dangers that are lurking about, and wishing that Marzipan was with him, instead of having gone a different way, splitting up, due to their differences, as HK could use another pair of eyes and a brain with him in the dangerous forest in order to survive.
-----------
OR using the text processor (I'm still new to this, so hopefully this is how it's done):
http://docs.textadventures.co.uk/quest/ ... essor.html
'forest' Room Object -> '?Setup? or ?room description?' Tab -> 'description' -> run as script -> add a~new script -> output -> 'msg' Script -> [EXPRESSION] -> (see below)
{if Marzipan.parent = HK.parent: "HK and Marzipan look around the forest nervously, afraid of all the dangers that are lurking about, and both decide that it would be best to put aside their differences and work together, in order to survive."}
{if not Marzipan.parent = HK.parent: "HK looks around the forest nerverously, afraid of all the dangers that are lurking about, and wishing that Marzipan was with him, instead of having gone a different way, splitting up, due to their differences, as HK could use another pair of eyes and a brain with him in the dangerous forest in order to survive."}
you might need to remove the double quotes, I'm not sure if they're needed or not.
'forest' Room Object -> '?Setup? or ?room description?' Tab -> 'description' -> run as script -> add a~new script -> scripts -> 'if' Script -> [EXPRESSION] -> (see below)
Marzipan.parent = player.parent
-> then, -> add a script -> output -> 'msg' Script -> [EXPRESSION] -> (see below)
HK and Marzipan look around the forest nervously, afraid of all the dangers that are lurking about, and both decide that it would be best to put aside their differences and work together, in order to survive.
else,
-> add a script -> output -> 'msg' Script -> [EXPRESSION] -> (see below)
HK looks around the forest nerverously, afraid of all the dangers that are lurking about, and wishing that Marzipan was with him, instead of having gone a different way, splitting up, due to their differences, as HK could use another pair of eyes and a brain with him in the dangerous forest in order to survive.
-----------
OR using the text processor (I'm still new to this, so hopefully this is how it's done):
http://docs.textadventures.co.uk/quest/ ... essor.html
'forest' Room Object -> '?Setup? or ?room description?' Tab -> 'description' -> run as script -> add a~new script -> output -> 'msg' Script -> [EXPRESSION] -> (see below)
{if Marzipan.parent = HK.parent: "HK and Marzipan look around the forest nervously, afraid of all the dangers that are lurking about, and both decide that it would be best to put aside their differences and work together, in order to survive."}
{if not Marzipan.parent = HK.parent: "HK looks around the forest nerverously, afraid of all the dangers that are lurking about, and wishing that Marzipan was with him, instead of having gone a different way, splitting up, due to their differences, as HK could use another pair of eyes and a brain with him in the dangerous forest in order to survive."}
you might need to remove the double quotes, I'm not sure if they're needed or not.
The Pixie
12 May 2015, 08:29Marzipan wrote:This is another one of those incredibly simple questions I feel dumb for even having to post, but I'm having trouble with the exact syntax needed. All I want to do is use some {if} text that will change descriptions based on whether you're in the room with a certain NPC.
I've tried about half a dozen different variations of {if game.pov.parent=BLAHBLAH:} and even more complicated stuff like(ListContains(ScopeReachable(), NPC NAME GOES HERE)) and I keep getting errors.
It's not a huge deal because I can make it work with an if/else script, I'd just prefer not to have to mess with those constantly when half the time all I'm doing is slapping down an extra line of text.
Presumably you know the name of room if you are writing the description for it, so you do not needgame.pov.parent, just use the name. that means it can go on the right side of the condition. Say it is called "green_room", and your NPC is "boris". You description might look like this:
You are in a strange green room.{if boris.parent=green_room:The colour scheme is making Boris nauseous.}
Marzipan
12 May 2015, 14:27The Pixie wrote:
Presumably you know the name of room if you are writing the description for it, so you do not needgame.pov.parent, just use the name. that means it can go on the right side of the condition. Say it is called "green_room", and your NPC is "boris". You description might look like this:You are in a strange green room.{if boris.parent=green_room:The colour scheme is making Boris nauseous.}
Oh ffs.
That is one of the things I tried. Only by that point I was getting lazy and just slapping a 'your alt text worked, congrats!' message onto the player character's description so I could just type >x me and move on.
{if testobject.parent=Trapped:your alt text is working, congrats!}
Guess what the one object in the entire game is that the above doesn't work on?


Forgewright
12 May 2015, 16:11Say the player is being followed by a NPC, but it could be ANY NPC. Perhaps we started a fight and they are chasing us. Can we code for a check of any other NPC in the room. Not a specific NPC but any NPC? An, "Am I alone?" check.
The Pixie
12 May 2015, 16:55Some general code to start you off:
You will need to modify the third line for whatever you use to signify an NPC (eg, DoesInherit(o, "npc_type")). If the flag is false, the player is alone.
flag = false
foreach (o, GetDirectChildren(game.pov.parent)) {
if (o.npc) {
flag = true
msg("There is a " + GetDisplayAlias(o) + " stalking you."
}
}
You will need to modify the third line for whatever you use to signify an NPC (eg, DoesInherit(o, "npc_type")). If the flag is false, the player is alone.

jaynabonne
12 May 2015, 18:15The Pixie wrote:
Presumably you know the name of room if you are writing the description for it, so you do not needgame.pov.parent, just use the name. that means it can go on the right side of the condition. Say it is called "green_room", and your NPC is "boris". You description might look like this:You are in a strange green room.{if boris.parent=green_room:The colour scheme is making Boris nauseous.}
I don't think that works. (At least, it didn't work in the test I did.) boris.parent will be an object, not a string.
Or is it a new Quest feature?
With the version I have, it does "ToString" on the attribute, which makes player.parent look (in my case) like "Object: Room", which you can't compare against due to the ":" in it.

Edit: the above is wrong. It did work for me, once I upgraded. The above is left for continuity only.
Marzipan
12 May 2015, 19:32It did work for me, but keep in mind we're talking about the GUI text editor here, I didn't do anything with the actual code.
The thing I can't figure out is why it works with every object except the player...not that I need to change anything about the player's appearance in this case, I just find it to be weird.
The thing I can't figure out is why it works with every object except the player...not that I need to change anything about the player's appearance in this case, I just find it to be weird.

jaynabonne
12 May 2015, 20:14I upgraded to 5.6, and it works now. T'was just me.
And it works for me with "player" as well.
And it works for me with "player" as well.

Marzipan
12 May 2015, 20:46jaynabonne wrote:And it works for me with "player" as well.
So you're pasting the line directly in the player's description and it's showing up when you examine yourself?
I don't know why I can't get it to work. It's such a little thing but it's bugging the heck out of me.

jaynabonne
12 May 2015, 21:26If I paste it into the "Look at" description on the "Player" tab, then yes. The one on the "Object" tab doesn't work for "x me".
Marzipan
13 May 2015, 01:32Hate to waste anyone more time with such a trivial thing, but when I paste it in the Object tab it doesn't show up at all, and when I paste it in the Player tab it spits the entire {if blah.blah=blah:blahblah} line right back at me.
...but I've got bigger issues now, I noticed I had the old version and thought upgrading might help and instead I just broke my entire game.
...but I've got bigger issues now, I noticed I had the old version and thought upgrading might help and instead I just broke my entire game.


Forgewright
13 May 2015, 03:29Thanks Pix.
HegemonKhan
13 May 2015, 15:02@Forgewright:
just to add more commentary to Pixie's post~code:
the general concept is to give your 'npc' Objects an 'identifier' (a specific Attribute: String, Boolean, Integer, Double, Boolean, Script, List, Dictionary, etc, or an Object Type: 'inherit' Attribute), which thus allows quest to check for and separate these 'npc' Objects from the other Objects:
(err, 'npcs' are usually non-team_members ~ ie townsfolk, whereas 'pcs' is your main character and your team members, but meh, it's only my own terminology~symantics that I'm more used to, as terminology~symantics can be whatever you want it to be. In my examples below though, I'll use your terminolgy + some made up terminolgy based on your terminolgy to show all this stuff in ~full usage)
next the concept is to get all the Objects in (usually) a Room (or another Object, a Player Object such as your, the default 'player' Player Object's, own inventory, or the entire game itself: see the 'AllObjects ()' Functions) and cycle~iterate~go through them all:
foreach (placeholder_variable, Objectlist_Attribute_name) { scripts }
and the Scopes~Alls~Gets, which are Objectlists:
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/ ... tions.html (see the 'Allxxx' and some of the 'Getxxx' section)
to get a Room's Objects:
http://docs.textadventures.co.uk/quest/scopes.html (pick the one you want, as there's some differences between them)
for examples:
foreach (object_variable, ScopeReachableNotHeldForRoom) { scripts }
~OR~
foreach (object_variable, GetDirectChildren) { scripts }
to get the Player Object's inventory (your Objectlist):
foreach (object_variable, ScopeInventory) { scripts }
to get the entire game's Objects (the lazy, HK's, way, laughs):
foreach (object_variable, AllObjects () ) { scripts }
the last concept is to add your 'check' Scripts so it looks for if the Objects in the Objectlist, have that 'identifier' (the specific Attribute or Object Type: 'inherit' Attribute), to separate them out, from the other Objects, and then lastly after that, do the desired scripts for those separated (and~or unseparated) Objects:
for example:
'GetXAttributeX' does the 2 steps in 1, otherwise, you can use the 'HasXAttributeX' but you then got to do another step with it anyways. Ask if you're confused about 'get' and~or 'has', and I'll try to explain them better.
'HasXXX' ~ 'GetXXX'
~ AND~OR ~
'DoesInherit' (for Object Types: 'inherit' Attribute)
-------
useful links:
http://docs.textadventures.co.uk/quest/ ... tions.html
Objectlists:
Scopes:
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/ ... y/got.html (shortcut instead of using 'ScopeInventory' Function)
Alls:
http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... exits.html
http://docs.textadventures.co.uk/quest/ ... ripts.html
http://docs.textadventures.co.uk/quest/ ... mands.html
Gets (Objectlists):
http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... ldren.html
Attributes:
Object Types: 'inherit' Attribute
http://docs.textadventures.co.uk/quest/ ... /type.html (Object Types)
http://docs.textadventures.co.uk/quest/ ... herit.html (an Object Types 'inherit' Attribute)
Has'es:
http://docs.textadventures.co.uk/quest/ ... ibute.html (general Attribute Type)
etc etc etc (the specific Attribute Types)
Gets:
http://docs.textadventures.co.uk/quest/ ... ibute.html (general Attribute Type)
etc etc etc (the specific Attribute Types)
-----
just to add more commentary to Pixie's post~code:
the general concept is to give your 'npc' Objects an 'identifier' (a specific Attribute: String, Boolean, Integer, Double, Boolean, Script, List, Dictionary, etc, or an Object Type: 'inherit' Attribute), which thus allows quest to check for and separate these 'npc' Objects from the other Objects:
(err, 'npcs' are usually non-team_members ~ ie townsfolk, whereas 'pcs' is your main character and your team members, but meh, it's only my own terminology~symantics that I'm more used to, as terminology~symantics can be whatever you want it to be. In my examples below though, I'll use your terminolgy + some made up terminolgy based on your terminolgy to show all this stuff in ~full usage)
<object name="knight_team_mate_object">
<alias>blah1</alias>
<attr name="type_of_object" type="string">npc</attr>
</object>
<object name="barbarian_team_mate_object">
<alias>blah2</alias>
<attr name="type_of_object" type="string">npc</attr>
</object>
<object name="thief_team_mate_object">
<alias>blah3</alias>
<attr name="type_of_object" type="string">npc</attr>
</object>
<object name="cleric_team_mate_object">
<alias>blah4</alias>
<attr name="type_of_object" type="string">npc</attr>
</object>
<object name="wizard_team_mate_object">
<alias>blah5</alias>
<attr name="type_of_object" type="string">npc</attr>
</object>
<object name="haphaetu_the_blacksmith_townsfolk_object">
<alias>blah6</alias>
<attr name="type_of_object" type="string">non_npc</attr>
</object>
<object name="the_tavern_owner_townsfolk_object">
<alias>blah7</alias>
<attr name="type_of_object" type="string">non_npc</attr>
</object>
<object name="table_1_object">
<alias>table</alias>
</object>
<object name="chair_1_object">
<alias>chair</alias>
</object>
next the concept is to get all the Objects in (usually) a Room (or another Object, a Player Object such as your, the default 'player' Player Object's, own inventory, or the entire game itself: see the 'AllObjects ()' Functions) and cycle~iterate~go through them all:
foreach (placeholder_variable, Objectlist_Attribute_name) { scripts }
and the Scopes~Alls~Gets, which are Objectlists:
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/ ... tions.html (see the 'Allxxx' and some of the 'Getxxx' section)
to get a Room's Objects:
http://docs.textadventures.co.uk/quest/scopes.html (pick the one you want, as there's some differences between them)
for examples:
foreach (object_variable, ScopeReachableNotHeldForRoom) { scripts }
~OR~
foreach (object_variable, GetDirectChildren) { scripts }
to get the Player Object's inventory (your Objectlist):
foreach (object_variable, ScopeInventory) { scripts }
to get the entire game's Objects (the lazy, HK's, way, laughs):
foreach (object_variable, AllObjects () ) { scripts }
the last concept is to add your 'check' Scripts so it looks for if the Objects in the Objectlist, have that 'identifier' (the specific Attribute or Object Type: 'inherit' Attribute), to separate them out, from the other Objects, and then lastly after that, do the desired scripts for those separated (and~or unseparated) Objects:
for example:
'GetXAttributeX' does the 2 steps in 1, otherwise, you can use the 'HasXAttributeX' but you then got to do another step with it anyways. Ask if you're confused about 'get' and~or 'has', and I'll try to explain them better.
'HasXXX' ~ 'GetXXX'
~ AND~OR ~
'DoesInherit' (for Object Types: 'inherit' Attribute)
-------
useful links:
http://docs.textadventures.co.uk/quest/ ... tions.html
Objectlists:
Scopes:
http://docs.textadventures.co.uk/quest/scopes.html
http://docs.textadventures.co.uk/quest/ ... y/got.html (shortcut instead of using 'ScopeInventory' Function)
Alls:
http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... exits.html
http://docs.textadventures.co.uk/quest/ ... ripts.html
http://docs.textadventures.co.uk/quest/ ... mands.html
Gets (Objectlists):
http://docs.textadventures.co.uk/quest/ ... jects.html
http://docs.textadventures.co.uk/quest/ ... ldren.html
Attributes:
Object Types: 'inherit' Attribute
http://docs.textadventures.co.uk/quest/ ... /type.html (Object Types)
http://docs.textadventures.co.uk/quest/ ... herit.html (an Object Types 'inherit' Attribute)
Has'es:
http://docs.textadventures.co.uk/quest/ ... ibute.html (general Attribute Type)
etc etc etc (the specific Attribute Types)
Gets:
http://docs.textadventures.co.uk/quest/ ... ibute.html (general Attribute Type)
etc etc etc (the specific Attribute Types)
-----
foreach (object_variable, AllObjects () ) {
if (GetString (object_variable, "type_of_object") = "npc") {
// scripts to do what you want with those 'npc' Objects of yours, but for this example for you:
// for having them follow you, as team members:
if (not object_variable.parent = player.parent) {
object_variable.parent = player.parent
msg (object_variable.alias + " follows you, as they're your team mates.")
}
} else if (GetString (object_variable, "type_of_object") = "non_npc") {
msg (object_variable.alias + doesn't follow you, as they're just townsfolk.")
} else {
msg ("These Objects don't have the String Attribute 'type_of_object', as they are probably furniture and like stuff.")
}
}