#Is it possible to set a texture of hud_screen.json based on a scoreboard value?

1 messages · Page 1 of 1 (latest)

civic arch
#

Essentially I want to update the image of the user's hud screen based on their score for a scoreboard objective, like if the have a score of 1, the path would be textures/ui/1 etc. Here is my current code, which sets it as one texture always. {
"custom_sidebar_text_renderer_image2": {
"type": "image",
"texture": "textures/items/apple",
"anchor_from": "top_left",
"anchor_to": "top_left",
"size": [
"16px",
"16px"
],
"layer": 4,
"offset": [
0,
-35
]
}
}. Any help or guidance would be greatly appreciated!

dusk ice
#

It is possible but instead of editing hud_screen edit scoreboard.json

#

I'm not sure if you can with the player's own score but you can based on scores

soft obsidian
civic arch
#

I assume it would use global variables, I just have had no luck so far

#

smth like this $actionbar_text",

#

but for the sb value

soft obsidian
#

look at the example on the wiki I linked

{
    "black_conditional_image": {
        "type": "image",
        "texture": "textures/ui/Black",
        "size": [16, 16],
        "layer": 10,
        "$atext": "$actionbar_text",
        "visible": "($atext = 'hello world')"
    },

    "black_conditional_image_factory": {
        "type": "panel",
        "factory": {
            "name": "hud_actionbar_text_factory",
            "control_ids": {
                "hud_actionbar_text": "[email protected]_conditional_image"
            }
        }
    },

    "root_panel": {
        "modifications": [
            {
                "array_name": "controls",
                "operation": "insert_front",
                "value": {
                    "[email protected]_conditional_image_factory": {}
                }
            }
        ]
    }
}

I believe that's what you're wanting to do

#

the $atext = 'hello world' should be your titleraw with the score

i haven't tested it but that's where I'd start

civic arch
#

alright

civic arch
# soft obsidian the `$atext = 'hello world'` should be your titleraw with the score i haven't t...

Tried multiple times with different things, but keep getting this error [UI][warning]-UI Control: hud_screen | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: root_panel | UI Control: centered_gui_elements_at_bottom_middle | UI Control Key: custom_sidebar_text_renderer_image2 | Expected variable not found in ancestor tree: '$actionbar_text'

#
        "custom_sidebar_text_renderer_image2": {
          "type": "image",
          "texture": "textures/ui/Black",
          "anchor_from": "top_left", // Anchoring the image from top-left
          "anchor_to": "top_left", // Position it at the top-left of the screen
          "size": [
            "16px", // Image width
            "16px" // Image height
          ],
          "$atext": "$actionbar_text",
          "visible": "($atext = 'hello world')",
          "layer": 4,
          "offset": [
            0,
            -35
          ] // Shifting the texture up by 20 units
        }
      },```
#

also the way this is set up would limit me to one total (if I can get it to work as the wiki says), would it be possible to have more?

#

like for example in this image, I have to apples, one image I want to be controlled by the score slot1, the second by slot2, same with the text (I have if statements to convert the number score into the words I want)

steel crane
#

Not sure if it’ll help ya but it’s got 2 images in there at least

civic arch
steel crane
nova storm
#

can action bar be preserved like title

#

instead of using system.runInterval