Datapack that has string operations sort of.
Here's an explanation of how this works: https://docs.google.com/document/d/15Va-tUmoMhrajIbZFhZNWKGKYWvWQMv4spxkHr877ps
- strings: Reads strings into char arrays
- strings/substring: Can create "substrings" of char arrays
- strings/case: Has to lower, to upper case and get case functions
- strings/ntca: Converts a number into a char array
- dictionary: WIP part for a tts module
- examples: Has some example functions (Ts)
- application/name: Shortens names using a set of rules, for occasions where messages may require names below a certain length
- base64: converts an array of base64 chars into an array of ascii chars
- parser: parses an array of chars formatted as a json object into name/value pairs
- application/cape: Detects which cape (if any) a player has
- application/unix: Converts unix timestamps into dates/times
More modules are in development
data modify storage string:in input append value {string:"abcde"}
to put in a stringfunction string:call
to read the stringdata get storage string:out out
to get the char array
- Replacement for Step 1:
data modify storage string:in input append value {string:"abcde",callback:{command:"function example:test",id:1}}
- When the string is completely read the function in 'callback.command' is called and the score of 'callback string' is set to 'callback.id'. Both values are optional (see examples 3-4)
- Several strings can be handelled after each other with a queue by using Basic Step 1 and Step 2 several times after one another (see example 4)
- Replacement for Step 1:
data modify storage string:in input append value {string:"abcde",async:{iterations:10}}
- After 'async.iterations' iterations the module stops processing and continues in the next tick. Can be combined with callbacks and the callback will be called once the entire string has been processed.
- Replacement for Step 1:
data modify storage string:in input append value {string:"abcde",async:{iterations:10,parallel:1}}
- After 'async.iterations' iterations the module stops processing and continues in the next tick. The callback is called every tick with everything found in that tick, as well as once at the end with the entire string. This allows parallely already doing something with the start of the string while the rest of the string is still parsing.
data merge storage substring:in {string:["a","b","c"],start:0,length:2}
inputfunction substring:do/start
to executedata get storage substring:out string
to get a char array of the substring- Start determines where the substring starts, length determines how long it is
- Negative start, starts counting from the end instead (start=-1 starts at the last character)
- Negative length is equal to (string length)+(length) (length=-1 for a 10 character string would be 9)
- The char array for this function can be generate using the Strings module and put into this module via a callback (see Examples 8 and 9)
Explanation is coming soon
Explanation is coming soon
Module not final
Explanation is coming soon
Explanation is coming soon
/data modify storage base64:in string set value ["S", "G", "V", "s", "b", "G", "8", "g", "V", "2", "9", "y", "b", "G", "Q", "h"]
/function base64:convert
/data get storage ascii:main text
to read the output/function print:tellraw
gives a plaintext readout of the output array
/function base64:call
will copy the array of characters from the output array of the strings module, then convert them. (Good for converting player skull data)/function print:call
converts an array of bytes in thestorage ascii:main bytes
into ascii characters (ascii values 32 to 126)
/data modify storage parse:in in set value ["{",'"',"a",'"',":",'"',"b",'"',"}"]
/function parser:call
/data get storage parse:main out
to read the output
- numbers longer than 9 digits are displayed in a specific way, for example the number
-3234567.8901
would be displayed as{pol:-1,num:[3, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1],dec:4,base:10}
and if it is not in an array it's type would be"long_number"
- the format for long numbers is
{pol:1/-1,num:[],dec:0,base:10}
pol
is-1
if the number is negitive, and1
if it is positivenum
is the digits in orderdec
is the position of the decimal point from the right
- Integrated with this module is a base(x) converter, instructions for its use can be found here
- The output of this is formatted in name/value pairs inside of an output array, the notation is
{Value:[],Type:"",Extra:[],Name:[]}
Minecraft itself orders the data like this, I do not have any control over how the data is ordered inside of the pair itself. - escape characters are avalible, you are going to want to escape any qotes (
"
) within the name or value entires. To enter a backslash (\
) into a char array you need to use 2, so"\\"
.
Explanation is coming soon
- Input unix timestamp in seconds:
scoreboard players set $second aplication_unix 1575491054
- Run
function application_unix:call
- Outputs as scores: Objective
aplication_unix
for players$day
,$month
,$year
,$hour
,$minute
,$second
,$weekday
(0 for Thursday, 6 for Wednesday) - Outputs as CustomNames: month:
@e[type=minecraft:armor_stand,tag=month,tag=aplication_unix]
, weekday:@e[type=minecraft:armor_stand,tag=weekday,tag=aplication_unix]
function aplication_unix:print
shows the result
- McTsts > String Reading
- gibbsly > Advanced String Operations
- Suso > Unix
Please credit McTsts, Suso and gibbsly if you use any of the modules
- Zonteek > Original Concept (to get timestamp)
- SirBenet > "a, b, c" tag step explanation
- Onnowhere > /help step concept
- Oskar > Asking about the /tag list bug
- Misode > Recursive nbt for dictionary solution