Paste #107404: Unnamed Denizen Script Paste

Date: 2023/03/15 15:20:40 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


tesla_battery:
  type: item
  Debug: false
  material: verdant_froglight
  display name: <&b><&l>Batterie de tour Tesla

tesla_panel:
  type: item
  Debug: false
  material: sea_lantern
  display name: <&b><&l>Panel de tour Tesla

tesla_antenne:
  type: item
  Debug: false
  material: lightning_rod
  display name: <&b><&l>Antenne de tour Tesla

tesla_battery_wifi:
  type: item
  Debug: false
  material: sea_lantern
  display name: <&b><&l>Batterie wifi d'énergie Tesla

tesla_core:
  type: item
  Debug: false
  material: paper
  display name: <&b><&l>Coeur Tesla
  mechanisms:
    custom_model_data: 25

tesla_pipe:
  type: item
  Debug: false
  material: prismarine_wall
  display name: <&b><&l>Tuyeau éléctro-Teslatérique

tesla_event:
    type: world
    Debug: true
    events:
      on player places tesla_battery:
      - flag <context.location> tesla_battery

      on player breaks block location_flagged:tesla_battery:
      - flag <context.location> tesla_setup:!
      - flag <context.location.above[1]> tesla_setup:!
      - flag <context.location.above[1]> tesla_setup_fuel:!
      - flag server tesla_panel_wifi:<-:<context.location.above[1]>
      - flag <context.location.above[2]> tesla_setup:!
      - flag server tesla_setup_antenne:<-:<context.location.above[2]>

      on player places tesla_panel:
      - flag <context.location> tesla_panel

      on player breaks block location_flagged:tesla_panel:
      - flag <context.location.below[1]> tesla_setup:!
      - flag <context.location> tesla_panel:!
      - flag <context.location> tesla_setup:!
      - flag <context.location> tesla_setup_fuel:!
      - flag server tesla_panel_wifi:<-:<context.location>
      - flag <context.location.above[1]> tesla_setup:!
      - flag server tesla_setup_antenne:<-:<context.location.above[1]>

      on player places tesla_antenne:
      - flag <context.location> tesla_antenne

      on player breaks block location_flagged:tesla_antenne:
      - flag <context.location.below[2]> tesla_setup:!
      - flag <context.location.below[1]> tesla_setup:!
      - flag <context.location.below[1]> tesla_setup_fuel:!
      - flag server tesla_panel_wifi:<-:<context.location.below[1]>
      - flag <context.location> tesla_setup:!
      - flag <context.location> tesla_antenne:!
      - flag server tesla_setup_antenne:<-:<context.location>

      on player places tesla_battery_wifi:
      - if <context.location.find_blocks_flagged[tesla_battery_wifi].within[15].size> >= 1:
        - narrate "<&4><&l>Une batterie wifi est déjà présente dans la zone"
        - determine cancelled
      - else:
        - flag <context.location> tesla_battery_wifi
        - flag <context.location> tesla_battery_wifi_fuel:0

      on player breaks block location_flagged:tesla_battery_wifi:
      - flag <context.location> tesla_battery_wifi:!
      - flag <context.location> tesla_battery_wifi_fuel:!


      on player right clicks block location_flagged:tesla_panel:
        - if <context.location.has_flag[tesla_setup]> && <context.location.above[1].has_flag[tesla_setup]> && <context.location.below[1].has_flag[tesla_setup]>:
          - narrate "<&b><&l>Énergie électrique: <context.location.flag[tesla_setup_fuel]> / 210"
        - else:
          - narrate "<&4><&l>Tour Tesla non opérationelle"

      on player right clicks block location_flagged:tesla_panel with:tesla_core:
      - if <context.location.above[1].has_flag[tesla_antenne]> && <context.location.below[1].has_flag[tesla_battery]>:
            - narrate "<&2><&l>Tour Tesla opérationelle "
            - playsound <context.location> sound:entity_lightning_bolt_impact
            - playeffect effect:ele at:<context.location> offset:1
            - flag <context.location> tesla_setup
            - flag <context.location> tesla_setup_fuel:0
            - flag server tesla_panel_wifi:->:<context.location>
            - flag <context.location.above[1]> tesla_setup
            - flag <context.location.below[1]> tesla_setup
            - flag server tesla_setup_antenne:->:<context.location.above[1]>

      on system time secondly every:10:
      - foreach <server.flag[tesla_panel_wifi]> as:search_tesla_battery:
        - if <[search_tesla_battery].has_flag[tesla_setup]>:
          - foreach <[search_tesla_battery].find_blocks_flagged[tesla_battery_wifi].within[10]> as:tesla_battery_wifi_find:
            - flag <[tesla_battery_wifi_find]> tesla_battery_wifi_fuel:+:<[search_tesla_battery].flag[tesla_setup_fuel]>
            - flag <[search_tesla_battery]> tesla_setup_fuel:0

      on player right clicks block location_flagged:tesla_battery_wifi:
      - narrate "<&b><&l>Énergie électrique: <context.location.flag[tesla_battery_wifi_fuel]> "

      on system time secondly every:30:
      - foreach <server.flag[tesla_setup_antenne]> as:lightning_antenne_tesla:
        - random:
          - repeat 1:
            - if <util.random_chance[50]>:
              - strike <[lightning_antenne_tesla]> no_damage
              - if <[lightning_antenne_tesla].flag[tesla_setup_fuel]> >= 200:
                - determine cancelled
              - else:
                - flag <[lightning_antenne_tesla].below[1]> tesla_setup_fuel:+:1

      on player places tesla_pipe:
      - flag server tesla_pipee:->:<context.location>
      - flag <context.location> tesla_pipe
      - flag <context.location> tesla_pipes_fuel:0

      on player breaks location_flagged:tesla_pipe:
      - flag server tesla_pipee:<-:<context.location>
      - flag <context.location> tesla_pipe:!
      - flag <context.location> tesla_pipes_fuel:!

      on system time secondly every:5:
      - foreach <server.flag[tesla_pipee].flood_fill[10].types[block_flagged:tesla_pipe]> as:tesla_pipes:
        - foreach <[tesla_pipes].find_blocks_flagged[tesla_battery_wifi].within[1]> as:tesla_pipe_find_bat:
          - flag <[tesla_pipes]> tesla_pipes_fuel:+:<[tesla_pipe_find_bat].flag[tesla_battery_wifi_fuel]>
          - flag <[tesla_pipe_find_bat]> tesla_battery_wifi_fuel:0