-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:moxvallix/moxlib
- Loading branch information
Showing
16 changed files
with
147 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
execute unless data storage moxlib:data/private {lock:true} run function moxlib:data/array/slice/init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function moxlib:math/string_to_integer/init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data modify storage moxlib:api/verify output set value true | ||
|
||
schedule function moxlib:verify/cleanup 1t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scoreboard objectives add moxlib.data.array.slice dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
data remove storage moxlib:api/data/array/slice target | ||
data remove storage moxlib:api/data/array/slice start | ||
data remove storage moxlib:api/data/array/slice end | ||
|
||
execute if data storage moxlib:api/data/array/slice {success:false} run data remove storage moxlib:api/data/array/slice output | ||
|
||
execute unless data storage moxlib:api/data/array/slice {success:false} run data remove storage moxlib:api/data/array/slice error | ||
execute unless data storage moxlib:api/data/array/slice {success:false} run data modify storage moxlib:api/data/array/slice success set value true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function moxlib:data/common/setup | ||
function moxlib:data/array/slice/setup | ||
|
||
execute unless data storage moxlib:api/data/array/slice {success:false} run function moxlib:data/array/slice/loop | ||
|
||
function moxlib:data/array/slice/cleanup | ||
function moxlib:data/common/cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
execute if score $index moxlib.data.array.slice >= $start moxlib.data.array.slice if score $index moxlib.data.array.slice < $end moxlib.data.array.slice run data modify storage moxlib:api/data/array/slice output append from storage moxlib:api/data/array/slice target[0] | ||
data remove storage moxlib:api/data/array/slice target[0] | ||
scoreboard players add $index moxlib.data.array.slice 1 | ||
execute if score $index moxlib.data.array.slice < $end moxlib.data.array.slice if data storage moxlib:api/data/array/slice target[0] run function moxlib:data/array/slice/loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
data remove storage moxlib:api/data/array/slice success | ||
|
||
data modify storage moxlib:api/data/array/slice output set value [] | ||
scoreboard players set $index moxlib.data.array.slice 0 | ||
execute store result score $start moxlib.data.array.slice run data get storage moxlib:api/data/array/slice start | ||
execute store result score $end moxlib.data.array.slice run data get storage moxlib:api/data/array/slice end | ||
execute unless score $start moxlib.data.array.slice matches 0.. run scoreboard players set $start moxlib.data.array.slice 0 | ||
execute unless score $end moxlib.data.array.slice matches 1.. unless data storage moxlib:api/data/array/slice end run scoreboard players set $end moxlib.data.array.slice 2147483647 | ||
|
||
execute if score $start moxlib.data.array.slice > $end moxlib.data.array.slice run data modify storage moxlib:api/data/array/slice success set value false | ||
execute if score $start moxlib.data.array.slice > $end moxlib.data.array.slice run data modify storage moxlib:api/data/array/slice error set value "End cannot be less than start" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
data/moxlib/functions/math/string_to_integer/init.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
data modify storage moxlib:api/math/string_to_integer success set value true | ||
|
||
data modify storage moxlib:api/string/to_array target set from storage moxlib:api/math/string_to_integer target | ||
function moxlib:api/string/to_array | ||
|
||
data modify storage moxlib:api/math/array_to_integer target set value [] | ||
execute unless data storage moxlib:api/string/to_array output[0] run data modify storage moxlib:api/math/string_to_integer success set value false | ||
execute if data storage moxlib:api/string/to_array output[0] run function moxlib:math/string_to_integer/iterate | ||
|
||
execute if data storage moxlib:api/math/string_to_integer {success:true} run function moxlib:api/math/array_to_integer | ||
|
||
data modify storage moxlib:api/math/string_to_integer output set from storage moxlib:api/math/array_to_integer output | ||
execute if data storage moxlib:api/math/string_to_integer {success:false} run data remove storage moxlib:api/math/string_to_integer output | ||
data remove storage moxlib:api/math/string_to_integer target |
22 changes: 22 additions & 0 deletions
22
data/moxlib/functions/math/string_to_integer/iterate.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
data modify storage moxlib:math/string_to_integer digit set from storage moxlib:api/string/to_array output[0] | ||
|
||
scoreboard players set $digit moxlib.math.string_to_integer -1 | ||
|
||
execute if data storage moxlib:math/string_to_integer {digit:"0"} run scoreboard players set $digit moxlib.math.string_to_integer 0 | ||
execute if data storage moxlib:math/string_to_integer {digit:"1"} run scoreboard players set $digit moxlib.math.string_to_integer 1 | ||
execute if data storage moxlib:math/string_to_integer {digit:"2"} run scoreboard players set $digit moxlib.math.string_to_integer 2 | ||
execute if data storage moxlib:math/string_to_integer {digit:"3"} run scoreboard players set $digit moxlib.math.string_to_integer 3 | ||
execute if data storage moxlib:math/string_to_integer {digit:"4"} run scoreboard players set $digit moxlib.math.string_to_integer 4 | ||
execute if data storage moxlib:math/string_to_integer {digit:"5"} run scoreboard players set $digit moxlib.math.string_to_integer 5 | ||
execute if data storage moxlib:math/string_to_integer {digit:"6"} run scoreboard players set $digit moxlib.math.string_to_integer 6 | ||
execute if data storage moxlib:math/string_to_integer {digit:"7"} run scoreboard players set $digit moxlib.math.string_to_integer 7 | ||
execute if data storage moxlib:math/string_to_integer {digit:"8"} run scoreboard players set $digit moxlib.math.string_to_integer 8 | ||
execute if data storage moxlib:math/string_to_integer {digit:"9"} run scoreboard players set $digit moxlib.math.string_to_integer 9 | ||
|
||
execute if score $digit moxlib.math.string_to_integer matches -1 run data modify storage moxlib:api/math/string_to_integer success set value false | ||
execute store result storage moxlib:math/string_to_integer digit byte 1 run scoreboard players get $digit moxlib.math.string_to_integer | ||
execute if data storage moxlib:api/math/string_to_integer {success:true} run data modify storage moxlib:api/math/array_to_integer target append from storage moxlib:math/string_to_integer digit | ||
|
||
data remove storage moxlib:api/string/to_array output[0] | ||
|
||
execute if data storage moxlib:api/string/to_array output[0] if data storage moxlib:api/math/string_to_integer {success:true} run function moxlib:math/string_to_integer/iterate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function moxlib:spec/data/array/slice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9] | ||
|
||
function moxlib:api/data/array/slice | ||
|
||
data modify storage moxlib:test/it describes set value "An array sliced with no start or end" | ||
data modify storage moxlib:test/it expects set value [1,2,3,4,5,6,7,8,9] | ||
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output | ||
|
||
function moxlib:api/test/perform | ||
|
||
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9] | ||
data modify storage moxlib:api/data/array/slice start set value 2 | ||
|
||
function moxlib:api/data/array/slice | ||
|
||
data modify storage moxlib:test/it describes set value "An array sliced with no end" | ||
data modify storage moxlib:test/it expects set value [3,4,5,6,7,8,9] | ||
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output | ||
|
||
function moxlib:api/test/perform | ||
|
||
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9] | ||
data modify storage moxlib:api/data/array/slice end set value 7 | ||
|
||
function moxlib:api/data/array/slice | ||
|
||
data modify storage moxlib:test/it describes set value "An array sliced with no start" | ||
data modify storage moxlib:test/it expects set value [1,2,3,4,5,6,7] | ||
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output | ||
|
||
function moxlib:api/test/perform | ||
|
||
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9] | ||
data modify storage moxlib:api/data/array/slice start set value 4 | ||
data modify storage moxlib:api/data/array/slice end set value 7 | ||
|
||
function moxlib:api/data/array/slice | ||
|
||
data modify storage moxlib:test/it describes set value "A slice operation" | ||
data modify storage moxlib:test/it expects set value [5,6,7] | ||
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output | ||
|
||
function moxlib:api/test/perform | ||
|
||
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9] | ||
data modify storage moxlib:api/data/array/slice start set value 4 | ||
data modify storage moxlib:api/data/array/slice end set value 4 | ||
|
||
function moxlib:api/data/array/slice | ||
|
||
data modify storage moxlib:test/it describes set value "A slice operation with zero magnitude" | ||
data modify storage moxlib:test/it expects set value [] | ||
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice output | ||
|
||
function moxlib:api/test/perform | ||
|
||
data modify storage moxlib:api/data/array/slice target set value [1,2,3,4,5,6,7,8,9] | ||
data modify storage moxlib:api/data/array/slice start set value 4 | ||
data modify storage moxlib:api/data/array/slice end set value 2 | ||
|
||
function moxlib:api/data/array/slice | ||
|
||
data modify storage moxlib:test/it describes set value "A slice operation with the end less than the start" | ||
data modify storage moxlib:test/it expects set value {success:0b,error:"End cannot be less than start"} | ||
data modify storage moxlib:test/it receives set from storage moxlib:api/data/array/slice {} | ||
|
||
function moxlib:api/test/perform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data remove storage moxlib:api/verify output |