Skip to content

Commit

Permalink
✨ String splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
haiiro2gou committed Dec 10, 2023
1 parent 57f0e9c commit 06759df
Show file tree
Hide file tree
Showing 24 changed files with 242 additions and 0 deletions.
19 changes: 19 additions & 0 deletions data/ashen_lib/functions/string/split/.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#> ashen_lib:string/split/
#
# Break down the string into single characters
#
# @input storage
# ashen_lib:api Argument
# String : string
# @output storage ashen_lib:api
# Return : string[]
# @api

# Validate
execute unless data storage ashen_lib:api Argument.String run tellraw @a [{"nbt": "Ashen.Global.Prefix.ERROR", "storage": "global"}, {"translate": "Ashen.Api.Error.String", "fallback": "Missing Argument: String"}]

# Exec
execute if data storage ashen_lib:api Argument.String run function ashen_lib:string/split/core/

# Reset
data remove storage ashen_lib:api Argument.String
24 changes: 24 additions & 0 deletions data/ashen_lib/functions/string/split/core/.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#> ashen_lib:string/split/core/
# @within function ashen_lib:string/split/

# Move to Temporary Storage
data modify storage ashen_lib:temp all set from storage ashen_lib:api Argument.String

# Get Length
execute store result score #Length Ashen.Global.Temporary run data get storage ashen_lib:temp all

# Division into 2 parts
execute if score #Length Ashen.Global.Temporary matches 1024.. run function ashen_lib:string/split/core/start/1024
execute if score #Length Ashen.Global.Temporary matches 512.. run function ashen_lib:string/split/core/start/512
execute if score #Length Ashen.Global.Temporary matches 256.. run function ashen_lib:string/split/core/start/256
execute if score #Length Ashen.Global.Temporary matches 128.. run function ashen_lib:string/split/core/start/128
execute if score #Length Ashen.Global.Temporary matches 64.. run function ashen_lib:string/split/core/start/64
execute if score #Length Ashen.Global.Temporary matches 32.. run function ashen_lib:string/split/core/start/32
execute if score #Length Ashen.Global.Temporary matches 16.. run function ashen_lib:string/split/core/start/16
execute if score #Length Ashen.Global.Temporary matches 8.. run function ashen_lib:string/split/core/start/8
execute if score #Length Ashen.Global.Temporary matches 4.. run function ashen_lib:string/split/core/start/4
execute if score #Length Ashen.Global.Temporary matches 2.. run function ashen_lib:string/split/core/start/2
execute if score #Length Ashen.Global.Temporary matches 1.. run function ashen_lib:string/split/core/start/1

# Reset
scoreboard players reset #Length Ashen.Global.Temporary
8 changes: 8 additions & 0 deletions data/ashen_lib/functions/string/split/core/1024.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#> ashen_lib:string/split/core/1024
# @within function
# ashen_lib:string/split/core/start/1024

data modify storage ashen_lib:temp 512 set string storage ashen_lib:temp all 0 512
function ashen_lib:string/split/core/512
data modify storage ashen_lib:temp 512 set string storage ashen_lib:temp all 512
function ashen_lib:string/split/core/512
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/128.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/128
# @within function
# ashen_lib:string/split/core/start/128
# ashen_lib:string/split/core/256

data modify storage ashen_lib:temp 64 set string storage ashen_lib:temp all 0 64
function ashen_lib:string/split/core/64
data modify storage ashen_lib:temp 64 set string storage ashen_lib:temp all 64
function ashen_lib:string/split/core/64
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/16.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/16
# @within function
# ashen_lib:string/split/core/start/16
# ashen_lib:string/split/core/32

data modify storage ashen_lib:temp 8 set string storage ashen_lib:temp all 0 8
function ashen_lib:string/split/core/8
data modify storage ashen_lib:temp 8 set string storage ashen_lib:temp all 8
function ashen_lib:string/split/core/8
7 changes: 7 additions & 0 deletions data/ashen_lib/functions/string/split/core/2.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#> ashen_lib:string/split/core/2
# @within function
# ashen_lib:string/split/core/start/2
# ashen_lib:string/split/core/4

data modify storage ashen_lib:api Return append string storage ashen_lib:temp all 0 1
data modify storage ashen_lib:api Return append string storage ashen_lib:temp all 1
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/256.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/256
# @within function
# ashen_lib:string/split/core/start/256
# ashen_lib:string/split/core/512

data modify storage ashen_lib:temp 128 set string storage ashen_lib:temp all 0 128
function ashen_lib:string/split/core/128
data modify storage ashen_lib:temp 128 set string storage ashen_lib:temp all 128
function ashen_lib:string/split/core/128
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/32.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/32
# @within function
# ashen_lib:string/split/core/start/32
# ashen_lib:string/split/core/64

data modify storage ashen_lib:temp 16 set string storage ashen_lib:temp all 0 16
function ashen_lib:string/split/core/16
data modify storage ashen_lib:temp 16 set string storage ashen_lib:temp all 16
function ashen_lib:string/split/core/16
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/4.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/4
# @within function
# ashen_lib:string/split/core/start/4
# ashen_lib:string/split/core/8

data modify storage ashen_lib:temp 2 set string storage ashen_lib:temp all 0 2
function ashen_lib:string/split/core/2
data modify storage ashen_lib:temp 2 set string storage ashen_lib:temp all 2
function ashen_lib:string/split/core/2
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/512.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/512
# @within function
# ashen_lib:string/split/core/start/512
# ashen_lib:string/split/core/1024

