giving items to NPCS

scottskeptic
I've been having an issue with this for the past two days. I'm using the web version of quest, not the windows version, so the tutorial seems to be slightly different and I can't quite grasp it. I am attempting to give an item to a character in the game. I have gone to the character settings, activated the use/give, clicked on give (other object) to this, selected my object, and typed in the message I wanted to appear when giving the character the item, but nothing works. Ideally, I am trying to make it that you have to retrieve items for this character, and everytime you give him an item, a different message appears. Does anybody know how I would go about doing this?
(Bonus question; how do object flags work?)

XanMag
Here is a quick give object to NPC code from my tutorial game I am working on.

Just start a new game and paste the following code AFTER the </game> in the code view and before the </asl> at the end of the code view (click the little button at the top of the editor that looks like a note card).

Delete all code between those two markers I mentioned. That way you can view it in the GUI editor panels and see what I did.

I'll put together the flag tutorial for you in just a bit. Ask if you have questions!

  <object name="standard NPC room">
<inherit name="editor_room" />
<alias>standard NPC ask and tell room</alias>
<object name="George the Puzzler">
<inherit name="editor_object" />
<inherit name="namedmale" />
<feature_usegive />
<give type="scriptdictionary">
<item key="jigsaw piece A">
msg ("George takes the puzzle piece and gives you a smile in return!")
RemoveObject (jigsaw piece A)
</item>
<item key="encrypted box">
msg ("\"Ah!\" George replies. \"A classic puzzle box! Thank you so much!\"")
RemoveObject (encrypted box)
</item>
<item key="crossword">
msg ("\"Oh, how very excellent! I love crosswords. Thank you so much!\"")
RemoveObject (crossword)
</item>
</give>
<look>If you give George some puzzles to work on, he may be able to help you!</look>
</object>
<object name="jigsaw piece A">
<inherit name="editor_object" />
<look>It just looks like a jigsaw piece. Maybe you should give it to George?</look>
<take />
</object>
<object name="encrypted box">
<inherit name="editor_object" />
<look>It's one of those boxes that you have to move the parts of in different directions to open. Maybe George the Puzzler would like to have this?</look>
<take />
</object>
<object name="crossword">
<inherit name="editor_object" />
<look>It's a crossword puzzle. I bet George would like to try and solve this?</look>
<take />
</object>
<object name="Magoo">
<inherit name="editor_object" />
<inherit name="editor_player" />
<look>You're Magoo. A simple being trapped in a test game.</look>
<attr name="pov_look">You're Magoo. A simple being trapped in a test game.</attr>
</object>
</object>


Let me know if it works for you!

XanMag
Flag Room:

I have added another room to my tutorial game. Forgive me, I did this really quick so if you notice any errors please let me know so I can fix it. If you got the tutorial room above to work, you can copy and paste the following code immediately AFTER the last </object> in that code and it should work. Or, you can copy-paste over a brand new game as instructed above.

  <object name="flag setting unsetting room">
