You can actually stack arrays, thus only requiring one array for the entire scoreboard, which then again holds 10 sub-arrays per entry, which then hold the data.
An array in thyme is a multi-entry-variable. It is a single variable with with a specific size, and each element of the array(numbered 0 to size-1) holds a variable of it's own. Imagine it like being bad at naming stuff and naming your images image0, image1, image2, image3, but all grouped together nicely in an "image" folder.
For reasons only algoryx can tell us, array's are read-only, meaning that once you create an array, you can only find out what's inside it, or replace the entire thing. That is the principle that X-Ray's script propably circumvents by completely re-assembling an array from scratch by reading all elements, replacing the one you want to change, and writing all elements into a new array, which replaces the old one.
for your example, your array would look like this:
hs = [["",0],["",0],["",0],["",0],["",0],["",0],["",0],["",0],["",0],["",0]]
As you can see, its one array holding 10 smaller arrays for the scoreboard. The temporary array you need should be created whenever you need one by typing something like "tempvar = ["",0]".
Now to editting the array:
As mentioned, editting single elements of an array requires assembling a new array from scratch, where a single element is replaced with the new entry in the process. I coded a simple code for replacing entries here, which does not require XRay's Xfor in it.
Open the object holding your script, and copy this entire code into the little empty black box in the top left:
(Pick the first for a function only existing in one object, or the second for a global function)
- Code: Select all
_changeEntry/scene.my.changeEntry = (a, m, d)=>{
templist = [];
for(4, (i)=>{
tempentry = [];
i == m ? {
tempentry = d
} : {
tempentry = a(i)
};
templist = templist ++ tempentry
});
templist
}
You can now use it by typing _changeEntry/scene.my.changeEntry(array, index, new entry in format ["name", score])
so for example, to change the 8th entry in the scoreboard, you would type
_changeEntry(hs, 7, ["Fra32Roolz", 9001]);
Keep in mind that, since arrays start counting from 0, the 8th entry is number 7, just as the first entry is number 0.