Virtual objects

I want to have a virtual thing, in particular a virtual silver coin. A virtual thing doesn’t exist in play, but is available for a description of it. I put the silver coin in the pouch but then I get when I examine the player’s belt pouch (being worn): “You have 12 gold coins and 4 silver coins and a silver coin.” I can’t make the silver coin’s description exist.
[1] I tried putting the silver coin nowhere, but then “x silver coin” gets a ‘can’t find such a thing’ error.
[2] I tried making the silver coin scenery, but then I couldn’t put it into a pouch worn by the player because scenery must be fixed in place.
[3] I tried concealed possession rules, but couldn’t figure out how to make that work. It is mystifying!

Any advice?

Something like this?

the Bank is a room.
a gold coin and a silver coin are in the Bank.
the description of the gold coin is "Shiny and golden.".
the description of the silver coin is "Silvery silver.".

a thing can be usable or unusable. A thing is usually usable.
the silver coin is unusable.

before doing something when the noun is unusable:
	if the current action is examining:
		continue the action;
	else:
		say "That's just for looking at.";
		stop the action.
1 Like

When I open the pouch, it lists its contents. I think this will give me nothing in the pouch, or the silver and gold coins in addition to the money statement. (The coins aren’t the only thing in the pouch.)

I got this to work but it is very kludgy:

Before listing contents of small belt pouch:
	now silver coin is nowhere;
	now gold coin is nowhere;
	
After listing contents of small belt pouch:
	now silver coin is in small belt pouch;
	now gold coin is in small belt pouch;

In effect it puts the coins out of play before listing the contents, and then back into play again. :frowning:

My solution still works if you include a pouch. Just add the player holds a pouch and put the gold and silver coins into the pouch (testing that both are listed in the pouch and that the gold coin can be interacted with normally). It’ll probably be more useful later on than your solution, since you can also apply the property to other things.

If you want something present, but not remarked upon, you could always make it part of something else (the pouch).

you’ll also need a way to head off commands, which is what hidnook is getting at. though you might want to use an “involves” construction if an indirect object is possible, i.e. “buy hat with coin”

You can declare something “part of” during action processing if you need to ship it in and out.

lab is a room.

the pouch is a container. it is held by the player.

a silver coin is part of the pouch. the silver coin is undescribed.

before doing something when the current action involves the silver coin:
	unless examining:
		say "Some things are only as good as they look." instead.
	
coin disposing is an action applying to nothing.
understand "cd" as coin disposing. 

carry out coin disposing:
	now the silver coin is nowhere;
	say "hey, where did that coin go?"

	
test me with "
x pouch /
x coin /
get coin / 
cd /
x coin
"

e: though your own solution is fine. making your own inventory rule is another approach that might have benefits. having a custom property like “unusable” could be handy too. options!

e2: I thought that “undescribed” stuck for “parts” but not for things in containers. I was wrong! So it would be a good idea to add something to prevent strange behavior.

does the player mean doing something when the current action involves the silver coin:
	it is very unlikely.
1 Like

How attached are you to making the coins genuinely virtual?

Market is a room. "A prominent merchant's stall looms over you." The player is in Market.

Metal is a kind of value. The metals are golden and silver.

A coin is a kind of object. A coin has a metal called the material. Understand the material property as describing a coin.

The purse is a container. The player carries the purse. There are four golden coins in the purse. There are twelve silver coins in the purse.

looks to me exactly equivalent to TADS3’s Unthing…

in TADS3’s definition (adv3) is:

An “unthing” is an object that represents the absence of an object. It’s occasionally useful to respond specially when the player mentions an object that isn’t present, especially when the player is likely to assume that something is present.

so, my suggestion is define the virtual object as a kind of scenery, with appropriate handling.

Best regards from Italy,
dott. Piergiorgio.

1 Like

What effect are you trying to accomplish exactly? Just an item that can be examined but not otherwise interacted with? If it’s something more complicated, could you maybe provide a mocked-up transcript of the behaviour you’re trying to create?

1 Like

Yeah, that would be helpful, I think – I almost wonder whether a simple understand statement could be what’s needed?

1 Like

Thanks, but scenery is fixed in place, and won’t be contained by a pouch carried by the player.

I don’t know how many silver/gold coins I will have, so I have nbrSilver and nbrGold counters–they are not pre-created objects. This works fine except that x silver coin gets an error message saying “You don’t see that here.” I need a coin that I can examine. I also disallow dropping a coin because that causes lots of other problems, but buying and selling works fine.

I’m going to try the “undescribed” option and see what happens.

I don’t understand what you are trying to say. I thought of “virtual” objects as my only solution.

One method that I employ often is to put the coin in some fake room, and use an after deciding the scope of the player rule to place it in scope when the player examines something in the presence of the pouch.

Well, ‘undescribed’ wont work. From the documentation:

Note that the "undescribed" property is automatically removed
from anything carried by, worn by or part of the player, 
even indirectly; and that nothing on top of an "undescribed" 
supporter will be visible in a room description, even if it 
itself is "described". 

I am not clear on what you mean by “virtual objects,” exactly.

Nevertheless, my code sample demonstrates that it is perfectly possible to create a coin type that can be golden or silver, and to have four of one and twelve of the other in the player’s possession at the beginning of the game. These are definitely “real,” non-virtual (except in the sense that everything in your game is virtual) objects.

Whether this does or does not meet your needs, only you can say! But you may find playing around with it a useful point for thinking about whether it does what you want it to do.

1 Like

I updated my post last night. The important thing is making it part of something. But I’m not sure what your goal is so maybe that’s not what you need.

https://zedlopez.github.io/i7doc/WI_3.html#section_23

Patrick,
Inform requires all objects to be created statically, before play begins. It is not like other languages that can create dynamic objects. Since I don’t know how many coins I will have–and there will probably be many–I use one gold coin so I can describe it in case the player enters: examine gold coin.
(I do the same for the silver coin. It is reasonable the player would do this when looking in his/her pouch and finds many gold and silver coins. They are not really there: I use a nbrGold and nbrSilver to keep track for bookkeeping.

Since the coins cannot show up as “objects” in my game, I called them “virtual objects”, which granted, may be a poor name selection. The best I could think of to do is the silent-movement treatment shown in the Solution box above.

Gotcha, I see what you mean. I had initially thought from your example that you knew how many total coins of each type you wanted to have in the game world.

You marked this as solved but said that your solution felt kludgy, so I hope you don’t mind if I point out that there are several money-handling recipes in section 9.4 of The Inform Recipe Book that might be adapted to fit your needs.

Since you suggested that you already have an object which represents a collection of coins, can’t you just have that object respond to an attempt to examine a single coin as well as several coins?

The player carries a privately-named proper-named thing called the silver-collection. The silver-collection has a number called the quantity. The quantity of the silver-collection is 17. Understand "silver/-- coin/coins" as the silver-collection. Understand "silver" as the silver-collection.

Rule for printing the name of the silver-collection: say "[quantity] silver coin[s]"

The description of the silver-collection is "Silver coins are small and round and shiny.[paragraph break]You have [quantity] silver coin[s]."
3 Likes
The lab is room. 

The player carries the pouch.

Backstage is a room. The silver coin is in Backstage.

The description of the silver coin is "This is the coin of the realm."

After deciding the scope of the player when the player carries the pouch:
	place the silver coin in scope;
	
test me with "x silver coin/drop pouch/x silver coin".
``
2 Likes