how do i exchange items between npc and player
rocket20001010
18 Feb 2016, 18:08i dont know how to exchange items between an npc and player e.g give npc money, the npc then makes food available. if anyone can help me i would be very grateful



HegemonKhan
18 Feb 2016, 19:06here's a link:
viewtopic.php?f=18&t=5559
(near the bottom is when I specifically get into Attributes and how to do barterting: "buying" and "selling")
this may be a bit difficult, if you're new to quest, and especially if you've never done coding, as it involves scripting, which takes a while to learn.
ask if you got any questions or need help with anything
viewtopic.php?f=18&t=5559
(near the bottom is when I specifically get into Attributes and how to do barterting: "buying" and "selling")
this may be a bit difficult, if you're new to quest, and especially if you've never done coding, as it involves scripting, which takes a while to learn.
ask if you got any questions or need help with anything

XanMag
18 Feb 2016, 19:47Also, rocket... if you want simple exchanges, I can certainly help with that when I get home. If you'll want a more complex system, you can follow the guides in the link supplied by HK or check out the 'Libraries' forum.
If you want to take a look at the 'Quest - Tutorials and Templates' game guide (it's still on the homepage), you can play it and enter the NPC hallway and look at the 'standard NPC' room and the 'Take Items from NPC' room to see how you can do it. Just type 'explain' in those rooms for a walk-through on how to achieve what you are asking. Also, the .aslx file is available for download in the 'Game Announcement' forum. If you download that and look at those rooms, you can take your needed pieces from the GUI and use them as templates. REMEMBER: this is meant to be a simple exchange. If you want complex buying and selling with many (or at least several) items, you'll want to check out the Libraries.
Good luck.
If you want to take a look at the 'Quest - Tutorials and Templates' game guide (it's still on the homepage), you can play it and enter the NPC hallway and look at the 'standard NPC' room and the 'Take Items from NPC' room to see how you can do it. Just type 'explain' in those rooms for a walk-through on how to achieve what you are asking. Also, the .aslx file is available for download in the 'Game Announcement' forum. If you download that and look at those rooms, you can take your needed pieces from the GUI and use them as templates. REMEMBER: this is meant to be a simple exchange. If you want complex buying and selling with many (or at least several) items, you'll want to check out the Libraries.
Good luck.

jaynabonne
18 Feb 2016, 20:22One thing to keep in mind is that, while the interaction between the player and NPC on the surface appears to the player as an exchange, internally you don't have to make it so. In other words, as long as it looks like the transaction has taken place, you don't need to worry about things like the NPC actually receiving money or actually making a decision based on that money. It just needs to "make the right noise" in the output text.
A simple solution could be a command like this:
It might seem a bit lame. It might not be what you want this time. But sometimes, it's all you really need.
A simple solution could be a command like this:
<command>
<pattern>give money to bartender</pattern>
<script>
msg ("He slips the money into the cash register. \"Here you go,\" he says, handing you your martini.")
AddToInventory (Martini)
</script>
</command>
It might seem a bit lame. It might not be what you want this time. But sometimes, it's all you really need.

XanMag
18 Feb 2016, 21:04jaynabonne wrote:It might seem a bit lame. It might not be what you want this time. But sometimes, it's all you really need.
I tell my wife that all the time...

jaynabonne
18 Feb 2016, 22:08Ba dump bump! lol
rocket20001010
19 Feb 2016, 07:21@XanMag
could you give me the link to the "Qust tutorial and templates" game guide because i cant find it
could you give me the link to the "Qust tutorial and templates" game guide because i cant find it
HegemonKhan
19 Feb 2016, 07:51here's a link, in the 'Game Announcements' forum-board:
viewtopic.php?f=5&t=5940
I'll let XanMag give the link for his published tutorial game
viewtopic.php?f=5&t=5940
I'll let XanMag give the link for his published tutorial game
rocket20001010
19 Feb 2016, 09:22ok but do i have to download the game or do i play it online

XanMag
19 Feb 2016, 11:03You can play it in your browser. If you do this, you will be relying on the 'explain' command only while in game, which I hope is adequate enough. In the game announcement forum, you can find the .aslx file. If you choose to download that, you can open it up with Quest as if it is your own game. By doing so you can see how solution look in the editor. For me, that is always really helpful. But, by just playing the online game, you can go to the NPC room and type 'explain' in that room to get a step by step explanation on how that room was achieved.
Let me know if you have questions!
Game link: http://textadventures.co.uk/games/view/ ... -templates
Let me know if you have questions!
Game link: http://textadventures.co.uk/games/view/ ... -templates
rocket20001010
19 Feb 2016, 12:32@XanMag
i have learnt how to give items to NPC's but how do i make them give me something back e.g give money, thn they give food
i have learnt how to give items to NPC's but how do i make them give me something back e.g give money, thn they give food
rocket20001010
19 Feb 2016, 13:06@XanMag
i have learnt how to make simple trades between NPC's and player. thanks for the help but is it ok if i can ask more questions if i need to?
i have learnt how to make simple trades between NPC's and player. thanks for the help but is it ok if i can ask more questions if i need to?

XanMag
19 Feb 2016, 15:39Absolutely.
I'm at work but will offer this quick solution until a more detailed one is needed. Since I am not looking at the editor right now, forgive me if this from-memory solution isn't exactly right. =)
If it is something that you just can buy one of...
This will work, but it is based on a barter system - you trade something for an item; you trade something else for a different item, etc.
1. I would make your NPC a surface container. Change the prefix to 'He is carrying'. You'll find this on the Features tab (container, change drop down to surface).
2. When you look at the NPC, it will say 'He is carrying..." You can change this prefix so that the wording sounds right for what he is selling. I think you can type in something like 'On his table, you see' or 'His wares include' Mess around with that until you get an output that you like.
3. Create whatever objects you want him to 'sell' and add them to the NPC object. Make sure they cannot be taken (untick the 'object can be taken'). Copy-paste those objects into a 'dead room'. Make sure these objects are 'able to be taken'!
4. If you have an object that you want to give him in exchange for what he is selling, go to the 'give' tab of that object and select the NPC name. Run the script 'move object to inventory' [bought object2]. boughtobject2 is the copy-pasted object of his wares.
5. If you do not want the object to be buyable again (which I suspect you wouldn't), use a 'remove object script' to remove that object from the game.
Now... if you want a more complex system where you are using a certain number of coins to buy a range of different things, then I can help with that too, but it will require setting up attributes - which gets a little trickier and will require me to be sitting in front of my home computer.
I will add a 'vendor/merchant' to my tutorial now though, because I think it is a good idea.
Remember, this is a basic outline. There are some other things you'll run into that are problematic, but this should give you an idea on how to set it up. I can make a better system when I'm at home and have time to iron out the details.
Let me know if you want tips on how to set the more complex trading system.
rocket20001010 wrote:...how do i make them give me something back e.g give money, then they give food
I'm at work but will offer this quick solution until a more detailed one is needed. Since I am not looking at the editor right now, forgive me if this from-memory solution isn't exactly right. =)
If it is something that you just can buy one of...
This will work, but it is based on a barter system - you trade something for an item; you trade something else for a different item, etc.
1. I would make your NPC a surface container. Change the prefix to 'He is carrying'. You'll find this on the Features tab (container, change drop down to surface).
2. When you look at the NPC, it will say 'He is carrying..." You can change this prefix so that the wording sounds right for what he is selling. I think you can type in something like 'On his table, you see' or 'His wares include' Mess around with that until you get an output that you like.
3. Create whatever objects you want him to 'sell' and add them to the NPC object. Make sure they cannot be taken (untick the 'object can be taken'). Copy-paste those objects into a 'dead room'. Make sure these objects are 'able to be taken'!
4. If you have an object that you want to give him in exchange for what he is selling, go to the 'give' tab of that object and select the NPC name. Run the script 'move object to inventory' [bought object2]. boughtobject2 is the copy-pasted object of his wares.
5. If you do not want the object to be buyable again (which I suspect you wouldn't), use a 'remove object script' to remove that object from the game.
Now... if you want a more complex system where you are using a certain number of coins to buy a range of different things, then I can help with that too, but it will require setting up attributes - which gets a little trickier and will require me to be sitting in front of my home computer.
I will add a 'vendor/merchant' to my tutorial now though, because I think it is a good idea.
Remember, this is a basic outline. There are some other things you'll run into that are problematic, but this should give you an idea on how to set it up. I can make a better system when I'm at home and have time to iron out the details.
Let me know if you want tips on how to set the more complex trading system.
rocket20001010
19 Feb 2016, 17:55@XanMag
thank you i have used that way of making it but with a few adjustments e.g i made the object the NPC was going to give me invisible then once i give him the payment it gets put into my inventory and it becomes visible. if i need a advanced one, i will ask, if that is fine with you?
thank you i have used that way of making it but with a few adjustments e.g i made the object the NPC was going to give me invisible then once i give him the payment it gets put into my inventory and it becomes visible. if i need a advanced one, i will ask, if that is fine with you?
rocket20001010
19 Feb 2016, 18:44@XanMag
is there a way where if you search a container to make it have a percentage chance to find the item inside it e.g if you search a bin you sometimes find the money others you dont
is there a way where if you search a container to make it have a percentage chance to find the item inside it e.g if you search a bin you sometimes find the money others you dont

XanMag
19 Feb 2016, 19:25Yes. It's under the 'If' script drop down selection. If random chance 25% make object diamond visible, else make object copper coin visible. The next script should be remove object diamond and copper coin. If you don't the person could search infinitely until the diamond appears.
Warning... I've never tried that but can't imagine it not working. Let me know.
Edit: and that if script should be placed with a 'search' verb.
Warning... I've never tried that but can't imagine it not working. Let me know.
Edit: and that if script should be placed with a 'search' verb.
HegemonKhan
19 Feb 2016, 21:23XanMag can help you do this in the GUI~Editor, so here's the code stuff of it:
------------
there's 4 built-in randomization functions for you to use:
http://docs.textadventures.co.uk/quest/ ... omint.html (GetRandomInt)
http://docs.textadventures.co.uk/quest/ ... ouble.html (GetRandomDouble)
http://docs.textadventures.co.uk/quest/ ... eroll.html (DiceRoll)
http://docs.textadventures.co.uk/quest/ ... hance.html (RandomChance)
------------
using 'RandomChance' with one of the other randomization functions works very well for stuff like this, a quick brief sample example:
the 'GetRandomInt' selects the item, and then the 'RandomChance' determines whether you actually get that selected item or not.
------------
there's 4 built-in randomization functions for you to use:
http://docs.textadventures.co.uk/quest/ ... omint.html (GetRandomInt)
http://docs.textadventures.co.uk/quest/ ... ouble.html (GetRandomDouble)
http://docs.textadventures.co.uk/quest/ ... eroll.html (DiceRoll)
http://docs.textadventures.co.uk/quest/ ... hance.html (RandomChance)
------------
using 'RandomChance' with one of the other randomization functions works very well for stuff like this, a quick brief sample example:
the 'GetRandomInt' selects the item, and then the 'RandomChance' determines whether you actually get that selected item or not.
<object name="short_sword">
<attr name="alias" type="string">short sword</attr>
<attr name="parent" type="object">item_drop_container</attr>
</object>
<object name="hand_axe">
<attr name="alias" type="string">hand axe</attr>
<attr name="parent" type="object">item_drop_container</attr>
</object>
<object name="club">
<attr name="alias" type="string">club</attr>
<attr name="parent" type="object">item_drop_container</attr>
</object>
<object name="dagger">
<attr name="alias" type="string">dagger</attr>
<attr name="parent" type="object">item_drop_container</attr>
</object>
<object name="short_bow">
<attr name="alias" type="string">short bow</attr>
<attr name="parent" type="object">item_drop_container</attr>
</object>
<object name="item_drop_container">
<attr name="weapon_class_list_1" type="objectlist">
<value>short_sword</value>
<value>hand_axe</value>
<value>club</value>
<value>dagger</value>
<value>short_bow</value>
</attr>
</object>
<function name="weapon_class_1_drop">
selected_item = ObjectListItem (item_drop_container.weapon_class_list_1, GetRandomInt (0, ListCount (item_drop_container.weapon_class_list_1) - 1))
if (RandomChance(95)) {
msg ("You got " + selected_item.alias)
selected_item.parent = player
} else {
msg ("You got nothing, sorry")
}
</function>
rocket20001010
20 Feb 2016, 15:00@XanMag
thanks that helped me a lot. is it ok if i ask more questions if i need to
thanks that helped me a lot. is it ok if i ask more questions if i need to

XanMag
20 Feb 2016, 15:26Absolutely. If it's unrelated to NPCs, start a new thread. Or, you can always PM me.