Ability to trade items with NPCs
In quest based learning we often need to give specific items/blocks depending on the items/blocks a player has. For example we might want to have a player collect a book from a library before we give them a pick axe to clear a pathway. With NPCs we can trigger a /give command but not a /take type command. A merging of the villager trading system (with options to customize the trades) into the NPC interface would be very useful. A successful trade could them trigger a command as an additional. An attempt to trade an incorrect item could also trigger a different command. Success/failure depending on the outcome of the trade could be used as an assessment tool.
-
Tom Banaszewski Deb Borba Thanks for your interest in beta testing the project. Please send me an email so we can continue the conversation. evgenii.permiakov@bbs.edu.kw
2 -
How to return items back to Player Inventory when he has "no money"? I've spent some time to solve this.
We can use command blocks For/While Loops, same as in this video https://youtu.be/9yX7mhgIhs0
In LOOP we clear Emeralds or something else from Player's inventiry and count this in scorebpard variable
Finaly if Player has small amount of "money" we start second LOOP and give Emeralds back one-by-one
This is flat world with simple solution
https://drive.google.com/open?id=17KMo2R3zXvNrRotWY28sY7up961O6Sab
0 -
Hello teacher, thanks for joining the conversation.
I've run your world and it did work. A quick question: in the project I am working on I have a total of 50+ transactions. Do I need to create a second loop for every transaction?
2 -
Hello. I don't tested the 50+ transaction at the same time. I think the best way - clone "LOOP" for every NPS
About "moneyback" - the best and super quick way to do this - use functions. We can test "Score" with moneyback and make list of commands from 32768 (maximum items in give command). If we store coins in scoreboard "moneyback":
give @s[scores={moneyback=32768..}] emerald 32768 0
scoreboard players remove @s[scores={moneyback=32768..}] moneyback 32768give @s[scores={moneyback=16384..}] emerald 16384 0
scoreboard players remove @s[scores={moneyback=16384..}] moneyback 16384https://drive.google.com/open?id=1BRq0WEkpXTJMcXMxLZFuu6-G9t7iyKVu
Using: import resource pack attached, declare scoreboard moneyback and set some value
and in command block run /execute @p[x=5,y=4,z=5,r=3] ~ ~ ~ function moneyback
:) offcource specify Your x,y,z in selector
0 -
Perhaps what is missing is a command to know what is in the player's inventory? I can't remember at the moment, but it seems to me that it is hard to test whether or not a player has something or not.
0 -
A simple option would be to allow an option to customize the trades for villagers. Or add an option where for NPCs to trade.
1 -
yaa
0
Please sign in to leave a comment.
Comments
37 comments