Rookie bugs in game? (Use / Give)

Hey all,
After a good while of thinking up a story script, I finally am working on my very very very first game ever. Because of that I am using the GUI editor both offline and online - for learning purposes and testing - and not the code view just yet. (helps me to visualize how the Quest game "thinks").

I did run into a few thingies though, not sure if they're bugs or if I am just not seeing the answer.

After I make the player collect a few items and solve the first few puzzles, they enter a secret area. They have to start a fire with collected items there. There is no (visible) exit to this area. What I've found is: the player can only type the command, as the button 'Use' only echos "You can't use it this way". By typing the command, it works flawless. In any other area, the Use button does what it is supposed to do. Does anyone know why the game behaves like this?

A bit further in the game, the player has to Give an item to another character. I can add a verb for sure, but it never shows up when I test play the game. The Use/Give tab on the character (use other item on this) didn't do it. The Use/Give tab of the item itself doesn't do much either.

Did I run into some bugs here, or is the answer so simple I overlooked it?

If anyone would like to see what I mean instead of guessing rookie mistakes, please look at the "learning game":
(I hope you like the direction I'm going in with this game idea!)

Thanks in advance to those that answer!

I don't have time to play through the game to test it, but I'm looking at the code now.

It looks to me like the command should be "use ferro rod on (any object)"? Is that the one that's failing when you use the links?

Also, you wrote:

only echos "You can't use it this way".

Do you mean "You can't use it that way."?

I can't figure out why that should happen. That's a default message which is supposed to appear if you use it on an object that isn't in the dictionary; and shouldn't happen for the Ferro rod because it has a selfuseanything script.

A bit further in the game, the player has to Give an item to another character. I can add a verb for sure, but it never shows up when I test play the game.

Do you mean you added it to the inventoryverbs list on the object tab?

I notice that the object "hand full of mushrooms" has everything set up so it can be given to another character, but the displayverbs and inventoryverbs lists (which just control which buttons are displayed) are set to "Look at;Take;Eat" and "Look at;Use;Drop;Eat" respectively.

This means that the player can type the command "give mushrooms" or "give mushrooms to soldier" and it will work, but the "Give" button won't appear.

If you want the button or link to appear, you need to add it to the appropriate list at the bottom of the object's "Object" tab.

(again, just by skim-reading your code, as I don't have time to look through it in any more detail. So I could be wrong here)

Thank you for your reply, mrangel, This got me stuck and changing my original storyline for a few times now.
As "selfuseanything" is a term you can't see in the GUI Editor, I have no idea what you are on about, sorry for that... I've been playing with this for just a few days...

I do recognize your name on this forum, so I sort of know you're a bad-ass coder... I hope you find the time to help me out here... Again, GUI only, not into the coding screen yet... (still learning how to do this...)

selfuseanything is the attribute which is set by the script labelled "Use on any other object" in the Use/Give tab. An object with that script set should run it instead of displaying the "You can't use it that way." message; so I can't see why you would still be seeing it.

I "solved it" by making the player type the command, but still can't figure out how selfuseanything doesn't work properly...

OK, I see your problem.

There's a reason I asked if "use Ferro rod on sticks" was the command that wasn't working. I tried it now, and that seems to work fine whether I type the command or use the GUI.

One that doesn't seem to work is "use pot on fire".
That's because the object's full name is "pot with water". When you click the "Use" button, Quest enters the command "Use pot with water".

This matches the pattern for the command "useon", whose pattern is use #object1# with #object2#.
It attempts to match the string "pot" to object1, and as you only have one object with "pot" in its name, it assumes you mean the object "pot with water".
Then it attempts to match the string "water" to object2, and as you only have one object with "water" in its name, it assumes you mean the object "pot with water".

So clicking the "use" button is equivalent to the command: "use pot with water on pot with water".

The pot with water is set up in the "Use / Give" tab to do the same thing if you use it on its own (for example, "use pot"), or if you use it on the fire (eg "use pot on fire"). It will even work if the player types "use pot with water on small fire".

It's only a problem for the command "use pot with water" because of the object name.
I'd recommend that you name the object "pot of water" or something similar. Objects whose alias includes the words "on", "in", "with", or "to" can sometimes cause problems because it thinks the player has specified 2 objects, and so doesn't ask for the second one.

ah, another issue with the complexity of parsing and its coding, and of the naming (and/or alias) of Objects and the Command's pattern expression, and the user's input during game play...

good job, mrangel in finding/solving this issue as a parsing issue!

If you want it to work when an object has "with" or "on" in its name, here's a quick workaround. The parser thinks you've typed "USE pot with water WITH pot with water". So in the list of objects you can use this on, create an extra option for "pot with water"; and have that option go back to the single "USE object" command.

In code view, it would look like:

  do (use, "script", QuickParams ("object", this))

That will make the button work as it would for any other object; whether that's a "Use (on its own)" script, or displaying a menu of objects to use it on.

It's worth noting that some of your scripts don't do sufficient checking. For example, entering the command "use pot" will give you boiled water even if you don't have the fire. And using the Ferro rod on anything will create a fire in the secret room as long as the player has the knife. If the player takes the Ferro rod, leaves the secret area, and then uses the Ferro rod on the paracord, the sticks will disappear (even if the player wasn't carrying them) and a fire will appear in the secret area (even if the player isn't there).

I'd recommend getting into good habits with the structure of the command. I find that it often makes the code easier to follow if you put all the failure cases first, so that the message for each is right next to the corresponding 'if'. So for your 'use Ferro rod on sticks' command, the structure would look like (not actual code):

  • if (player isn't in the right room)
    • Tell the player this isn't a good place to build a fire
  • else if (player doesn't have the knife)
    • Tell the player it doesn't work
  • else
    • We've got past all the 'if' conditions, so everything is fine
    • Display a message that it worked and make the fire appear

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