Page 2 of 2

Re: dUtilLib Ideas!

Posted: August 11th, 2016, 5:29 pm
by Anthony
BlackCoyote wrote: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 >.<

Re: dUtilLib Ideas!

Posted: August 11th, 2016, 5:38 pm
by BlackCoyote

Code: Select all

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..

Re: dUtilLib Ideas!

Posted: August 11th, 2016, 7:23 pm
by BlackCoyote
Mwthorn wrote: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!

Re: dUtilLib Ideas!

Posted: August 13th, 2016, 10:59 am
by Mwthorn
Using the rainbow procedure and encountered this:
http://image.prntscr.com/image/c4351cad ... 055709.png
You can type [ and ] which gives an odd behaviour.
I have also tested this on 1.10

Re: dUtilLib Ideas!

Posted: August 13th, 2016, 12:43 pm
by mcmonkey
Somebody doesn't know about Denizen1's need for escaping
Stares at BlackCoyote's code

Re: dUtilLib Ideas!

Posted: August 13th, 2016, 1:50 pm
by BlackCoyote
mcmonkey wrote: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

Re: dUtilLib Ideas!

Posted: August 13th, 2016, 5:40 pm
by mcmonkey
BlackCoyote wrote:
mcmonkey wrote: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>:
?

Re: dUtilLib Ideas!

Posted: August 13th, 2016, 5:46 pm
by BlackCoyote
mcmonkey wrote:
BlackCoyote wrote:
mcmonkey wrote: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.

Re: dUtilLib Ideas!

Posted: August 13th, 2016, 5:57 pm
by BlackCoyote
Mwthorn wrote:Using the rainbow procedure and encountered this:
http://image.prntscr.com/image/c4351cad ... 055709.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

Re: dUtilLib Ideas!

Posted: August 16th, 2016, 7:12 pm
by mcmonkey
Topic moved.

Re: dUtilLib Ideas!

Posted: August 17th, 2016, 9:02 am
by Mwthorn
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.

Re: dUtilLib Ideas!

Posted: August 17th, 2016, 12:57 pm
by BlackCoyote
What do you mean flat? as in all the surface blocks are at the same height?

Re: dUtilLib Ideas!

Posted: August 17th, 2016, 1:03 pm
by Mwthorn
Yes, or in between a defined height

Re: dUtilLib Ideas!

Posted: August 17th, 2016, 1:06 pm
by BlackCoyote
@anthony make it happen! (I wish I could tag people in forum posts or knew how)

Re: dUtilLib Ideas!

Posted: August 22nd, 2016, 4:54 am
by Mwthorn
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.

Re: dUtilLib Ideas!

Posted: August 22nd, 2016, 6:55 am
by BlackCoyote
Mwthorn wrote: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

Re: dUtilLib Ideas!

Posted: November 24th, 2016, 10:38 am
by Mwthorn
A procedure at gives a sphere (hollow?) as a list of locations.
Input a radius and a location.