x container clashing with search verb

XanMag
22 Dec 2015, 23:32I have a trashcan that I have as a container object. When 'x'ed, the contents are listed, which is what I want, but how do I deal with it if the player types 'search trashcan'? The current response makes it appear the trashcan contains nothing relevant. Boo.
Is the easiest way to run a script in the look at description box that makes them go from invisible to visible AND do the same for the search verb? Should be easy enough, right? But, I want to keep them in the trashcan until the player removes them. I have a problem though... if I mark them as invisible, there is no 'make object visible' option when the container is looked at (so in that case, the objects would remain invisible). I guess I could add a command for the room titled: x trashcan; look at trashcan; search trashcan; dig in trashcan etc and make them visible AND move them to the parent trashcan.
Am I over thinking this??
There has to be an easier way, right? Thanks!
Is the easiest way to run a script in the look at description box that makes them go from invisible to visible AND do the same for the search verb? Should be easy enough, right? But, I want to keep them in the trashcan until the player removes them. I have a problem though... if I mark them as invisible, there is no 'make object visible' option when the container is looked at (so in that case, the objects would remain invisible). I guess I could add a command for the room titled: x trashcan; look at trashcan; search trashcan; dig in trashcan etc and make them visible AND move them to the parent trashcan.
Am I over thinking this??


OurJud
23 Dec 2015, 00:28No doubt talking out my rear, but can't you just run the script you're using on 'x', on a command for 'search'?
Presuming I understand correctly that you want 'x' and 'search' to do the same thing?
Presuming I understand correctly that you want 'x' and 'search' to do the same thing?
jdpjdpjdp
23 Dec 2015, 00:40What Jud said, basically. If they are meant to do the same thing, just use the same script. Just make sure that however you set it up handles the redundancy issue; that is, you want to avoid this:
x trashcan
-You found a doodad!
take doodad
-You take it.
search trashcan
-You found a doodad!
Most people remember to prevent repeating a result with the same command used twice, but you'd be surprised how often they forget when you can get the result from two different commands.
x trashcan
-You found a doodad!
take doodad
-You take it.
search trashcan
-You found a doodad!
Most people remember to prevent repeating a result with the same command used twice, but you'd be surprised how often they forget when you can get the result from two different commands.

XanMag
23 Dec 2015, 03:18So... here is my 'x at' description AND my script for the 'search' verb for a haystack.
When I use this code and I 'x haystack', it will list the needle in the objects pane and print the proper description.
Search verb code on haystack is the same as the 'x at' description and I get the "You search the haystack and you find a needle!" response but the needle does not appear on the objects pane. The haystack is a 'surface container' with objects hidden until looked at. What code do I put in the search verb script to list the 'children' of the haystack?
if (Contains (haystack,needle)) {
msg ("You search the haystack and you find a needle!")
}
else {
msg ("You rummage around in the hay but find nothing of interest.")
}
When I use this code and I 'x haystack', it will list the needle in the objects pane and print the proper description.
Search verb code on haystack is the same as the 'x at' description and I get the "You search the haystack and you find a needle!" response but the needle does not appear on the objects pane. The haystack is a 'surface container' with objects hidden until looked at. What code do I put in the search verb script to list the 'children' of the haystack?
jdpjdpjdp
23 Dec 2015, 04:34You've overcomplicated things by making the haystack a container at all. It doesn't need to be and, in this situation, I would suggest it shouldn't. Remember, just because something is inside something else IN THE GAME WORLD, doesn't mean it has to actually be inside it. How I would do it is this:
Don't make the haystack a container. Put a flag on it, "hasneedle" (set this flag in the start script at the beginning of the game). The needle should be in the room, invisible.
Your "x haystack" and "search haystack" script will be this:
Your "take needle" script will be this:
That should cover everything you want to do. Let me know if it doesn't.
Don't make the haystack a container. Put a flag on it, "hasneedle" (set this flag in the start script at the beginning of the game). The needle should be in the room, invisible.
Your "x haystack" and "search haystack" script will be this:
if (GetBoolean(haystack, "hasneedle")) {
if (ListContains(ScopeVisible(), needle)) {
msg ("There's a needle in the haystack.")
}
else {
msg ("Looking through the hay, you found a needle!")
MakeObjectVisible (needle)
}
}
else {
msg ("There's nothing else of interest in the haystack.")
}
Your "take needle" script will be this:
msg ("You take it.")
SetObjectFlagOff (haystack, "hasneedle")
AddToInventory (needle)
That should cover everything you want to do. Let me know if it doesn't.

XanMag
23 Dec 2015, 05:02I wasn't very clear. I want it to retain the properties of a container, especially the put [object] in [container]. I had trouble with putting objects in non-containers that realistically should be a container. For example, consider a lunch pail. Logically, it should hold things like a container should, but perhaps it's the only weapon available against an intruder. You want the player to get a logical response for 'put marshmallow in lunch pail' but because it will do no good, you can set the lunch pail as a limited container that can hold zero objects. Then you can print a message like 'It does make sense to put that marshmallow in the pail, but you have a feeling you need to keep that pail empty for now." The built-in 'put in' commands for containers interferes with adding 'put; put in; put marshmallow in pail' as a verb. The other option is to make a command like "put #text# in lunch pail" and give a proper response (if that works).
The problem is that the 'search' verb is not making the objects visible within the parent container. So, a code I could input to print objects in the parent parent container AND make them "takeable" would be tremendously helpful. HELP!! Argh!
God... I'm getting tired tonight.
Thanks again!
The problem is that the 'search' verb is not making the objects visible within the parent container. So, a code I could input to print objects in the parent parent container AND make them "takeable" would be tremendously helpful. HELP!! Argh!
God... I'm getting tired tonight.

Thanks again!
jdpjdpjdp
23 Dec 2015, 18:36Oh, that's even easier. I'm going to stick to the haystack/needle example. Make the haystack a container with the needle inside it, but invisible (and takeable). The haystack should be open, and "List contents when looked at".
"x haystack"-
"search haystack"-
That should do it.
"x haystack"-
MakeObjectVisible (needle)
msg ("It's a haystack.")
"search haystack"-
do (haystack, "look")
ListObjectContents (haystack)
That should do it.

XanMag
23 Dec 2015, 19:37Thanks again! You're proving yourself quite valuable!! 
