Date: 2024/08/11 10:02:15 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
tank_handler:
type: world
events:
on player drags liquid_tank in backpack_script:
- determine cancelled
#fill tank
on player right clicks *_bucket in inventory:
- determine passively cancelled
- define slots <context.inventory.find_all_items[liquid_tank]>
- define current -1
- define max 1
- define valid_slot -1
#find a valid slot if there is one
- foreach <[slots]> as:slot:
- if <context.inventory.slot[<[slot]>].has_flag[liquid_level]>:
- define current <context.inventory.slot[<[slot]>].flag[liquid_level.current]>
- define max <context.inventory.slot[<[slot]>].flag[liquid_level.max]>
- if ( <[current].is_less_than[<[max]>]> && <context.inventory.slot[<[slot]>].material.name> == <context.item.material.name> ) || <[current]> == 0:
- define valid_slot <[slot]>
- foreach stop
#valid slot found
- if <[valid_slot]> > 0:
- inventory flag liquid_level.current:++ slot:<[valid_slot]> destination:<context.inventory>
- if !<context.inventory.slot[<[valid_slot]>].has_flag[title_changed]>:
- inventory flag title_changed slot:<[valid_slot]> destination:<context.inventory>
- define type <context.inventory.slot[<[valid_slot]>].material>
- inventory adjust slot:<[valid_slot]> display:<script[config].parsed_key[messages.backpack.tank_title.<[type]>]> destination:<context.inventory>
- define current <context.inventory.slot[<[valid_slot]>].flag[liquid_level.current]>
- inventory adjust slot:<[valid_slot]> "lore:<&nl><&f>Niveau: <&7><[current]><&f>/<&6><[max]>" destination:<context.inventory>
- inventory adjust slot:<context.slot> material:bucket destination:<context.clicked_inventory>
- if <context.inventory.slot[<[valid_slot]>].material> != <context.item.material>:
- inventory adjust slot:<[valid_slot]> destination:<context.inventory> material:<context.item.material>
#no valid slot found, send info message
- else:
- define tank_type <script[config].parsed_key[messages.backpack.tank_title.<context.item.material.name>]>
- define tanks <context.inventory.slot[<[slots]>].parse_tag[<[parse_value].material>]>
- if <[tanks].contains[<context.item.material>]>:
- narrate "<proc[get_key].context[config|prefix]> <script[config].parsed_key[messages.backpack.info_full_tank]>"
- narrate <proc[get_message].context[backpack|info_full_tank]>
- else:
- narrate <proc[get_message].context[backpack|info_no_tank]>