#Json UI Variables
1 messages · Page 1 of 1 (latest)
Once you have finished, please close your thread.
At the moment im doing it like
"variables": [
{
"requires": "(not(($actionbar_text - 'var1:1') = $actionbar_text))",
"$var1": 1
},
{
"requires": "(not(($actionbar_text - 'var1:2') = $actionbar_text))",
"$var1": 2
},
{
"requires": "(not(($actionbar_text - 'var1:3') = $actionbar_text))",
"$var1": 3
},
{
"requires": "(not(($actionbar_text - 'var1:4') = $actionbar_text))",
"$var1": 4
}, etc...
]
its very inefficient and there must be a better way to do it
@frail karma If you strip away the alphabetical characters from a string, it will automatically convert the numerical string to a number. So you can pass in var1:# and strip away the var1: part, and # will automatically be converted to an integer. That way you can do it in one operation rather than a million requires sections
how do i strip away the alphabetical characters
you could just do $string - 'var1:' for instance. But since you're passing in more than one variable at a time, you'll need to do some more advanced string manip. I'll link you in a sec
okay
#old-json-ui message
you can use that method to get a variables from the text you pass in
Do keep in mind if you use actionbar, you need to make a copy of $actionbar_text and modify that variable, as trying to modify the vanilla variable will result in errors since last few updates
okay
what if i have string varaibles like
var1:21,var2:20,var3:10,var4:20,var5:"sdsdsd"
does that work
yes
are you able to call?
i can't im actually heading off for the day. but feel free to post something here and i'll try to get back later
"controls": [
{
"var_0@single_variable_text": {
"$var_index": 0 // Will show ':7589'
}
},
how do i use this var_0 in text
like i want to create a label
how do i set the text to this var
how is that working i dont get it
It’s not
Well json ui is coded in c++ just like all of Minecraft bedrock
So with this you can use printf functions
So
When you multiply a formatting sentax by a string it will parse that string and return what you want
@merry jacinth
oh yeah
But the thing is @vocal idol thing isn’t working on the action bar
🤔
@exotic iris
Why am i able to do
"$var_1": "((%.7s * $actionbar_raw_text))",
"$var_2": "($var_1 - 'var1:')",
but i cant do
"$var_1": "((%.7s * $actionbar_raw_text) - 'var1:')",```
@vocal idol ^
Key: _ Represents Space
"$actionbar_raw_text": "$actionbar_text", // ex: §z20 §z10 §z100§z34
"$var_1_raw": "(%.6s * $actionbar_raw_text)", //§z20_
"$var_2_raw": "(%.6s * ($actionbar_raw_text - $var_1_raw))", //§z10_
"$var_3_raw": "(%.6s * ($actionbar_raw_text - $var_1_raw - $var_2_raw))", //§z100
"$var_4_raw": "(%.6s * ($actionbar_raw_text - $var_1_raw - $var_2_raw - $var_3_raw))", //§z34_
@exotic iris @vocal idol i made a system that actually works!
@vocal idol Fixed your system this is how it should actually be done!
"(('%.' + $var_size + 's') * ($actionbar_raw_text - (('%.' + ($var_size * $var_index) + 's') * $actionbar_raw_text)))"
"variable_parser": {
"$var_index": 0,
"$var": "(('%.' + $var_size + 's') * ($actionbar_raw_text - (('%.' + ($var_size * $var_index) + 's') * $actionbar_raw_text)))"
},```
And can be used by doing
```json
{
"[email protected]_parser": {
"type": "label",
"$var_index": 0, // Change to desired index for `$var`
"font_type": "default",
"text_alignment": "left",
"line_padding": 2,
"color": "white",
"text": "$var",
"font_scale_factor": 0.7,
"size": ["85%", "default"],
"offset": ["28%", "-14%"]
}
}```
glad ya got it workin!