#Bindings + Clip ratio help
1 messages · Page 1 of 1 (latest)
so this works if my scoreboard shows something like 10.0
But if I do something like this, and my scoreboard shows 0.5, then the thing doesn't clip at all
not clipped at all
tried this, also didn't work
tried this, didnt work
@random parrot I see you know a lot about clip ratios and bindings, think you could help me?
tried this, element dissapeared
It looks like you're never converting the string to a number properly due to the way your parentheses are ordered in your attempts. Technically a numerical string should automatically convert to a number after a subtraction, so you don't need to multiply by one, but it's fine to do it anyway. The third picture you sent should be fine, but you need to make sure you divide (or multiply) by $clip_max in the final binding to convert it to a decimal properly.
And clip max can just be 1.0 if I already have the correct number, right?
@random parrot Alright so having the scoreboard say 10.5 with this setup clips half the hp, but when I change the scoreboard to show something like 0.5 and then set the $max_clip to 1.0, it breaks. Any idea on why that happens?
is it retaining the string format? So like there you have 010.5, so when you change to 0.5 is the string at the end 000.5?
The string is 00.50000
The first 0 is not part of it, that's the 20th character, and I'm getting the 21st on
Ah, gotcha. I think it's because UI doesn't always convert to decimal/float. So when it gets the value for #hp from the text, it converts to an int which turns 0.5 into 0. I would just multiply the value by 100 to get a percentage and then divide by 100 when setting #clip_ratio
👍 gotcha!
u can help me?
If you pass anything other than a number to clip_ratio it will cause you to crash. You need to make sure your sidebar name is only a number, and if not you need to remove any characters in the string. Also the binding is #objective_sidebar_name. In yours it's mispelled with an extra "r".
I think the clip_ratio is trying to get the button_string from the first_menu, but the first_menu is letters and not numbers, so it crashes, but it doesn't make sense because the second menu is invisible, it shouldn't interfere.
you know?
@random parrot
It works! Thank you very much!
Awesome!
Sorry, I had to head out for a while. Bindings don't carry across elements unless they are hardcoded global bindings, or you use a view type binding with a source control name pointing to the element. In this case you don't have that. What elements are first_menu and secondMenu attached to? Can you show the code for that? Though it makes it tricky since you're using it across screens. The NPC screen doesn't have access to the scoreboard bindings, only the hud screen does. You'll need to overlay the screens if you want to display an element dynamically from the scoreboard. If you're trying to use secondMenu in both screens that's likely why you're crashing.
@median notch is there anywhere I can read how to use this clip thing I want to make something similar as in a custom bar which uses scoreboards.
Urh use what I had and Shane's advice
Oh thanks
@random parrot could you help me? I'm trying to add an extra bar which uses scoreboards. I copied the code and changed what I thought I needed to change but it still isn't working.
{
"controls": [
{
"mana": {
"type": "image",
"anchor_from": "bottom_middle",
"anchor_to": "bottom_middle",
"offset": [ -50, -35 ],
"texture": "textures/ui/experience_bar_full_white",
"size": [ 81, 5 ],
"layer": 2,
"clip_direction": "left",
"$clip_max": 20.0,
"color": [ 173, 216, 230 ],
"bindings": [
{
"binding_name": "#objective_sidebar_name",
"binding_type": "global"
},
{
"binding_type": "view",
"source_property_name": "('§z' + #objective_sidebar_name)",
"target_property_name": "#text"
},
{
"binding_type": "view",
"source_property_name": "(('%.25s' * #text) - ('%.20s' * #text))",
"target_property_name": "#mana"
},
{
"binding_type": "view",
"source_property_name": "(#mana / $clip_max)",
"target_property_name": "#clip_ratio"
}
]
}
}
]
}
That's the full code in the file under rp/ui/.... I wnat to add an extra bar or 2 if it's possible
Just copy/pasting the code won't work unless you set up your input in the same format. This line "source_property_name": "(('%.25s' * #text) - ('%.20s' * #text))", extracts characters 21-25 from the objective name and uses that as the input for the clipping. You need to change the bindings above clip ratio to extract the data you want to send in.
How and where would I do thta from?
In the bindings above clip ratio
What should I change it to?
I can't give you an answer. It depends what data you're trying to get.
Oh I want to use scoreboards
Is it possible?
yes
What would I need to change for it to use scoreboards?
Depends if you're using values from the actual sidebar or just need to input data from a single player's score where you can use something like titleraw. There's a lot of different ways you can do it. I'd suggest searching json-ui for #hud_title_text_string, #player_score_sidebar, #objective_sidebar_name, and looking at various examples.
Is it on the Wikipedia page?
There's some examples there, yeah. You should read through the json ui intro
By single player score you mean like I use /scoreboard objectives add...
Okay thanks
Well that's an objective. But let's say you had an objective that tracked player thirst, such as /scoreboard objectives add thirst dummy, and each player had a unique score for thirst. You could send that thirst value through a titleraw command and then display the percentage of a bar based off that. If you're using scripting to track it you don't need the objective/score and can just send the variable in dynamically in the title.
Oh thanks I'll try that
im trying to do something like this. Did yo uget this to work?
Unfortunately no I didn't.
can u help me?
@random parrot
"preserved_title_display": {
"type": "image",
"layer": 32,
"size":[64,56],
"clip_direction":"up",
"clip_pixelperfect":false,
"texture": "textures/ui/empty_heart",
"$divide": 100.0,
"bindings": [
{
"binding_type": "view",
"source_control_name": "$control",
"source_property_name": "( #preserved_text - $preserved) ",
"target_property_name": "#hp"
},
{
"binding_type": "view",
"source_property_name": "(#hp / $divide) ",
"target_property_name": "#clip_ratio"
}
]
}
it always show 100% clip even if i use 0 in title command
pls
@random parrot @random parrot
Were you able to get it working?
yep
How
idk