data modify storage ashen_lib:temp 256 set string storage ashen_lib:temp all 0 256
function ashen_lib:string/split/core/256
data modify storage ashen_lib:temp 256 set string storage ashen_lib:temp all 256
function ashen_lib:string/split/core/256
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/64.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/64
# @within function
# ashen_lib:string/split/core/start/64
# ashen_lib:string/split/core/128

data modify storage ashen_lib:temp 32 set string storage ashen_lib:temp all 0 32
function ashen_lib:string/split/core/32
data modify storage ashen_lib:temp 32 set string storage ashen_lib:temp all 32
function ashen_lib:string/split/core/32
9 changes: 9 additions & 0 deletions data/ashen_lib/functions/string/split/core/8.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#> ashen_lib:string/split/core/8
# @within function
# ashen_lib:string/split/core/start/8
# ashen_lib:string/split/core/16

data modify storage ashen_lib:temp 4 set string storage ashen_lib:temp all 0 4
function ashen_lib:string/split/core/4
data modify storage ashen_lib:temp 4 set string storage ashen_lib:temp all 4
function ashen_lib:string/split/core/4
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#> ashen_lib:string/split/core/_index.d
# @private

#> Score Holder
# @within function ashen_lib:string/split/core/**
#declare score_holder #Length
6 changes: 6 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/1.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#> ashen_lib:string/split/core/start/1
# @within function
# ashen_lib:string/split/core/

data modify storage ashen_lib:api Return append string storage ashen_lib:temp all 0 1
scoreboard players remove #Length Ashen.Global.Temporary 1
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/1024.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/1024
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/1024

data modify storage ashen_lib:temp 1024 set string storage ashen_lib:temp all 0 1024
function ashen_lib:string/split/core/1024
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 1024
scoreboard players remove #Length Ashen.Global.Temporary 1024
execute if score #Length Ashen.Global.Temporary matches 1024.. run function ashen_lib:string/split/core/start/1024
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/128.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/128
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/128

data modify storage ashen_lib:temp 128 set string storage ashen_lib:temp all 0 128
function ashen_lib:string/split/core/128
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 128
scoreboard players remove #Length Ashen.Global.Temporary 128
execute if score #Length Ashen.Global.Temporary matches 128.. run function ashen_lib:string/split/core/start/128
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/16.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/16
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/16

data modify storage ashen_lib:temp 16 set string storage ashen_lib:temp all 0 16
function ashen_lib:string/split/core/16
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 16
scoreboard players remove #Length Ashen.Global.Temporary 16
execute if score #Length Ashen.Global.Temporary matches 16.. run function ashen_lib:string/split/core/start/16
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/2.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/2
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/2

data modify storage ashen_lib:temp 2 set string storage ashen_lib:temp all 0 2
function ashen_lib:string/split/core/2
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 2
scoreboard players remove #Length Ashen.Global.Temporary 2
execute if score #Length Ashen.Global.Temporary matches 2.. run function ashen_lib:string/split/core/start/2
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/256.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/256
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/256

data modify storage ashen_lib:temp 256 set string storage ashen_lib:temp all 0 256
function ashen_lib:string/split/core/256
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 256
scoreboard players remove #Length Ashen.Global.Temporary 256
execute if score #Length Ashen.Global.Temporary matches 256.. run function ashen_lib:string/split/core/start/256
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/32.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/32
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/32

data modify storage ashen_lib:temp 32 set string storage ashen_lib:temp all 0 32
function ashen_lib:string/split/core/32
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 32
scoreboard players remove #Length Ashen.Global.Temporary 32
execute if score #Length Ashen.Global.Temporary matches 32.. run function ashen_lib:string/split/core/start/32
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/4.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/4
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/4

data modify storage ashen_lib:temp 4 set string storage ashen_lib:temp all 0 4
function ashen_lib:string/split/core/4
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 4
scoreboard players remove #Length Ashen.Global.Temporary 4
execute if score #Length Ashen.Global.Temporary matches 4.. run function ashen_lib:string/split/core/start/4
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/512.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/512
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/512

data modify storage ashen_lib:temp 512 set string storage ashen_lib:temp all 0 512
function ashen_lib:string/split/core/512
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 512
scoreboard players remove #Length Ashen.Global.Temporary 512
execute if score #Length Ashen.Global.Temporary matches 512.. run function ashen_lib:string/split/core/start/512
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/64.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/64
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/64

data modify storage ashen_lib:temp 64 set string storage ashen_lib:temp all 0 64
function ashen_lib:string/split/core/64
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 64
scoreboard players remove #Length Ashen.Global.Temporary 64
execute if score #Length Ashen.Global.Temporary matches 64.. run function ashen_lib:string/split/core/start/64
10 changes: 10 additions & 0 deletions data/ashen_lib/functions/string/split/core/start/8.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#> ashen_lib:string/split/core/start/8
# @within function
# ashen_lib:string/split/core/
# ashen_lib:string/split/core/start/8

data modify storage ashen_lib:temp 8 set string storage ashen_lib:temp all 0 8
function ashen_lib:string/split/core/8
data modify storage ashen_lib:temp all set string storage ashen_lib:temp all 8
scoreboard players remove #Length Ashen.Global.Temporary 8
execute if score #Length Ashen.Global.Temporary matches 8.. run function ashen_lib:string/split/core/start/8

0 comments on commit 06759df

Please sign in to comment.