Skip to main content

Ability to trade items with NPCs

Comments

37 comments

  • Evgenii Permiakov

    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
  • teacher

    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
  • Evgenii Permiakov

    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
  • teacher

    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 32768

    give @s[scores={moneyback=16384..}] emerald 16384 0
    scoreboard players remove @s[scores={moneyback=16384..}] moneyback 16384

    https://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
  • Moderator Beacon of Knowledge Super Star

    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
  • Trinity Ahie

    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
  • Valentina Galvez

    yaa

    0

Please sign in to leave a comment.