<inherit name="editor_room" />
<enter type="script">
</enter>
<description><![CDATA[In this room, you will hopefully master flag setting and unsetting!<br/><br/>There are flags in the room. Look at them. To raise them, type "raise flag (of your choice)". To lower them, type "lower flag (of your choice)".<br/><br/>This room assumes you have knowledge of 'If'/'Then' statements. If you don't type "if then help".<br/><br/>Notice that when you raise a flag, I have set that particular flag on that flag object to 'raised'. If you look at the particular flag, I have used an 'If'/'Else' script to give a different viewpoint of the flag. The country's flag with a flag titled 'raised' will look as though it is standing erect. When you "lower" the flag, I unset that country's flag 'raised' so it appears in the look at description as on the ground.]]></description>
<alias>flag setting and unsetting room</alias>
<object name="The Flag of England">
<inherit name="editor_object" />
<look type="script">
if (GetBoolean(The Flag of England, "raised")) {
msg ("You behold the proud English flag rippling in the breeze. To lower the flag, simply type 'lower' flag.")
}
else {
msg ("The English Flag and its pole rest on the ground. To raise the flag, simply type 'raise' flag.")
}
</look>
<alt type="stringlist">
<value>english flag</value>
</alt>
<raise type="script"><![CDATA[
msg ("You lift the English Flag from the ground and nestle the pole it is tied to neatly into the ground. The English Flag is now raised!<br/><br/>In code, we have set flag 'object' 'The Flag of England' 'flag name' \"raised\"")
SetObjectFlagOn (The Flag of England, "raised")
]]></raise>
<lower type="script"><![CDATA[
msg ("You lift the English Flag from the earth and rest it gently on the ground.<br/><br/>In code, we have Unset flag 'object' 'The Flag of England' 'flag name' \"raised\".")
SetObjectFlagOff (The Flag of England, "raised")
]]></lower>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="The Flag of the USA">
<inherit name="editor_object" />
<raise type="script"><![CDATA[
msg ("You lift the American Flag from the ground and nestle the pole it is tied to neatly into the ground. The Stars and Stripes is now raised!<br/><br/>In code, we have set flag 'object' 'The Flag of the USA' 'flag name' \"raised\"")
SetObjectFlagOn (The Flag of the USA, "raised")
]]></raise>
<lower type="script"><![CDATA[
msg ("You lift the American Flag from the earth and rest it gently on the ground.<br/><br/>In code, we have Unset flag 'object' 'The Flag of the USA' 'flag name' \"raised\".")
SetObjectFlagOff (The Flag of the USA, "raised")
]]></lower>
<look type="script">
if (GetBoolean(The Flag of the USA, "raised")) {
msg ("You behold the proud American flag rippling in the breeze. To lower the flag, simply type 'lower' flag.")
}
else {
msg ("The American Flag and its pole rest on the ground. To raise the flag, simply type 'raise' flag.")
}
</look>
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<object name="German Flag">
<inherit name="editor_object" />
<look type="script">
if (GetBoolean(German Flag, "raised")) {
msg ("You behold the proud German flag rippling in the breeze. To lower the flag, simply type 'lower' flag.")
}
else {
msg ("The German Flag and its pole rest on the ground. To raise the flag simply type 'raise' flag.")
}
</look>
<raise type="script"><![CDATA[
msg ("You lift the German Flag from the ground and nestle the pole it is tied to neatly into the ground. The German Flag is now raised!<br/><br/>In code, we have set flag 'object' 'German Flag' 'flag name' \"raised\"")
SetObjectFlagOn (German Flag, "raised")
]]></raise>
<lower type="script"><![CDATA[
msg ("You lift the German Flag from the earth and rest it gently on the ground.<br/><br/>In code, we have Unset flag 'object' 'German Flag' 'flag name' \"raised\".")
SetObjectFlagOff (German Flag, "raised")
]]></lower>
<usedefaultprefix />
</object>
<object name="Magoo">
<inherit name="editor_object" />
<inherit name="editor_player" />
<look>You're Magoo. A simple being trapped in a test game.</look>
<attr name="pov_look">You're Magoo. A simple being trapped in a test game.</attr>
</object>
<command name="I IE E help cmd">
<pattern>if then help</pattern>
<script><![CDATA[
msg ("An 'If' script is likely the most useful script in the game.<br/><br/>Simply put, you set a condition with the 'If' script. In the GUI change the 'expression' box to whatever condition you want to set. In this room, I have set an 'If' object has flag. Choose the object you want to conditionalize. I chose 'German Flag'. Then name the flag. In this room, I chose the flag name 'raised'.<br/><br/>Now, choose what happens next with the 'Then' script. Click 'add new script'. In this room, I set the description of the raised flag as a 'print a message' script. In this box I described the German Flag as if it had been raised.<br/><br/>In the 'Else' box, you choose what happens if the condition is NOT met. So, in this room, when the German Flag did NOT have the 'raised' flag name active, I described it as lying on the ground.<br/><br/>If you are interested in how to use the 'Else If' part of this script, visit the If Then room!")
]]></script>
</command>
</object>


If you aren't sure of using the if/else script, there is a short and hopefully helpful tutorial in this room for that, too. Just type "if then help".

Again, your feedback here is important as I continue working on my tutorial game. Thanks and I hope this helps you!

scottskeptic
Thank you very much for the reply! However I am very far into the game I have created and was wondering if it was possible to use/give items without having to create a new game? Also if I did use the code you gave me, would I have to insert the name of every item before starting to work on the game? I apologize if some of these questions sound silly, I have never coded before or done anything of the sort.

XanMag
I only suggested in the code I gave you to copy-paste my code into a new game so you could see exactly as I did it in the GUI editor. Then you could use that as a template to do whatever you wanted in your own game.

Based on what you said you did, I can't really tell why it's not working. If you could post that bit of code on here it might be helpful. Another option is to publish your game privately, share with me the link and let me test it. Or, compress the game file and link it to a post and I can test it that way. From the sounds of it, it seems like what you've done should work.

Let me know!

scottskeptic
That sounds great, thank you! Where would I find the code on the web version of quest?

Pertex
I think you just want to do this:
give.png


give2.png


I did it in the offline editor but it's the same in the online version

scottskeptic
I did exactly that as well! It wouldn't work. I'm guessing it has to do with the fact that im using the web version, but the use/give feature seems to be the same so I don't know why it won't work.

XanMag
Your best bet (at least to have me look at it) is to compress your game file and attach it to this forum or in a pm to me. Find your .aslx file on your computer, right click it, send to compressed (zipped) folder. Attach the zipped file here so I/we can take a look at what you are having problems with. From what I hear in your post, it should work.

When you say "nothing happens"... does that mean you type 'give apple to man' and you get a blank response? Does the game continue as if you didn't type anything at all?

Anyway, if you can attach it, or at least the code for the game, we might be able to help a little more. Compressing the file and attaching it to a post is a lot easier than making sure you copy the correct code, so I suggest trying that first. If for some reason, you don't want to attach the entire game zipped, I'll help you select the correct code to post here.

Good luck!

Pertex
I tested it with the webversion and it's working. And you really used the 'move object' script command?

scottskeptic
I couldn't find any files on my computer to to send to you so I just took screenshots instead. And when I say nothing happens, i mean that it says "You can't give this."
Screen Shot 2015-08-11 at 4.18.45 PM copy.jpg
Screen Shot 2015-08-11 at 4.07.26 PM copy.jpg

Pertex
Strange! In "MyGames" you should see your game like this:
download.png


Could you click "download" there and post your game here, then?

EDIT:
I only get the message "You can't give this." when I insert the command "give orange pistol". But when I use "give orange pistol to sheriff pepper" it works.

scottskeptic
Wow thank you so much! I can't believe the problem was as simple as specifying who to give it to. It works now that I type in "give orange pistol to sheriff pepper." Is there any chance you could help me with the other part of my problem? I am trying to figure out how to permanently change Sheriff Pepper's "talk to" text after the item has been given to him.

XanMag
After your script to move object orange pistol to object sheriff pepper, simply click add new script. Scroll down to Variables and click set object flag.

Then set flag on object sheriff pepper and give the flag a name like gun.

On object sheriff pepper, add a verb 'talk to; speak to'. Then run a script for that verb. Add an 'If' script. For the 'If' part, add If 'object has flag' 'object' 'sheriff pepper' 'flag name' 'gun' ... Under the 'Then' part of that script add new script and select 'print a message'. Have sheriff pepper say whatever you want him to say AFTER he has been given the gun. At the bottom of this 'If/Then' script click on 'Add Else', then 'add new script'. Select 'print a message' and have sheriff pepper say whatever you want him to say BEFORE he has been given the gun.

scottskeptic
It works perfectly, thank you! One last question; if I wanted to have a second item afterwards, say a yellow pistol, that when given to sheriff pepper would create a new text, how would i go about making sure the other two texts don't pop up when the second is given? and a third item after that?

XanMag
Hmmm... I think it kind of depends on how the process of giving things to Sheriff Pepper goes. If it is sequential, it is easier. If the items you want to give can be given in any order, it gets a little trickier.

Let's say you have items A, B, and C that you want to give Pepper. If they must be given to him sequentially (A,B, then C), I would use flags. I'd follow these steps.
1. On the give item A to pepper script, add a flag and call it one (or whatever). My pic below is from my tutorial game. Obviously you would replace Sheriff Pepper with my Frank =) and object one with whatever your object is.
Screenshot (3).png

2. On the give item B to pepper script, Add an If - Pepper has flag name one, then print a message and add a flag and call it two AND unset flag one on pepper. In the Else box add a print a message script and instruct the player that the item can't be given yet. Evidently I can't add another screenshot to this post. lol

3. On the give item C to pepper script, Add an If - Pepper has flag name two, then print a message and add a flag and call it complete AND unset flag two on pepper. In the Else box add a print a message script and instruct the player that the item can't be given yet.

4. On your 'talk to; speak to' verb for pepper, add an If script. If pepper has flag one, print a message. Else if pepper has flag two, print a (different) message. Else if (again) pepper has flag complete, print a (final) message. Else print a (introductory (no items given yet) message.
Screenshot (1).png

Screenshot (2).png


You can add as many Else If scripts as you need.

If you are able to give him the items in a random order, that is a bit more difficult and I will walk you through it if you need that.

XanMag
Pic for step 2.
Screenshot (4).png


Pic for step 3.
Screenshot (5).png


Let me know if you have questions.

XanMag

scottskeptic
The items were indeed sequential, so this is perfect! I really appreciate all the help, you've made my game creating experience much easier. Thank you again!

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

Support

Forums