"Advanced" is a strong word, the content on this page was written to be understood by everyone but it may not be useful for everyone.
Advanced hud
If statements and while loops
Note that the indentation must be exclusively tabs, note that some editors will automatically replace tabs with
spaces so be sure to disable that! If you didn't understand the previous statement use Notepad from this point.
You can use #if to do large if conditions (unlike "basic" conditions you can only have 1 condition without an else statement)
#if is a multi-lined condition (which means)
#while is similar except it repeats itself until the condition is false
You can also use {break} to stop the execution of the while loop early without stopping the execution
of the rest of the hud.
Here is an example of both (Please do not use this, it will likely crash your game):
#if fps<60
{math=10+20}
{crashmypc=true}
{xx=0}
{yy=0}
#while crashmypc
#if yy>height
{crashmypc=false}
;hand, xx,yy,1;
{xx=xx+16}
#if xx>width
{yy=yy+16}
{xx=0}
Magnificent, isn't it? Looks like I peaked early when I came up with this piece of art.
Arrays
Version 5.5.0 or above!
The first item in an array starts at 0!
An array is a list of values with that can be of any length (up to infinity [aka how much your computer can handle]).
You can use [values,seperated,by,commas] to create an array that stores a list of values of any type.
To read the value at a certain spot in an array you must use arrayname[position].
To set a value at a certain point you must do arrayname[position]=value.
Arrays have a fixed size which can be read using the length function.
Arrays can be expanded be inserting a value after the last point in the array (You can't skip points, if an array is of length 6 and you wish to expand it, you must set a value at point 7, before you set a value at point 8)
here is a simple example:
Define an array with 3 objects inside it (the number 4 and the number 2 and the word "Text"):
{arr=[4,2,"Text"]}
Get the number of objects within the array (3):
{length(arr)}
Replace the number 2 with the number 3:
{arr[1]=3}
Read the first value of the array:
{arr[0]}
Add an object in the 4th position of the array:
{arr[3]="4th object"}
Read the new length of the array (4):
{length(arr)}
Writing your own methods
You can use #def to write your own methods. here is an example:
#def divide, number, number
{result = arg1/arg2}
;divide, 4, 2;
{result==2}
You can also use {break} to stop the execution of the method early without stopping the execution
of the rest of the hud.
Available types: string, number, boolean, array, any.
Break variable
The {break} variable is special because it's not actually a variable, once it is used, execution of the hud will stop.
If used in #while loop or a #def method, then instead of stopping the execution of the hud it will just stop the execution of the while loop or def method.
The above statement is only true for #while and #def, not #if.
Example:
#while _i<10
{_i++}
#if _i==5
{break}
{_i}
Will set {_i} to 5
Inc, Dec and Boolean operators
You can use {_i++} to increase _i's value by 1 and then return the it's old value, {_i--} does the same but decreases by 1.
You can use {++_i} to increase _i's value by 1 and then return the it's new value, {--_i} does the same but decreases by 1.
You can use {!_i} to return the opposite value of _i, if it is true then it will return false, if it is false then it will return true.
You can use {boolean2&&boolean1} to return true if both booleans are true
You can use {boolean2||boolean1} to return true if either booleans are true
Item components
The getItem([Number slot]) function returns an object that contains the following properties:
name - The name of the item
item_name - The name of the item type (Even if name was modified with anvil/commands)
repair_cost - The repair cost of the item
damage - How much the item has been damaged
max_damage - How much the item can bee damaged
max_stack_size - The max stack size of the item
enchantment_glint_override - Imma be honest idk what this one does, check the minecraft wiki if it's important.
trim - An object containing the following 3 properties:
- material - The name of the material used on the armor piece's trim
- pattern - The name of the pattern used on the armor piece's trim
- showintooltip - Whether it should show the armor trim in the item's tooltip (idk how this would be useful but it was easy to add so I added it.)
enchantable - If not null, items with the component can be enchanted in an enchanting table.
lore - An array of "Text" objects (use their getString function if you need a string)
rarity - Can be of the following values: common, uncommon, rare and epic.
unbreakable - If it is not null then the tool is unbreakable.
custom_data - Custom NBT data attached to the object... in the form of a string.
enchantments - Contains every enchantment on the object, if the enchantment is null then it is not present:
- [Enchantment name] - The enchantment
- level - The level of the enchantment on the item.
Those properties can be navigated with the '.' character
Example:
Your selected item has {getItem(selectedslot).durability} durability left!