Paste #11145: Diff note for paste #11144

Date: 2014/11/10 15:52:29 UTC-08:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


 SetBlocksCommand:
   type: command
   debug: false
   name: /set
   description: Sets each block in the selected region.
   usage: //set [<&lt>material<&gt>]
   script:
   - define material <context.args.get[1]||null>
   - define 1 l@<player.name>CurrentSelectedRegion1
   - define 2 l@<player.name>CurrentSelectedRegion2
   - if %material% == null || %material% !matches material narrate "<red>Must specify a valid material."
     else if <def[1]||null> == null narrate "<red>Must select corner 1 with left-click."
     else if <def[2]||null> == null narrate "<red>Must select corner 2 with right-click."
     else {
     - define blocks <cu@%1%|%2%.get_blocks>
-    - define list ""
+    - define undoMaterials <def[blocks].parse[material.full]>
-    - foreach %blocks% {
-      - define mat <def[value].material>
-      - if <def[%mat%]||null> == null define %mat% <def[value].simple>
-      - define %mat% <def[%mat%]>|<def[value].simple>
-      }
     - modifyblock %blocks% <context.args.get[1]>
-    - foreach <queue.definitions.filter[starts_with[m@]]> {
+    - flag global "UndoableActions:->:set_blocks;<cu@%1%|%2%>;%list%"
-      - define list %list%%value%/<def[%value%].escaped>;
-      }
-    - flag global "UndoableActions:->:set_blocks;%list%"
     }
 
 UndoCommand:
   type: command
   debug: false
   name: /undo
   description: Undo the last action.
   usage: //undo
   script:
   - define last_action <server.flag[UndoableActions].as_list.last||null>
   - if %last_action% == null narrate "<red>Nothing to undo."
     else {
     - ^inject locally "path:<def[last_action].split[;].get[1]>"
     - ^flag global "UndoableActions:<-:%last_action%"
     }
   set_blocks:
-  - define split_info <def[last_action].split[;].exclude[set_blocks]>
-  - foreach %split_info% {
-    - define s <def[value].split[/]>
-    - modifyblock <def[s].get[2].unescaped> <def[s].get[1]>
+  - define cuboid <def[last_action].split[;].get[2].as_cuboid.get_blocks||null>
+  - define materials <def[last_action].split[;].get[3]||li@>
+  - foreach %cuboid% {
+    - define material <def[materials].get[%loop_index%]>
+    - if <def[value].material.full.is[==].to[material]> foreach next
+    - modifyblock %value% %material%
     }
   - ^narrate "Successfully undid all modified blocks."