dUtilLib Ideas!

Anthony

Active member
Aug 5, 2016
35
0
6
BlackCoyote said:
find_all_partial is kind of lacking when it comes to this. I have a buncho code somewhere that simulates server.match_player[] but with regular lists, i think this is what he would find more useful. I'll be adding it in.

It is indeed. I used it in the code i posted above for lulz and it's kinda... meh. <proc[DUL_colorlist].context[match|blue]> returns dark_blue

Also, you lied >.<
 

BlackCoyote

Well-known member
Aug 6, 2016
78
0
0
Code:
DUL_find_best_match:
  type: procedure
  debug: false
  DUL:
    author:
    - BlackCoyote
    description:
    - Returns the best search match out of a list.
    usage:
    - <proc[DUL_find_best_match].context[<list separated by '/'>|<value>]>
    example:
    - <proc[DUL_find_best_match].context[<server.flag[homes].as_list.separated_by[/]>|<context.args.get[1]>]>
  script:
  - define list <def[1].split_by[/]>
  - if <def[list].is_empty||true> {
    - debug error "DUL - No valid list specified!"
    - determine null
    }
  - if <def[2]||null> == null {
    - debug error "DUL - No valid value specified!"
    - determine null
    }
  - if <def[list].contains[<def[2]>]> {
    - determine <def[2]>
    } else if <def[list].filter[starts_with[<def[2]>]].size||0> > 0 {
    - determine <def[list].filter[starts_with[<def[2]>]].sort_by_number[length].first||null>
    } else if <def[list].filter[contains[<def[2]>]].size||0> > 0 {
    - determine <def[list].filter[contains[<def[2]>]].sort_by_number[length].first||null>
    } else {
    - determine null
    }

This is what i typically use. It's a lot like the match_player with one slight improvement, that it returns the shortest (and thus the most accurate) result.

I'm a bit unsure about how i'm taking the list input though..
 

BlackCoyote

Well-known member
Aug 6, 2016
78
0
0
Mwthorn said:
Recently I have experienced players done spelling mistakes and I want to correct their mistakes.
Examples with "/spawn" are: "/pawn" "/spawn%" "/spawn*" "/spa wn" "/spwatn"

A procedure that takes input as element-list and a element
This then should output an element, from the list, that is the closest element from the original.

We've partially implemented this in the most recent update at http://mcmonkey.org/denizen/repo/entry/96. it finds the best match, much like server.match_player does. however, it does NOT account for direct typos, only for complete or partial values.

I think Anthony might want to try to make something that can account for typos.
I would recommend this to be added as an entirely new utility as I can imagine accounting for typo inaccuracies might lead to a less accurate 'best match'.

Thanks for the suggestions mwthorn, keep em coming!
 

BlackCoyote

Well-known member
Aug 6, 2016
78
0
0
mcmonkey said:
Somebody doesn't know about Denizen1's need for escaping
Stares at BlackCoyote's code

please enlighten me on how I should be doing it without breaking the 1 color per character
 

mcmonkey

Administrator
Staff member
Helper
BlackCoyote said:
mcmonkey said:
Somebody doesn't know about Denizen1's need for escaping
Stares at BlackCoyote's code

please enlighten me on how I should be doing it without breaking the 1 color per character
-foreach <def[1].unescaped.to_list.escape_contents>:
?
 

BlackCoyote

Well-known member
Aug 6, 2016
78
0
0
mcmonkey said:
BlackCoyote said:
mcmonkey said:
Somebody doesn't know about Denizen1's need for escaping
Stares at BlackCoyote's code

please enlighten me on how I should be doing it without breaking the 1 color per character
-foreach <def[1].unescaped.to_list.escape_contents>:
?

that seems reasonable, thanks.
 

BlackCoyote

Well-known member
Aug 6, 2016
78
0
0
Mwthorn said:
Using the rainbow procedure and encountered this:
http://image.prntscr.com/image/c4351cade5264395ad7d81f835055709.png
You can type [ and ] which gives an odd behaviour.
I have also tested this on 1.10

should be fixed now on latest repo release if mcmonkey's suggestion was right

edit: had to change some more things to make it work the way he suggested but now it seems fine in my tests
 

Mwthorn

Helper
Staff member
Helper
Aug 6, 2016
46
0
6
26
Roskilde, Sjælland, Denmark
ggpvp.dk
Another idea; A task to check a cuboid if its flat. Given input a cuboid and maybe a height-number as a form of criteria for determining if it is flat.

Currently it only seems that's for a chunk to check if its flat.
 

Mwthorn

Helper
Staff member
Helper
Aug 6, 2016
46
0
6
26
Roskilde, Sjælland, Denmark
ggpvp.dk
Another idea! Say you have a long string element and want to split it up to multiple lines (for example to a lore on a item or a speech in a box).

So you give an input and a form of number to tell the length of each line. It should only split on spacebar letters so we don't get words splitted in different lines.
 

BlackCoyote

Well-known member
Aug 6, 2016
78
0
0
Mwthorn said:
Another idea! Say you have a long string element and want to split it up to multiple lines (for example to a lore on a item or a speech in a box).

So you give an input and a form of number to tell the length of each line. It should only split on spacebar letters so we don't get words splitted in different lines.

sounds good! ANTHONYYYY