DUL_Astar_default_neighbours: type: procedure debug: false DUL: author: - BlackCoyote name: - A* Pathfinder default neighbours description: - Returns the neighbours of a location, as required for the A* pathfinder. usage: - ]> example: - ]> script: # this needs to be better - determine DUL_Astar: type: procedure debug: false DUL: author: - BlackCoyote name: - A* Pathfinder description: - Returns a path from one location to another, using the A* algorithm usage: - example: - |]> script: - define origin - define destination - define precision - define max_loops - define neighbour_procedure - define open li@0//null - define closed li@ - while : - if > determine null - define parent_id - define q - define parent_ - define open ]> - define q_loc - define q_f - define neighbours ].context[]> - foreach : - if ]> < { - define final "0//parent_" - while stop } - define f ].add[].add[]>]> - if ]].filter[before[/].is[less].than[]].is_empty.not> { - foreach next } - if ]].filter[before[/].is[less].than[]].is_empty.not> { - foreach next } - define open //parent_].alphanumeric> - define closed ]> - define path li@ - if { - determine null } - define parent - while true: - if > determine null - define current ]||null> - if == null { - while stop } - define location - define path ]> - define parent - determine # commented version, entirely commented out for laziness sake # DUL_Astar: # type: procedure # debug: false # DUL: # author: # - BlackCoyote # name: # - A* Pathfinder # description: # - Returns a path from one location to another, using the A* algorithm # usage: # - # example: # - give |]> # script: # - define origin # - define destination # - define precision # - define max_loops # - define neighbour_procedure # initiate the open and closed lists, include the origin as a value to open # - define open li@0//null # - define closed li@ # while we still have values to look through # - while : # - if > determine null # define the ID of the current parent node as the value of the while loop # - define parent_id # Q is the parent node, which is the entry in the open list with the smallest cost (get1 since we sort this list alphanumerically when redefining) # - define q # fill the current parent ID's variable with the parent node's info # - define parent_ # remove the current parent from the open list # - define open ]> # get the location from the current parent # - define q_loc # get the cost of the current parent # - define q_f # get all the eligible neighbours from the current parent # - define neighbours ].context[]> # loop through each neighbour node # - foreach : # if the neighbour is within the threshold distance from the destination, stop the search loop # - if ]> < { # store the final node at which the path was completed separately # - define final "0//parent_" # - while stop # } # define the cost for the current child node, based on its distance to the parent, its parent's cost, and its distance to the destination # - define f ].add[].add[]>]> # if the open list contains a node with the same location and a lower cost, we can dismiss this node # - if ]].filter[before[/].is[less].than[]].is_empty.not> { # - foreach next # } # if the closed list contains a node with the same location and a lower cost, we can dismiss this node # - if ]].filter[before[/].is[less].than[]].is_empty.not> { # - foreach next # } # add this current node to the open list, # each added node will also contain an ID to which parent node it came from, this is used to trace back the direct path to the origin # each node will contain the cost it took to get there, so that it can be compared with other locations # - define open //parent_].alphanumeric> # when we finished looping through the neighbours for a parent, we add the parent to the closed list # - define closed ]> # at this point we reached our destination, we now have a list of nodes. Each node will have a link to its parent node (which is the node from which this current node was a neighbour node of) and now we simply backtrack every parent node starting from the destination, until we run out of parent nodes. # # for example the node cost/l@x,y,z,world/parent_50 has parent_50 as the parent's ID, if we now read we get cost/l@x,y,z,world/parent_46, and so we trace back through every single parent involved with the successful neighbour untill we run out of parents which means we got the origin again # # - define path li@ # - if { # no path found :( # - determine null # } # - define parent # now we basicly backtrack the entire node list, # - while true: # - if > determine null # - define current ]||null> # - if == null { # - while stop # } # - define location # - define path ]> # - define parent # - determine DUL_colorcode_message: type: procedure debug: false DUL: name: - Colorcode Message author: - BlackCoyote description: - Encodes your message into a colour code string and back. - only works with characters from a-z, 0-9, and _ ! usage: - ]> example: - encode: a: '&0&0' b: '&0&1' c: '&0&2' d: '&0&3' e: '&0&4' f: '&0&5' g: '&0&6' h: '&0&7' i: '&0&8' j: '&0&9' k: '&1&0' l: '&1&1' m: '&1&2' n: '&1&3' o: '&1&4' p: '&1&5' q: '&1&6' r: '&1&7' s: '&1&8' t: '&1&9' u: '&2&0' v: '&2&1' w: '&2&2' x: '&2&3' y: '&2&4' z: '&2&5' 0: '&2&6' 1: '&2&7' 2: '&2&8' 3: '&2&9' 4: '&3&0' 5: '&3&1' 6: '&3&2' 7: '&3&3' 8: '&3&4' 9: '&3&5' _: '&3&6' decode: '&0&0': a '&0&1': b '&0&2': c '&0&3': d '&0&4': e '&0&5': f '&0&6': g '&0&7': h '&0&8': i '&0&9': j '&1&0': k '&1&1': l '&1&2': m '&1&3': n '&1&4': o '&1&5': p '&1&6': q '&1&7': r '&1&8': s '&1&9': t '&2&0': u '&2&1': v '&2&2': w '&2&3': x '&2&4': y '&2&5': z '&2&6': 0 '&2&7': 1 '&2&8': 2 '&2&9': 3 '&3&0': 4 '&3&1': 5 '&3&2': 6 '&3&3': 7 '&3&4': 8 '&3&5': 9 '&3&6': _ script: - if li@encode|decode !contains { - debug error "DUL - No valid action specified! Must be encode or decode!" - determine null } - if == "" { - debug error "DUL - No message specified to !" - determine null } - define result "" - if == encode { - define list } else { - define list li@ - define 2 - repeat { - define list ,]>]> } } - foreach : - define result ".]||->" - determine DUL_colorcode_to_RGB: type: procedure debug: false DUL: name: - Colorcode to RGB author: - BlackCoyote description: - Returns a matching RGB value for the specified color code usage: - ]> example: - colors: 0: 0,0,0 1: 0,0,170 2: 0,170,0 3: 0,170,170 4: 170,0,0 5: 170,0,170 6: 255,170,0 7: 170,170,170 8: 85,85,85 9: 85,85,255 a: 85,255,85 b: 85,255,255 c: 255,85,85 d: 255,85,255 e: 255,255,85 f: 255,255,255 script: - determine ]||null> DUL_ColorList: type: procedure debug: false DUL: author: - Anthony name: - ColorList description: - Return colors from input or just list all colors usage: - ]> example: - narrate - narrate colors: black: 0 dark_blue: 1 dark_green: 2 dark_aqua: 3 dark_red: 4 dark_purple: 5 gold: 6 gray: 7 dark_gray: 8 blue: 9 green: a aqua: b red: c light_purple: d yellow: e white: f magic: k bold: l strikethrough: m underline: n italic: o reset: r script: - define colors '' - choose '': - case 'list': - define list 'li@' - foreach '': - define list ']> %value%]>' - determine '' - case 'match': - determine '|]>' DUL_cuboid_vertices: type: procedure debug: false DUL: author: - Anthony name: - Cuboid Vertices description: - Return the list of cuboid vertices from a location pair. usage: - example: - script: - define lx '' - define ly '' - define lz '' - define hx '' - define hy '' - define hz '' - define world '' - determine 'li@l@,,,|l@,,,|l@,,,|l@,,,|l@,,,|l@,,,|l@,,,|l@,,,' # Scrapped for flames, keeping for lulz #DUL_cuboid_vertices: # type: procedure # debug: false # DUL: # author: # - Anthony # name: # - Cuboid Vertices # description: # - Return the list of cuboid vertices from a location pair. # usage: # - # example: # - |]> # script: # - define world '' # - foreach 'li@x|y|z': # - define %value%pair 'li@|' # - define vertlist 'li@' # - foreach '': # - define x '%value%' # - foreach '': # - define y '%value%' # - foreach '': # - define vertlist '' # - determine '%vertlist%' DUL_cuboid_overlap: type: procedure debug: false DUL: author: - Anthony name: - Cuboid Overlap description: - Returns a cuboid object from 2 overlapping cuboids usage: - example: - script: # Reconstruct cuboids from list - define objects '' - define 'c1' '' - define 'c2' '' - if { - determine null } - define 1l '' - define 1h '' - define world '' - define 1lx '' - define 1ly '' - define 1lz '' - define 1hx '' - define 1hy '' - define 1hz '' - define 2l '' - define 2h '' - define 2lx '' - define 2ly '' - define 2lz '' - define 2hx '' - define 2hy '' - define 2hz '' - define flx '].round>' - define fly '].round>' - define flz '].round>' - define fhx '].round>' - define fhy '].round>' - define fhz '].round>' - determine 'cu@%flx%,%fly%,%flz%,%world%|%fhx%,%fhy%,%fhz%,%world%' DUL_cuboid_shell: type: procedure debug: false DUL: author: - Anthony name: - Cuboid Shell description: - Supply a list of cuboids and returns the list of surface locations. usage: - |...]> example: - |...]> script: # Reconstruct cuboids from list - define objects '' - define clist 'li@' - repeat '': - define 'cuboid%value%' '].to[]>' - define clist '' - define blocks 'li@' - define overLaps 'li@' - foreach '%clist%': - define olist '' - define cuboid '' - define 1l '' - define 1h '' - define world '' - define 1lx '' - define 1ly '' - define 1lz '' - define 1hx '' - define 1hy '' - define 1hz '' - foreach '%olist%': - define this '' - if { - define 2l '' - define 2h '' - define 2lx '' - define 2ly '' - define 2lz '' - define 2hx '' - define 2hy '' - define 2hz '' - define flx '].round>' - define fly '].round>' - define flz '].round>' - define fhx '].round>' - define fhy '].round>' - define fhz '].round>' - define oShell 'cu@l@%flx%,%fly%,%flz%,%world%|l@%fhx%,%fhy%,%flz%,%world%|l@%flx%,%fly%,%flz%,%world%|l@%flx%,%fhy%,%fhz%,%world%|l@%flx%,%fly%,%flz%,%world%|l@%fhx%,%fly%,%fhz%,%world%|l@%fhx%,%fhy%,%fhz%,%world%|l@%flx%,%fly%,%fhz%,%world%|l@%fhx%,%fhy%,%fhz%,%world%|l@%fhx%,%fly%,%flz%,%world%|l@%fhx%,%fhy%,%fhz%,%world%|l@%flx%,%fhy%,%flz%,%world%' - define overLaps ']>' } - define shell 'cu@l@%1lx%,%1ly%,%1lz%,%world%|l@%1hx%,%1hy%,%1lz%,%world%|l@%1lx%,%1ly%,%1lz%,%world%|l@%1lx%,%1hy%,%1hz%,%world%|l@%1lx%,%1ly%,%1lz%,%world%|l@%1hx%,%1ly%,%1hz%,%world%|l@%1hx%,%1hy%,%1hz%,%world%|l@%1lx%,%1ly%,%1hz%,%world%|l@%1hx%,%1hy%,%1hz%,%world%|l@%1hx%,%1ly%,%1lz%,%world%|l@%1hx%,%1hy%,%1hz%,%world%|l@%1lx%,%1hy%,%1lz%,%world%' - define blocks ']>' - determine ']>' # # Just a some commands to play with # #DUL_Commands_ShowOverlap: # type: command # debug: false # name: showoverlap # description: Show the overlapping area of two cuboids # usage: /showoverlap # aliases: '' # tab complete: # - determine 'li@' # script: # - showfake m@white_stained_glass |]>]> to: d:s #DUL_Commands_Showshell: # type: command # debug: false # name: showshell # description: Show the shell of two cuboids # usage: /showshell # aliases: '' # tab complete: # - determine 'li@' # script: # - showfake m@white_stained_glass |]> to: d:s # DUL_duration_formatted_full: type: procedure debug: false DUL: author: - BlackCoyote name: - Duration formatted full description: - Returns the duration as a formatted string, with full words. - additionally, you can specify your own words for it to use. usage: - (||||||)]> example: - script: - define duration - if == null { - debug error "DUL - No valid duration specified!" - determine null } - define return "" - define d - if > 1 { - define return " " } else if > 0 { - define return " " } - define duration d]> - define h - if > 1 { - define return " " } else if > 0 { - define return " " } - define duration h]> - define m - if > 1 { - define return " " } else if > 0 { - define return " " } - define duration m]> - define s - if > 1 { - define return " " } else if > 0 { - define return " " } - determine DUL_find_best_match: type: procedure debug: false DUL: name: - Find Best Match author: - BlackCoyote - Anthony description: - Returns the best search match out of a list. usage: - |]> example: - |]> script: - define list '' - if < 2 { - debug error "DUL - Must provide at least one value to match and one value to match against!" - determine null } - define match '' - define list ']>' - if ]> { - determine '' } else if ]].size||0> > 0 { - determine ']].sort_by_number[length].first||null>' } else if ]].size||0> > 0 { - determine ']].sort_by_number[length].first||null>' } else { - determine null } DUL_hidden_spawn_locations: type: procedure debug: false definitions: location|radius DUL: name: - Hidden Spawn Locations author: - BlackCoyote description: - Finds spawn locations within range that are out of line of sight. - If no locations out of line of sight are found, it will return valid spawn locations within line of sight. usage: - |]> example: - |15]> script: - if !matches location { - debug error "DUL - No valid location specified!" - determine null } - if !matches number { - debug error "DUL - No valid radius specified!" - determine null } - define radius - determine ].filter[y.sub[].abs.is[less].than[3]].filter[above.above.above.material.name.is[==].to[air]].filter[above.above.above.above.material.name.is[==].to[air]].filter[above.above.above.above.above.material.name.is[==].to[air]].filter[material.is_occluding].parse[above].filter[above.center.line_of_sight[].not]||]||li@>> DUL_parsePrepend: type: procedure debug: false DUL: author: - Anthony name: - String Prepender description: - Prepends a string to the beginning of each item in a list usage: - ]> example: - narrate "" script: - define e '' - determine '].parse[replace[regex:^].with[]||li@>' DUL_parseAppend: type: procedure debug: false DUL: author: - Anthony name: - String Appender description: - Appends a string to the end of each item in a list usage: - ]> example: - narrate "" script: - define e '' - determine '].parse[replace[regex:$].with[]||li@>' DUL_parseWrap: type: procedure debug: false DUL: author: - Anthony name: - String Wrapper description: - Adds a prepender and an appender to each item in a list usage: - ]> example: - narrate "" script: - define e '' - determine '].parse[replace[regex:^].with[].parse[replace[regex:$].with[]||li@>' # DUL_parse_colors_without_url: type: procedure debug: false DUL: name: - Parse Colors Without URL author: - BlackCoyote description: - parses the color codes in the input whilst skipping the ones within URLs. usage: - ]> example: - ]> script: - if == null { - determine null } - define message "" - foreach ]>: - define string - if //]> || //]> || { - define message " " } else { - define message " " } - determine DUL_rainbow_text: type: procedure debug: false DUL: name: - Rainbow Text author: - BlackCoyote description: - Turns the colour of a text into a rainbow format with a new colour per letter. usage: - ]> example: - ]> script: - if { - debug error "DUL - No valid text specified!" - determine null } - define colormap li@<&4>|<&6>|<&e>|<&a>|<&3>|<&9>|<&5> - define result "" - foreach : - define result "]>" - determine DUL_random_numbers_by_total: type: procedure debug: false DUL: name: - Random Numbers by Total author: - BlackCoyote description: - returns the specified amount of random positive integer numbers that always add up to the specified total. usage: - |]> example: - definitions: amount|total script: - if !matches number { - debug error "DUL - No valid amount specified." - determine null } - if !matches number { - debug error "DUL - No valid total specified." - determine null } - define numbers li@ - define currenttotal 0 - repeat : - define numbers ].sub[]>].round>]>]> # new number = random int from 1 to ( specified total - current total - ( specified amount - current amount ) ) fml i hate math - define currenttotal ]> - define numbers ]>]> - determine ]> DUL_random_surface_block: type: procedure definitions: location|radius debug: false DUL: name: - Random Surface Block author: - BlackCoyote description: - Finds a random surface block within the provided radius more efficiently than conventional denizen tags. usage: - |]> example: - |5000]> script: - if !matches location { - debug error "DUL - No valid location specified!" - determine null } - if !matches number { - debug error "DUL - No valid radius specified!" - determine null } - while true: - define newloc ].to[]>,0,].to[]>].highest.find.surface_blocks.within[5].get[1]||null> - if != null && { - determine } else if >= 10 { - determine null } DUL_rn: # An internally faster version type: procedure debug: false DUL: name: - Random Numbers by Total author: - Anthony description: - returns the specified amount of random positive integer numbers that always add up to the specified total. usage: - |]> example: - definitions: a|t script: - define r li@ - define s '%a%' - while : - define s '' - define n ']>' - define t '' - define r '%r%%n%|' - define r '%r%%t%' - determine # DUL_safeString: type: procedure debug: false DUL: author: - Anthony name: - Safe String description: - Boolean tag returns true if the string only contains lower case letters, numbers, and/or underscore _ usage: - example: - narrate script: - determine '' DUL_cleanString: type: procedure debug: false DUL: author: - Anthony name: - Clean String description: - Clean a string of any character that is not a lower case letter, number, or underscore _ usage: - example: - narrate script: - determine '' # DUL_script_tracker: type: world debug: false events: on system time hourly: - webget "http://stats.denizenscript.com/tracker?script=96&version=" DUL_text_progress_bar: type: procedure debug: false DUL: name: - Text Progress Bar author: - BlackCoyote description: - Makes a text based progress bar based on the percentage you provide. usage: - (||||)]> example: - ]> script: - define percentage - if == none { - define percentage 0 } - if { - define max } - if == none { - define max 10 } - if { - define char } else { - define char = } - if { - define col1 } else { - define col1 &a } - if { - define col2 } else { - define col2 &7 } - define string ].with[]> - define split ].as_int> - determine "]>,]>" DUL_unique_queue_id_prefixed: type: procedure debug: false DUL: name: - Unique Queue ID Prefixed author: - BlackCoyote description: - Gives a unique queue ID for you to use, with a specified prefix. usage: - ]> example: - ]> script: - define prefix - define id - while ]>: - define id - determine DUL_unparse_colors: type: procedure debug: false DUL: name: - Unparse Colors author: - BlackCoyote description: - unparses all the colors in your input usage: - ]> example: - ]> script: - if == null { - determine null } - determine ].with[&]> DUL_version_script: type: version name: dUtilLib id: 96 description: A collection of dscript functions and utilities written by BlackCoyote and Anthony. version: 20 DUL_WRCG: type: procedure debug: false DUL: author: - Anthony name: - Weighted Random Choice Generator description: - Supply a list of weight/return values and have one of the values returned to you randomly based on weight. usage: - example: - give script: - define l '' - define w '0' - foreach '': - define w '' - define number '' - define hv '0' - foreach '%l%': - define ov '%hv%' - define lv '' - define hv ']>' - if %number% >= %lv% && %number% <= %hv% { - determine '' }