Paste #110843: script

Date: 2023/06/08 09:19:16 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#+----------------------+
#- Recipe command, GUIs
#+----------------------+

#- @@@ Recipe Inventory

recipeInventory_main:
    type: inventory
    inventory: chest
    gui: true
    #title: <&color[#F4F4F4]>Recept
    slots:
    - [filler] [filler] [filler] [filler] [] [filler] [filler] [filler] [filler]
    - [filler] [filler] [filler] [] [] [] [] [filler] [filler]
    - [filler] [filler] [] [] [] [] [filler] [filler] [filler]
    - [filler] [filler] [filler] [filler] [filler] [filler] [filler] [filler] [filler]
    definitions:
        filler: white_stained_glass_pane[display=<&7>]

#- @@@ Player Command

recipeCommand_recipe:
    type: command
    name: recipe
    usage: /recipe [item]
    description: Zobrazi recept pre vyrobenie daneho itemu.
    tab completions:
        1: <static[<server.material_types.filter[is_item].parse[name]>]>
    data:
        CRAFTING: crafting_table
        COOKING: furnace
        BLASTING: blast_furnace
        SMOKING: smoker
        CAMPFIRE: campfire
        STONECUTTING: stonecutter
        SMITHING: smithing_table
        BREWING: brewing_stand
    script:
        - define material_name <context.args.first.to_lowercase.if_null[Null]>
        - if <[material_name]> == Null:
            - narrate "<&c>Nezadal si nazov itemu, ktoreho recept chces najst!"
            - stop
        - if <[material_name]> not in <static[<server.material_types.filter[is_item].parse[name]>]>:
            - narrate "<&c>Nevyzera to tak, ze si zadal existujuci item!"
            - stop
        # Definitions
        - define item <[material_name].as[item]>
        - define inventory <inventory[recipeInventory_main]>
        - define map_recipes <proc[recipeProcedure_maprecipes].context[<[item]>]>
        - define list <list[<[item].with[hides=ALL]>]>
        # Adjustments
        - adjust <[inventory]> "title:<&color[#F4F4F4]>Recept <[item].material.translated_name>"
        # Main loop
        - foreach <script.data_key[data]> as:material key:type:
            - if <[map_recipes].keys.contains[<[type]>]>:
                # Recept pre dany typ craftingu existuje
                - definemap mechanizmy:
                    display: <&e><item[<[material]>].material.translated_name.strip_color>
                    lore: <&7>Pocet najdenych receptov: <&e><[map_recipes].get[<[type]>].size><n><n><&a>Klikni pre zobrazenie receptov!
                    quantity: <[map_recipes].get[<[type]>].size>
            - else:
                # Recept pre dany typ craftingu neexistuje
                - definemap mechanizmy:
                    display: <&c><item[<[material]>].material.translated_name.strip_color>
                    lore: <&7>Pocet najdenych receptov: <&c>0
                    quantity: 1
            - define list:->:<item[<[material]>].with_map[<[mechanizmy]>]>
        # Inventory setter
        - inventory fill destination:<[inventory]> origin:<[list]>
        - inventory open destination:<[inventory]> player:<player>

#- @@@ Recipe Procedure

recipeProcedure_maprecipes:
    type: procedure
    definitions: item
    script:
        - define map_recipes <map>
        - foreach CRAFTING|COOKING|BLASTING|SMOKING|CAMPFIRE|STONECUTTING|SMITHING|BREWING as:type:
            - foreach next if:<[item].recipe_ids[<[type]>].is_empty>
            # Dany item ma pre tento typ nejake recepty
            - define list_recipes <list>
            - foreach <[item].recipe_ids[<[type]>]> as:recipe_id:
                # Recipe id predstavuje nazov toho speci itemu
                # trebars minecraft:diamond_from_deepslate_ore...
                - define list_recipes:->:<server.recipe_items[<[recipe_id]>]>
            # Vlozime ulozene recepty do mapy
            - define map_recipes <[map_recipes].with[<[type]>].as[<[list_recipes]>]>
        - determine <[map_recipes]>