Paste #9889: Diff note for paste #9888

Date: 2014/09/20 22:07:02 UTC-07:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


 ################################################################################
 #
 #                          M a s t e r C h e f   N P C 
 #                           Feed those hungry denizens
 #
 #
 #   Author: |Anthony|
 #   Version: 0.1
 #   dScript Version: 0.9.5-b1522
 #
 # 
 #
 ################################################################################
 #
 MasterChefNPC:
   type: assignment
   debug: false
 
   actions:
     on assignment:
       - run locally assignment instantly
     on spawn:
       - run locally spawn instantly
     on despawn:
       - run locally despawn instantly
     on click:
       - run locally click instantly
     on damage:
       - run locally damage instantly
     on chat:
       - inject locally chat instantly
 
   assignment:
     - trigger name:chat state:true
     - trigger name:click state:true
     - trigger name:proximity state:false
     - trigger name:damage state:true
     - vulnerable state:false
     - lookclose true range:5 realistic
 #    - flag npc respawn_location:<npc.location>
 #    - flag npc Pathfind.FidgetPathMaterial:<npc.location.standing_on.material.name>
 #    - flag npc Pathfind.FidgetHeight:1
     - inject locally spawn instantly
 
 
   spawn:
     - chat "Alright, time to start work..." no_target
 #    - run s@Fidget id:<npc.id>_fidgetQueue
 
 
   despawn:
     - chat "Phew... I<&sq>m glad to be done work for the day!" no_target
 
 
   damage:
     - chat "Why would you do that?" no_target
 
 
   click:
     - if <npc.has_flag[following]> {
       - if <npc.flag[following].as_player.is[==].to[<player>]> {
         - follow stop
         - if <queue.exists[Following_<npc.id>]> queue queue:Following_<npc.id> stop
         - chat "Ok. I<&sq>ll wait right here..."
         - flag npc following:!
         - queue stop
         }
         else {
         - chat "I<&sq>m a little busy right now..."
         - queue stop
         }
       }
       else {
       - flag npc following:<player>
       - run locally follow id:Following_<npc.id>
       }
 
   follow:
     - if !<npc.flag[following].as_player.is_online> {
       - flag npc following:!
       - follow stop
       - queue stop
       }
     - follow target:<npc.flag[following].as_player>
     - wait 5s
     - inject locally follow
 
   chat:
     - if <npc.has_flag[following]> {
       - chat "I<&sq>m a little busy right now following <npc.flag[following].as_player.name>..."
       - queue stop
       }
     - define options li@fridge|grill|sink|prep
