Arqade Asked on May 23, 2021
I am creating a tabletop RPG map and I’m using books to display the player’s current status, but as soon as the player activates a click event on the book the book closes. This is a problem because the book displays plus and minus buttons next to a multi-digit number and I need the player to be able to freely click and adjust the value without the book closing.
Is there a way to prevent books from closing on activating a JSON click event?
A written book is always closed upon clicking a JSON click event within the book unless it is a change_page
click event, which will change the page of the book. The only way around this is to have the book on a lectern instead of in-inventory.
It is also impossible to update data dynamically while the book is being read. This is due to component resolution:
When you use the JSON text components
score
,selector
, andnbt
, the system cannot render the value directly. Instead, these components must be resolved, meaning, converted into a text tag with the correct value. For example:This means that the component is only resolved once, so the value displayed will not dynamically update.
- This:
{"score":{"name":"@p","objective":" text"}}- must be converted into…
{"text":"16"}with the correct value, of course
So you can have your book on a lectern instead, which will prevent the automatic closure, but be warned that updating info of the book while someone is reading it may cause them to be kicked out.
You may instead want to interest yourself in having the book display a single button "Adjust Status" that when clicked, closes the book and /tellraw
s the buttons to change the status into the chat.
Answered by ExpertCoder14 on May 23, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP