Paste #14037: Untitled Paste

Date: 2015/02/25 23:54:11 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


lantern_world_handler: 
  type: world 
  debug: true 
  events:
    on player picks up i@lantern:
    - if <player.inventory.contains.display[strict:lantern].qty:3||false> {
      - determine cancelled
      }
    - inventory update
    on player picks up i@fueledlantern:
    - if <player.inventory.contains.display[strict:lantern]||false> {
      - determine cancelled
      }
    on player steps on block:
    - if <player.item_in_hand.material> == m@torch || <player.has_flag[lanternon]> {
      - define last <player.flag[torchlight.last]||null>
      - if %last% != null {
        - light %last% reset
        }
      - light <context.new_location> 10
      - flag player "torchlight.last:<context.new_location>"
      - wait 1t
      - if <c.new_location.simple> == <player.location.simple> {
        - light <player.location.standing_on> d:<player.flag[lanternon].expiration||false>
        }
      }
    on player holds item:
    - if <player.inventory.slot[<context.previous_slot>].material> == m@torch {
      - define last <player.flag[torchlight.last]||null>
      - if %last% != null {
        - light %last% reset
        - flag player "torchlight.last:!"
        }
      }
    - if <player.inventory.slot[<context.new_slot>].material> == m@torch {
      - light <player.location> 10
      - flag player "torchlight.last:<player.location>"
      }
    on player right clicks with i@fueledlantern:
    - if <player.has_flag[lanternon]> {
      - adjust i@fueledlantern 'lore:burn_time_left<&co><player.flag[lanternon].expiration||0>' save:lantern
      - if <player.item_in_hand.lore.before[<&co>]> == li@burn_time_left {
        - take <player.item_in_hand.full>
        }
        else {
        - take i@fueledlantern
        }
      - wait 1t
      - give <entry[lantern].result.full>
      - flag player lanternon:!
      - light <player.location> reset
      }
      else if !<c.item.lore.after_last[<&co>]||true> == true {
      - flag player lanternon d:<c.item.lore.after_last[<&co>]>
      - flag player fuelleft:!
      - wait 1t
      - light <player.location> 10 d:<player.flag[lanternon].expiration||false>
      }
      else {
      - flag player lanternon d:5m
      - wait 1t
      - light <player.location> 10 d:<player.flag[lanternon].expiration||false>
      }
    on player flag lanternon expires:  
    - take bydisplay:lantern
    - wait 1t
    - give i@lantern
    on player jumps:
    - if <player.has_flag[lanternon]> {
      - light <player.flag[prevloc]> d:1t
      }
    on player drops i@fueledlantern:
    - if <c.item.lore.before[<&co>]> == li@burn_time_left && !<player.has_flag[lanternon]> {
      - queue clear
      }
      else if <c.item> == i@fueledlantern && !<player.has_flag[lanternon]> {
      - queue clear
      }
      else {
      - determine passively cancelled
      - adjust <c.item.full> 'lore:burn_time_left<&co><player.flag[lanternon].expiration>' save:lantern
      - wait 1t
      - take bydisplay:lantern
      - drop <player.location.add[<player.location.direction.vector.mul[3]>]> <entry[lantern].result.full>
      - light <player.location.add[0,-1,0]> d:1t 
      - flag player lanternon:!
      }
lantern:
  type: item
  material: m@glass_bottle
  display name: lantern
  lore: 
  - this lantern needs fuel
  recipe: 
  - i@iron|i@glass|i@iron 
  - i@glass|i@string|i@glass 
  - i@iron|i@iron|i@iron

lanternfuel:
  type: item
  material: m@potion,8236
  display name: lantern_fuel
  recipe: 
  - i@potion|i@glowstone_dust|i@potion 
  - i@glass|i@coal|i@glass 
  - i@glass|i@glass|i@glass

fueledlantern:
  type: item
  material: m@glass_bottle
  display name: lantern
  lore:
  - right click to turn this lantern on
  - right click again to turn it off
  recipe: 
  - i@lanternfuel|i@air|i@air 
  - i@lantern|i@air|i@air 
  - i@air|i@air|i@air