-    - define equipment '<c.message.escaped>'
+    - define equipment '<c.message.split[ ].get[1].escaped>'
+    - define range '<c.message.split[ ].get[2].escaped||15>'
+    - if !<def[range].is[MATCHES].to[number]> {
+      - chat "Hey, that<&sq> s not a number!"
+      }
     - if '<def[options].contains[%equipment%]>' {
-      - inject locally find%equipment%
+      - inject locally find%equipment% instantly
       }
       else {
       - chat "I don<&sq>t know anything about that."
       - queue stop
       }
     - if <def[locations].is_empty> {
       - chat "I couldn<&sq>t find the %equipment%."
       - queue stop
       }
     - chat "I found <def[locations].size.as_int> %equipment%."
     - ~walk <npc> <def[locations].random.as_location> 'speed:0.6' 'radius:2.0'
     - chat "Ok, I made it to the %equipment%."
 
 
 
   findFridge:
   # The Fridge is 2 ironblocks tall with a stone button on the front of the top block
     - define ironBlocks <npc.location.find.blocks[iron_block].within[%range%]||null>
     - if <def[ironBlocks].is[!=].to[null]>
       && !<def[ironBlocks].is_empty> {
       - define locations li@
       - foreach %ironBlocks% {
         - define iron '%value%'
         - if <def[iron].below.material.is[!=].to[m@iron_block]||true> foreach next
 
         - define east '<def[iron].add[1,0,0]>'
         - define west '<def[iron].add[-1,0,0]>'
         - define north '<def[iron].add[0,0,1]>'
         - define south '<def[iron].add[0,0,-1]>'
         - define cardinals li@east|west|north|south
 
         - foreach %cardinals% {
           - define location '<def[%value%]>'
 
           - if <def[location].material.name.is[==].to[m@stone_button]>
             && <def[location].sub[0,1,0].material.name.is[==].to[m@air]>
             && <def[location].sub[0,2,0].material.is_solid> {
             - define locations <def[locations].include[<def[location].below>]>
             }
           }
         }
       }
 
 
   findGrill:
   # The Grill is a trapdoor over fire
     - define fireBlocks <npc.location.find.blocks[m@fire].within[%range%]||null>
     - if <def[fireBlocks].is[!=].to[null]>
       && !<def[fireBlocks].is_empty> {
       - define locations li@
       - foreach %fireBlocks% {
         - define fire '%value%'
         - if <def[fire].above.material.is[!=].to[trap_door]||true> foreach next
 
         - define east '<def[fire].add[1,0,0]>'
         - define west '<def[fire].add[-1,0,0]>'
         - define north '<def[fire].add[0,0,1]>'
         - define south '<def[fire].add[0,0,-1]>'
         - define cardinals li@east|west|north|south
 
         - foreach %cardinals% {
           - define location '<def[%value%]>'
 
           - if <def[location].material.is[==].to[m@air]>
             && <def[location].above.material.is[==].to[m@air]>
             && <def[location].below.material.is_solid> {
             - define locations <def[locations].include[%location%]>
             }
           }
         }
       }
 
 
   findSink:
   # The sink is a Cauldron full of water with a tripwire hook above
     - define cauldronBlocks <npc.location.find.blocks[cauldron,3].within[%range%]||null>
     - if <def[cauldronBlocks].is[!=].to[null]>
       && !<def[cauldronBlocks].is_empty> {
       - define locations li@
       - foreach %cauldronBlocks% {
         - define cauldron '%value%'
         - if <def[cauldron].above.material.is[!=].to[m@tripwire_hook]||true> foreach next
 
         - define east '<def[cauldron].add[1,0,0]>'
         - define west '<def[cauldron].add[-1,0,0]>'
         - define north '<def[cauldron].add[0,0,1]>'
         - define south '<def[cauldron].add[0,0,-1]>'
         - define cardinals li@east|west|north|south
 
         - foreach %cardinals% {
           - define location '<def[%value%]>'
 
           - if <def[location].material.is[==].to[m@air]>
             && <def[location].above.material.is[==].to[m@air]>
             && <def[location].below.material.is_solid> {
             - define locations <def[locations].include[%location%]>
             }
           }
         }
       }
 
 
   findPrep:
   # The Prep station is the top half stone slab
     - define prepBlocks <npc.location.find.blocks[stone_slab_up].within[%range%]||null>
     - if <def[prepBlocks].is[!=].to[null]>
       && !<def[prepBlocks].is_empty> {
       - define locations li@
       - foreach %prepBlocks% {
         - define prep '%value%'
         - if <def[prep].above.material.is[!=].to[m@air]||true> foreach next
 
         - define east '<def[prep].add[1,0,0]>'
         - define west '<def[prep].add[-1,0,0]>'
         - define north '<def[prep].add[0,0,1]>'
         - define south '<def[prep].add[0,0,-1]>'
         - define cardinals li@east|west|north|south
 
         - foreach %cardinals% {
           - define location '<def[%value%]>'
 
           - if <def[location].material.is[==].to[m@air]>
             && <def[location].above.material.is[==].to[m@air]>
             && <def[location].below.material.is_solid> {
             - define locations <def[locations].include[%location%]>
             }
           }
         }
       }
 
 
   findOven:
   # The oven is a furnace
 
 
   findStove:
   # The Stove is a furnace with a stone pressure plate on top