2

I'm making a dungeon-crawler adventure map, and at the end I would like the system to tell the player, either within the chat or on screen (using /title) these criteria:

  • Number of deaths
  • Number of rooms entered (out of X)
  • Number of mobs killed
  • Number of times fell in lava/from a high place

Things like that. I know that there's a way so that the player can press tab or have it displayed on the right of the screen, but I would like it so it's kind of a credits thing.

  • Is your question just how to display a death count, or how to display all of those things? What have you tried so far and what are you stuck on? – SirBenet May 25 '15 at 12:26
  • As far as I know, you can only get the death count, not the death cause. – Universal Electricity May 25 '15 at 12:39
  • I think you can get the cause as a subtype of the death stat. I can't check for sure right now, though. – MBraedley May 25 '15 at 12:48
  • @colorfusion I'm asking the command to have the death cout/other counts (as scoreboard stats) displayed in either the chat (Ex. /say @a deathCount) or as a title (/title deathCount) – SweetDelight May 25 '15 at 14:44
  • @SweetDelight So, if I'm understanding right, you already have the objectives set up, and just want to know how to say them into chat/a title? – SirBenet May 25 '15 at 15:13
2

As you already have the objectives set up and working, it's fairly simple to output them. You'll need to use the JSON format to get the player's score, like this:

["",{"score":{"name":"*","objective":"ObjectiveName"}}]

Where ObjectiveName is the name of the objective you want to get the player's value of.

/title already accepts JSON data, so all you need to do is:

/title @p title ["",{"score":{"name":"*","objective":"ObjectiveName"}}]

/say doesn't accept the JSON format, so you should use /tellraw instead, which does:

/tellraw @p ["",{"score":{"name":"*","objective":"ObjectiveName"}}]

If you want it as part of a sentence, you could change the JSON part to something like:

["You have died ",{"score":{"name":"*","objective":"ObjectiveName"}}, " times."]
| improve this answer | |
  • Can you add how one would you go about embedding the score into a sentence, like: "You died X times."? I assume it's just ["You died ",{...}," times."]? – MrLemon May 26 '15 at 17:07
  • @MrLemon Yep, that's how you do it. I'll add that to the answer. – SirBenet May 26 '15 at 17:11
  • @colorfusion Thank you so much! You're a lifesaver. – SweetDelight May 27 '15 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.