Problem with drop script

Forgewright
12 Jul 2015, 17:24If you take a look at the uploaded game, I have a script for picking up sand and it works great. I move clawfuls of sand from a dummy room to the player inventory. However when I tried the same type of script on dropping of the sand I get "You don't have it". I don't want the player to have type "Clawful of sand" or have to use the inventory panel drop box. I want all the options. And of course the dreaded " Which sand do you mean" list will pop up.
Is it necessary to change the games DoDrop function. I'm not sure why my drop script for sand is not following the script. I assume the coding is first checking to see if I have the sand which I don't. I don't want to change the game drop script for everything I drop.
Any ideas?
Is it necessary to change the games DoDrop function. I'm not sure why my drop script for sand is not following the script. I assume the coding is first checking to see if I have the sand which I don't. I don't want to change the game drop script for everything I drop.
Any ideas?
adammadam
12 Jul 2015, 17:58I'm not sure if this is useful but one idea I had is maybe you could make it a hidden attribute and an object also, the first time the player picks up sand they get a clawful of sand and their hidden sand attribute becomes +1, the second time they don't get any more objects but their sand attribute becomes +2, but this wouldnt change how it appears in the inventory, but could allow you to make the player need a certain amount to do certain things still. And then I guess when the player types drop sand, you could make them drop the sand object and set their sand attribute to 0.

jaynabonne
12 Jul 2015, 22:15The problem is that Quest does object name resolution in a strictly syntactic way, without paying attention to any sort of semantic information. (I'm not dissing Quest - it's not an easy problem to solve.) It will go through the same process for "drop" as it does for "take", and this object name resolution happens long before the verb or command kicks in. So even changing DoDrop won't fix the problem - the disambiguation menu happens before it even gets to the command.
Basically, if you give the name "sand" to your "clawful of sand", then you have two sand objects in the same room, period, and there's no way around that short of hacking the parser to special case this situation (in a way I haven't explored, so I can't offer any insight yet).
The only suggestion I have is to have the sand in the room disappear (or become hidden) when you pick it up. Then the sand in your inventory will take precedence, which means you need to have all the same behavior for that sand (e.g. the look text) as it does when in the room. So you can still look at the sand and all that, but it's now looking at the one in your inventory. If it has the same description, it will be indistinguishable behavior to the player. I did a test where, when you pick up the clawful of sand, it sets the "visible" flag of the floor sand to false, as well as adding the alias "sand" to the clawful one. It might be worth a try, just to see if it's close to what you want done.
Basically, if you give the name "sand" to your "clawful of sand", then you have two sand objects in the same room, period, and there's no way around that short of hacking the parser to special case this situation (in a way I haven't explored, so I can't offer any insight yet).
The only suggestion I have is to have the sand in the room disappear (or become hidden) when you pick it up. Then the sand in your inventory will take precedence, which means you need to have all the same behavior for that sand (e.g. the look text) as it does when in the room. So you can still look at the sand and all that, but it's now looking at the one in your inventory. If it has the same description, it will be indistinguishable behavior to the player. I did a test where, when you pick up the clawful of sand, it sets the "visible" flag of the floor sand to false, as well as adding the alias "sand" to the clawful one. It might be worth a try, just to see if it's close to what you want done.

Forgewright
13 Jul 2015, 04:55Thanks to both of you. I want to try every way to find out how things like this work. Hell I was proud of myself getting all the bugs out of the :take" script. Then "wham", the "drop" kick in the nads. Is there a "taken" attribute with a Boolean value during gameplay that could be changed from false to true for sand? Either this or the game just checks the sand parent.

XanMag
13 Jul 2015, 06:16My solution (if I understand your problem correctly)...
would be to name the 'sand' object something like 'sediment' or 'detritus' or 'worn path' and forget the whole problem all together. But, you obviously would know that so I don't think that is what you want.
Or... and I haven't tried this (edit: yes I did... see below)... could you add a command to the room like 'look at sand; x sand; look at floor; etc; etc;' and add the proper print message script (and not have an actual 'object' named 'sand' in there at all)? This could give you a descriptive feedback you'll want. Also, could you add a command like 'get sand; get floor; take floor; etc; etc' and add a script to that which moves 'clawful of sand' to your inventory from your 'holdingroom''? The add a script which moves 'drop sand' to 'holdingroom' again. You could just add to the in-room description the seeming presence of the sandy/dirty floor so the player recognizes it as relevant. Just thinking out loud... I've never tried to add a command for built-in Quest commands like take and drop.
^Of course, you would have to throw in your 'If' commands to your take/drop command to check if player is carrying sand already.
Got bored and just tried it out. Seems like the above works correctly. If this were my game, I'd be happy with the results!
Good luck!
Happy Gaming.
XanMag
would be to name the 'sand' object something like 'sediment' or 'detritus' or 'worn path' and forget the whole problem all together. But, you obviously would know that so I don't think that is what you want.
Or... and I haven't tried this (edit: yes I did... see below)... could you add a command to the room like 'look at sand; x sand; look at floor; etc; etc;' and add the proper print message script (and not have an actual 'object' named 'sand' in there at all)? This could give you a descriptive feedback you'll want. Also, could you add a command like 'get sand; get floor; take floor; etc; etc' and add a script to that which moves 'clawful of sand' to your inventory from your 'holdingroom''? The add a script which moves 'drop sand' to 'holdingroom' again. You could just add to the in-room description the seeming presence of the sandy/dirty floor so the player recognizes it as relevant. Just thinking out loud... I've never tried to add a command for built-in Quest commands like take and drop.
^Of course, you would have to throw in your 'If' commands to your take/drop command to check if player is carrying sand already.
Got bored and just tried it out. Seems like the above works correctly. If this were my game, I'd be happy with the results!

Happy Gaming.
XanMag

jaynabonne
13 Jul 2015, 06:58Forgewright: yes, it uses the parent attribute to determine whether the parent is currently holding an item or not.
XanMag: That's actually a good idea! By providing an overriding, specific command, you can take control over what happens. You do have to implement it
, but it is a workable approach to the problem.
XanMag: That's actually a good idea! By providing an overriding, specific command, you can take control over what happens. You do have to implement it


Forgewright
13 Jul 2015, 07:47XanMag, I'm about 4 or 5 months into coding Javascript. I will spend the next few days trying out your remedy. Or.....If you still have the script, you could hook a brother up with a copy. Otherwise I'll be adding 6 more posts to this thread crying the blues and begging for help..... 


XanMag
13 Jul 2015, 12:40
Forgewright
14 Jul 2015, 05:58I ran the game without reading the code and was happy with the results you got. Then when I saw how simple a fix it was, Welll let's just say I was embarrassed. Having all the tools and the skill to know how and when to use them is the trick. You can build a bridge to the moon or just say you did.
or something like that......
or something like that......