-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ feat: add a new bs.string
module
#283
base: master
Are you sure you want to change the base?
Conversation
and implementation of the `index_of` and `lenth` feature
close #191 |
and implementation of the `index_of` and `lenth` feature
+ starting the lower and upper case
and come fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey really quick review before this gets too big. I have'nt reviewed everything but it's a start
modules/bs.string/data/bs.string/function/concat/dispatch.mcfunction
Outdated
Show resolved
Hide resolved
modules/bs.string/data/bs.string/function/lower_case/fast/loop.mcfunction
Outdated
Show resolved
Hide resolved
modules/bs.string/data/bs.string/function/upper_case/fast/loop.mcfunction
Outdated
Show resolved
Hide resolved
…of the inverse table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok i'm really nitpicking here, i mainly reviewed the style and not the logic. For the logic I'll need more time to run the tests and all. Also there are some remaining say and tellraw, i'm sure it's because it's not completly finished and ready for the last review, but i commented some of them (not all). A small cleanup cannot hurt i guess 👍
@@ -0,0 +1,100 @@ | |||
# 🔠 String | |||
|
|||
**`#bs.string:help`** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to have a small description, a banner image, and a quote for our module. Nothing is mandatory except the description, but it's better with all of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how you find the image for the module with a black and white variant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either have a png with transparent background, or make 2 versions. If you don't really feel like doing some image design we'll try to do it (either Theo or me)
modules/bs.string/data/bs.string/function/find/inverse/inverse.mcfunction
Outdated
Show resolved
Hide resolved
modules/bs.string/data/bs.string/function/find/inverse/up.mcfunction
Outdated
Show resolved
Hide resolved
bs.string
modulebs.string
module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Globally i think we should avoid mixing storage and macro. This is because it's really hard to tell if some parameters are to be used dynamically or not. For example occurence may be used with a constant value but some people might want to use it dynamically and it adds extra complexity. I think we should only use storage for the whole module. Also some tests are failing, and i think some function could be changed a bit. Here are my propositions:
- find should be renamed find_all (still returns a list) and we should have a simple find that returns only the first occurence as an int from the function. This mean that the command can easily be used with if function.
- insert can be reworked easily into something like replace_range / substr_replace which does the same and more with a similar implementation (see the details after)
# 🔠 String | ||
|
||
**`#bs.string:help`** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In the documentation a lot of sentences are missing their
.
at the end. - Verbs should be imperative. For example in uppercase/lowercase,
Converts
should beConvert
instead. - In multiple examples the description does not have an uppercase at the start of the sentence.
- Functions should be sorted in alphabetical order.
- Storage inputs/outputs should use treeview (see other modules like block) if more than 1, and examples should also work this way. For example in replace:
# avoid data modify storage bs:in string.replace.str set value "hello world" data modify storage bs:in string.replace.old set value "world" data modify storage bs:in string.replace.new set value "minecraft" # use instead to encourage people to use only the base path (string.replace) to override the whole compound and avoid unintended side effects when multiple pack use bookshelf data modify storage bs:in string.replace set value {str: "hello world", old: "world", new: "minecraaft"}
**Strorage `bs:out string.replace`**: {nbt}`string` The replaced string | ||
``` | ||
|
||
_replace world by minecraft:_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
world and minecraft missing `` => world
and minecraft
data modify storage bs:in string.replace.old set value "world" | ||
data modify storage bs:in string.replace.new set value "minecraft" | ||
|
||
function #bs.string:replace {type:'fast'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type macro should not be here
scoreboard objectives remove bs.out | ||
scoreboard objectives remove bs.ctx | ||
|
||
#data remove storage bs:in string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove both input and outputs when unloading the module also the const score
scoreboard objectives add bs.ctx dummy [{"text":"BS ","color":"dark_gray"},{"text":"Ctx","color":"aqua"}] | ||
scoreboard objectives add bs.const dummy [{"text":"BS ","color":"dark_gray"},{"text":"Const","color":"aqua"}] | ||
|
||
#set constant |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really consistent with other comments, we should always add a space after #
. Also not sure this one is really needed since the code is self explanatory. We don't really have conventions for comments but i think it's best to be consistent across a module (like for example if you use uppercase at the start of comments use it everywhere)
# For more details, refer to the MPL v2.0. | ||
# ------------------------------------------------------------------------------------------------------------ | ||
|
||
data modify storage bs:out string.find append from storage bs:ctx x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said after in find avoid using x and use the score instead
data modify storage bs:ctx _.ltr set string storage bs:ctx _.test -1 | ||
execute store success score #t bs.ctx run data modify storage bs:ctx _.test set from storage bs:in string.find.needle | ||
|
||
data modify storage bs:ctx z set from storage bs:ctx y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed directly use y directly in match_pattern instead
# | ||
# For more details, refer to the MPL v2.0. | ||
# ------------------------------------------------------------------------------------------------------------ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for normal/skip
# - Any modifications must be documented and disclosed under the same license | ||
# | ||
# For more details, refer to the MPL v2.0. | ||
# ------------------------------------------------------------------------------------------------------------ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing new line. Also im lazy and i think a lot of code is shared with find, so i'll just say everything for find applies here
# For more details, refer to the MPL v2.0. | ||
# ------------------------------------------------------------------------------------------------------------ | ||
|
||
#reset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment style. Also im lazy so i'll just say that everything from find applies here
Tasks to do before merging
/docs
)