stinkey
Forum adept
- Joined
- Sep 8, 2020
- Messages
- 225
- Reaction score
- 74
This isn't exactly going to cover the functions of each text variable manipulation code block, but instead a list of some of the things you can do with them.
First, some pretty basic things.
You can usually use texts in number manipulation if they are just digits and points. Because of this, you don't always have to use the parse number code block, making things like weapon stats in item tags and such easier to manipulate. However, you should get rid of whitespaces and color codes and stray letters. Another cool thing about text manipulation code blocks is that you can use regular expressions (or regex) while using code blocks that target sections of the string (remove from text, replace text, etc.). RegEx can select things such as digits, words, certain combinations of letters, digits, and other things. For example, \d selects all digits (0-9). String damage:\d+ would select everything that is "damage:" and 1 or more digits. (+ in regex means one or more of the preceding token.)
Now, some cooler things (kinda? code is cool)
Let's say you're making a custom damage system with weapons. The weapon has item tag "weaponstats": "damage:5 cooldown:10". You parse the "weaponstats" tag, and get "damage:5 cooldown:10". You can select the damage stat just like this with RegEx, though that's kind of complicated. Another way to parse "damage" is by splitting the text with splitter " ", joining it with ":", then splitting it again with ":". Now you have a list, [damage, 5, cooldown, 10], which is much easier to manipulate.
Another example of how texts are cool: you are making a plot with a custom crafting system. You have successfully parsed a list with the input items [Iron, Coal], and now you are going to softcode a system that gets the output item with lists with the recipe and item to get. You can make 3 lists. One contains all input items and output items (ie: [Iron, Coal, Steel]). Now, in the second list, you can put: ["1+2"]. The third list has ['3']. You get the index of value with Iron and Coal, which are 1 and 2, as variables var1 and var2. Now, you can get list index of value "%var(var1)+%var(var2)" as a text in the second list, which is 1. You then get the value at index in the third list with the 1 you got from the previous get list index of value, which is '3'. You get list value at index in the first list with that 3, and get steel.
Hopefully my words weren't too confusing.
First, some pretty basic things.
You can usually use texts in number manipulation if they are just digits and points. Because of this, you don't always have to use the parse number code block, making things like weapon stats in item tags and such easier to manipulate. However, you should get rid of whitespaces and color codes and stray letters. Another cool thing about text manipulation code blocks is that you can use regular expressions (or regex) while using code blocks that target sections of the string (remove from text, replace text, etc.). RegEx can select things such as digits, words, certain combinations of letters, digits, and other things. For example, \d selects all digits (0-9). String damage:\d+ would select everything that is "damage:" and 1 or more digits. (+ in regex means one or more of the preceding token.)
Now, some cooler things (kinda? code is cool)
Let's say you're making a custom damage system with weapons. The weapon has item tag "weaponstats": "damage:5 cooldown:10". You parse the "weaponstats" tag, and get "damage:5 cooldown:10". You can select the damage stat just like this with RegEx, though that's kind of complicated. Another way to parse "damage" is by splitting the text with splitter " ", joining it with ":", then splitting it again with ":". Now you have a list, [damage, 5, cooldown, 10], which is much easier to manipulate.
Another example of how texts are cool: you are making a plot with a custom crafting system. You have successfully parsed a list with the input items [Iron, Coal], and now you are going to softcode a system that gets the output item with lists with the recipe and item to get. You can make 3 lists. One contains all input items and output items (ie: [Iron, Coal, Steel]). Now, in the second list, you can put: ["1+2"]. The third list has ['3']. You get the index of value with Iron and Coal, which are 1 and 2, as variables var1 and var2. Now, you can get list index of value "%var(var1)+%var(var2)" as a text in the second list, which is 1. You then get the value at index in the third list with the 1 you got from the previous get list index of value, which is '3'. You get list value at index in the first list with that 3, and get steel.
Hopefully my words weren't too confusing.