Checking if an object is not in the current room or a certain room?

Is there a command I can use to check if an object is in a certain room? Also is there a command to check if a object is not in the current room?
I was wondering if "object not reachable" would be a suitable command to check if the object is not in the current room?


you can do so via the 'Scope/All' Functions:

https://docs.textadventures.co.uk/quest/functions/#scope

with using the 'ListContains' and/or 'DictionaryContains' 'Scope/All' Functions:

https://docs.textadventures.co.uk/quest/functions/listcontains.html
https://docs.textadventures.co.uk/quest/functions/dictionarycontains.html

there's also directly the 'Contains' Function:

https://docs.textadventures.co.uk/quest/functions/contains.html

you can also use the built-in 'parent' Object (reference/pointer) Attribute:

https://docs.textadventures.co.uk/quest/attributes/parent.html

and if you just want to directly check the inventory (inventory = contained within the current active Player Object / game.pov), there's the 'Got' Function:

https://docs.textadventures.co.uk/quest/functions/corelibrary/got.html


But I'm still not certain in how to check if an object is in a certain room.
eg If fish is in river then print "You must catch the fish first"

Brian


if (Contains (river, fish)) {

Note that if the player is in the "river" room, a fish in their inventory will be in that room. If you want to check that an object is in a specific place but not held by the player, you would need to explicitly check this:

if (Contains (river,  fish) and not Got (fish)) {

If the fish starts in the river, an alternative would be checking if the fish has been moved:

if (fish.hasbeenmoved) {

Hi mrangel.

That hasbeenremoved test is very useful as I can use it to test if an object has been used in the game.
At the moment I've been making an object invisible and then making the object visiable when used in the game such as the player finding a new object. It also saves me having to set a flag so that the score does not get increased twice if the player repeats some action.

Is there also a hasnotbeenremoved test in Quest?

When checking if the
Will the if (Contains (river, fish)) { fail if the fish is in the same room as the player but not in the players inventory?
I have been using 'if object is reachable' to test for the object being in the same room but it might also pass if the player is carrying the object.
It's unusual that Quest does not have a specific command to test if an object is only in the current room (and not in the inventory).


Is there also a hasnotbeenremoved test in Quest?

if (not fish.hasbeenmoved) {

You can reverse any test by putting "not" in front of it.

Will the if (Contains (river, fish)) { fail if the fish is in the same room as the player but not in the players inventory?

Contains(river, fish) will be true if the fish is inside the river., or inside something (such as the player) which is in the river. It tests the location of the item and nothing else.

ListContains (ScopeReachable (), fish), on the other hand, tests if the player can reach the fish. This means that it's in the same room as the player (or in the inventory), and is visible, and is not in a closed container.

Quest does not have a specific command to test if an object is only in the current room (and not in the inventory).

if (ListContains (ScopeReachableNotHeld (), fish)) {

Many of the ScopeReachable functions also have a ScopeVisible version - because an object in a transparent closed container is visible but not reachable.

These functions aren't all in the GUI because the list would be impossibly large.


I have a list of commands from the Quest on-line help but I can't see the 'hasobjectmoved' anywhere in the list. Is this a recent command added to Quest?
Apart from the Quest Help is there somewhere I can find a complete list of Quest commands?


You're right, hasbeenmoved isn't in the list of attributes in the documentation. I think it was added in a recent version (5.8 maybe) and the docs aren't always updated.

The list on there is pretty comprehensive. I don't think there's anywhere better to look, unless you read the code itself.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums