Methods To Extract Datas From Players And Entities

This is just a short thread explaining manners to extract datas from players and entities because I was bored. And because there are a lot of feasible ways of doing it, I am gonna only go through the most commonly used ways.

Players

The most common way is to select a player with a %selected% tag using select objects and set the dynamic variable with the data in it into a distinct dynamic variable with %default% or %player% tag. This is an old method since mineland has already implemented a method to replace text and define the username that needs to be extracted easier. But if you are about to use replace text then there is a chance typo can happen, resulting in the username does not exist. To fix this, we gotta either make a dynamic variable to store every username that has logged in the world once or use the second method which I am about to explain.

The second common method (actually I’m lying less than 20 players knew about this) is called Entities Interference (EI). Yes, now you guys might be confusing about why we even need entities when this is literally about extracting data from players. But what I’m talking about is using an entity as the database to extract from. We spawn an entity with the name of the player we want to extract. Using select object entity name equals to select the entity, save its value within a dynamic variable then show it to the default player in a message form. I’ll explain more about this mechanic in the future thread. For now, you just need to know. When we killed an entity, every dynamic variable, and array value that it stored will always be saved. Even if you try to make it dissipate using the delete entity action, the value will still be saved. This is to avoid the entity limit(cap) being overfilled every time the player tries to extract data from a player.

The next method is actually not considered a “method”, instead, it is a way to show/express the data using containers instead of the conventional message form. Basically, every time the player performs the extraction, it gonna executes a recursive function. The recursive function gonna constantly increase the “x” and “z” coordinates from coordinate 0 0 0 (this depends on where the container started to generate). From there save the location into a dynamic variable, then check if the sign in the location contains the correspondent name. This technique has a lot of flaws. First, no one wants to ever waste their world space just for an extraction action. Second, it is very slow since the recursive function only has a speed of up to 800 operations/second. This means if there are 5,000+ chests/players in the game, and you are trying to extract the value from the newest joined player then it would take more than 6 seconds just to determine the location of the chest.

The most recent manner is to use arrays. As I explained in the previous thread relating to it. This is also a complex procedure just like the above containers method. First, we would need to set up a recursive function and run it to truncate every individual letter from the player’s name. After that, we will need to convert the letters into numbers using replace text. From the values we have gotten, we will multiply each of them by 2, 2^2, 2^3, 2^4, etcetera… Save the values we got and add all of them together we will get a sum. The sum is also the index that stores the player’s value that needs to be extracted.

Entities
Just like players, entities have a difference is that it does not have states like online and offline. Meaning method like Entities Interference doesn’t exist here.

Instead of using select object “players” we change it to “entities” or “mobs”. And depends on which operations, on how many targets. The database dynamic variable will either use %entity% or %selected% tag.

3 Likes