From e96fda96770f3882c439fe10eae9f5275bea5b4e Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 26 Apr 2017 16:48:03 +0200 Subject: [PATCH 1/3] added included plugin named delay, beware: this uses markerTag fix and setJSON to work!! --- BangCommands/Included/delay.js | 47 +++++++++++++++++++ .../Included/delay_support_module.mcc | 7 +++ 2 files changed, 54 insertions(+) create mode 100644 BangCommands/Included/delay.js create mode 100644 BangCommands/Included/delay_support_module.mcc diff --git a/BangCommands/Included/delay.js b/BangCommands/Included/delay.js new file mode 100644 index 0000000..4cbb139 --- /dev/null +++ b/BangCommands/Included/delay.js @@ -0,0 +1,47 @@ +/* +author: mrjvs +*/ + +var delay = {}; + + +delay.Install = function (smelt) { + smelt.addSupportModule("delay_support_module.mcc"); +}; + +delay.HowTo = function () { + var usage = "\n Usage:\n\n !delay ticks conditional command\n Ticks, int: how many ticks delay it before the command runs.\n Conditional, boolean: if the delay chain command block needs to be conditional or not.\n Command, string: what command to delay.\n\n Example: !delay 20 true /say hello there\n"; + return usage; +} + +delay.Execute = function(smelt) { + + function makeid() { + var text = "", + possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + i = 0; + for (i=0; i < 5; i++ ) + text += possible.charAt(Math.floor(Math.random() * possible.length)); + + return text; + } + + var markerId = makeid(); + var command = smelt.args[3]; + + for (var i = 4; i < smelt.args.length; i++) { + command += " " + smelt.args[i]; + } + + var options = {}; + options["type"] = "chain"; + options["auto"] = true; + options["conditional"] = smelt.args[2]; + smelt.addCommandBlock("execute @e[tag=" + markerId + ",type=area_effect_cloud,c=1] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {Tags:[\"comDelay\"],Particle:\"take\",Age:-" + smelt.args[1] + "}", options); + smelt.addCommandBlock(command,{auto:false,type:"impulse",conditional:false,markerTag:markerId}); + + smelt.setJSON({markerTag:""}); + +}; + +module.exports = delay; \ No newline at end of file diff --git a/BangCommands/Included/delay_support_module.mcc b/BangCommands/Included/delay_support_module.mcc new file mode 100644 index 0000000..5a7dba7 --- /dev/null +++ b/BangCommands/Included/delay_support_module.mcc @@ -0,0 +1,7 @@ +# Delay Mechanism +>{"type":"repeating-chain","auto":true} +/scoreboard players tag @e[tag=comDelay] add comDelayDone {Age:-1} + >{"conditional":true} + /execute @e[tag=comDelayDone] ~ ~ ~ blockdata ~ ~ ~ {auto:1b} + /execute @e[tag=comDelayDone] ~ ~ ~ blockdata ~ ~ ~ {auto:0b} + /kill @e[tag=comDelayDone] \ No newline at end of file From a38b826d6d45cce6762f4913deb7e0807bc79df2 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 26 Apr 2017 23:34:46 +0200 Subject: [PATCH 2/3] Made it compatible with smelt support module --- BangCommands/Included/delay.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/BangCommands/Included/delay.js b/BangCommands/Included/delay.js index 4cbb139..c28e897 100644 --- a/BangCommands/Included/delay.js +++ b/BangCommands/Included/delay.js @@ -7,8 +7,20 @@ var delay = {}; delay.Install = function (smelt) { smelt.addSupportModule("delay_support_module.mcc"); + switch(smelt.settings.Output.MinecraftVersion) + { + case "1.9": + case "1.10": + smelt.addSupportModule("smelt-for-1.9.mcc"); + break; + case "1.11": + default: + smelt.addSupportModule("smelt-for-1.11.mcc"); + break; + } }; + delay.HowTo = function () { var usage = "\n Usage:\n\n !delay ticks conditional command\n Ticks, int: how many ticks delay it before the command runs.\n Conditional, boolean: if the delay chain command block needs to be conditional or not.\n Command, string: what command to delay.\n\n Example: !delay 20 true /say hello there\n"; return usage; @@ -37,11 +49,9 @@ delay.Execute = function(smelt) { options["type"] = "chain"; options["auto"] = true; options["conditional"] = smelt.args[2]; - smelt.addCommandBlock("execute @e[tag=" + markerId + ",type=area_effect_cloud,c=1] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {Tags:[\"comDelay\"],Particle:\"take\",Age:-" + smelt.args[1] + "}", options); + smelt.addCommandBlock("execute @e[tag=" + markerId + ",type=area_effect_cloud,c=1] ~ ~ ~ summon minecraft:area_effect_cloud ~ ~ ~ {Tags:[\"aecDelay\"],Particle:\"take\",Age:-" + smelt.args[1] + "}", options); smelt.addCommandBlock(command,{auto:false,type:"impulse",conditional:false,markerTag:markerId}); - smelt.setJSON({markerTag:""}); - }; -module.exports = delay; \ No newline at end of file +module.exports = delay; From 551ae66f8ce7f31633b7d7d0a5534d75419cb15f Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 26 Apr 2017 23:35:34 +0200 Subject: [PATCH 3/3] Delete delay support --- BangCommands/Included/delay_support_module.mcc | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 BangCommands/Included/delay_support_module.mcc diff --git a/BangCommands/Included/delay_support_module.mcc b/BangCommands/Included/delay_support_module.mcc deleted file mode 100644 index 5a7dba7..0000000 --- a/BangCommands/Included/delay_support_module.mcc +++ /dev/null @@ -1,7 +0,0 @@ -# Delay Mechanism ->{"type":"repeating-chain","auto":true} -/scoreboard players tag @e[tag=comDelay] add comDelayDone {Age:-1} - >{"conditional":true} - /execute @e[tag=comDelayDone] ~ ~ ~ blockdata ~ ~ ~ {auto:1b} - /execute @e[tag=comDelayDone] ~ ~ ~ blockdata ~ ~ ~ {auto:0b} - /kill @e[tag=comDelayDone] \ No newline at end of file