Skip to main content

Makecode Passing variables to "on chat command" block

Comments

5 comments

  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Good question. I tried to declare a string variable and use it to accept a string input to a chat command but was unsuccessful.

    As an alternative, you could declare a function, perhaps:

    0
  • Rodrigo González

    Not allowing to pass string variables in chat commands seems a big limitation since the player can't invoke a function in the game, can he? 

    0
  • Debbie Alexander
    Moderator Beacon of Knowledge Super Star

    Can you help me understand the implementation you are going for here? What do you need to do with the string? Maybe we can find a work-around. =D

    0
  • Rodrigo González

    Could be something so simple as a chat command to greet another player in a multiplayer setting. The chat command would receive a string (a player's name) as a parameter and via a player.say block prints a greeting message personalized with the name received as a parameter

    0
  • Rodrigo González

    That's odd ... from the chat line you can only pass a numeric argument to a chat command. But when the player itself runs the chat command from inside the program, he can pass an argument ( player.runChatCommandWithArguments) ... but the argument has to be a string this time?

    This is from the minecraft codebuilder help:

     

    0

Please sign in to leave a comment.