sandstone icon indicating copy to clipboard operation
sandstone copied to clipboard

JSON Text Components with Selector syntax

Open ColinTimBarndt opened this issue 3 years ago • 1 comments

The following example does not compile because the selector only accepts strings. It would be nice to be able to use selectors in JSON Text Components without appending .toString(). This is already implemented for score components.

import { Selector, MCFunction, tellraw } from 'sandstone'

MCFunction('hello', () => {
  const closest = Selector('@p', {distance: [.1, Infinity]})

  tellraw(Selector('@a'), {
    text: 'My closest friend is ',
    extra: [
      { selector: closest }
    ]
  })
})

ColinTimBarndt avatar Aug 29 '21 22:08 ColinTimBarndt

Also, the selector component is missing the optional "separator" property, which is very useful.

Reference: https://minecraft.fandom.com/wiki/Raw_JSON_text_format#Entity_Names

ColinTimBarndt avatar Aug 29 '21 23:08 ColinTimBarndt