Paste #5683: Untitled Paste

Date: 2014/06/24 17:04:44 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


on click:
    - if <player.item_in_hand> == "i@shopping bag" { 
      - if <in@<player.name>_shopping_bag.qty> == 0 { 
        - narrate "your shopping bag is empty!" 
        } else { 
        - flag player delay duration:3s
        - chat "ok let's total these items up for you then!" 
        - define total_price 0 
        - foreach <in@<player.name>_shopping_bag.list_contents> { 
          - if <server.flag[<%value%.MATERIAL.id>]> == null { 
            - flag server <%value%.MATERIAL.id>:1.00 
            } 
          - define price <yaml[prices].read[prices.<%value%.MATERIAL.id>].mul[2].mul[<server.flag[<%value%.material.id>]>].mul[<%value%.qty>].as_int> 
          - define total_price <el@val[%total_price%].add[%price%]> 
          } 
        - if <player.money> < %total_price% { 
          - narrate "YOU NEED MONEYS D=" 
          - queue clear 
          } 
        - note 'in@player bag' as:<player.name>_item_bag
        - take money qty:%total_price% 
        - run itemgiver delay:1s
        - take 'i@shopping bag'
        - narrate "<green>The shopkeeper takes <red>%total_price% coins"
        - narrate "<gold>You are all checked out. have a great day!"
        - narrate "<red>Do not open your item bag until you are ready to take all the items out"
        - foreach <in@<player.name>_shopping_bag.list_contents> { 
          - flag server <%value%.material.id>adjust:+:1 
          - run script:price_adjuster def:<%value%.material.id> 
          } 
      } 
    - if <player.item_in_hand> == "i@selling bag" { 
      - flag player delay duration:3s
      - if <in@<player.name>_selling_bag.qty> == 0 { 
        - narrate "your selling bag is empty!" 
        } else if <in@<player.name>_selling_bag.contains['i@shopping bag']> {
        - chat "i am sorry but i do not buy back my shopping bags."
        } else {
        - chat "ok let's total these items up for you then!" 
        - define total_price 0 
        - foreach <in@<player.name>_selling_bag.list_contents> { 
          - define price <yaml[prices].read[prices.<%value%.MATERIAL.id>].mul[<%value%.qty>].as_int> 
          - define total_price <el@val[%total_price%].add[%price%]> 
          } 
        - note 'in@player bag' as:<player.name>_selling_bag
        - give money qty:%total_price% 
        - take 'i@selling bag'
        - narrate "<green>The shopkeeper gives you <red>%total_price% coins"
        - foreach <in@<player.name>_shopping_bag.list_contents> { 
          - flag server <%value%.material.id>adjust:-:1 
          - run script:price_adjuster def:<%value%.material.id> 
          } 
      }
    - run tutorialinquiry delay:1s
tutorialinquiry:
  type: task
  script:
  - if <player.flag[delay]> == null {
    - if <player.item_in_hand> != 'i@shopping bag' || <player.item_in_hand> != 'i@selling bag' || <player.item_in_hand> != 'i@item_bag' {
      - chat "if you would like to learn how to use our stores please type 'TUTORIAL'."
      }
    }