From b5845f288479b78f4120b167aef085aaf80b9497 Mon Sep 17 00:00:00 2001 From: atom0s Date: Sun, 28 May 2017 19:03:51 -0700 Subject: [PATCH] Adjusted the command parser to be more friendly with quotes and spaces. --- repeater.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/repeater.lua b/repeater.lua index 8ff12b4..477e4f8 100644 --- a/repeater.lua +++ b/repeater.lua @@ -25,7 +25,7 @@ _addon.author = 'bluekirby'; _addon.name = 'repeater'; -_addon.version = '3.0.0'; +_addon.version = '3.0.1'; require 'common' @@ -47,6 +47,22 @@ function read_fps_divisor() -- borrowed from fps addon return ashita.memory.read_uint32(addr + 0x30); end; +function quoted_concat(t, s, o) + if (o == nil) then return ''; end + if (o > #t) then return ''; end + + local ret = ''; + for x = o, #t do + local spaces = string.find(t[x], " "); + if (spaces) then + ret = ret .. string.format('"%s"%s', t[x], s); + else + ret = ret .. string.format('%s%s', t[x], s); + end + end + return ret; +end + ashita.register_event('load', function(cmd, nType) __go = false; __command = ""; @@ -62,7 +78,8 @@ ashita.register_event('command', function(cmd, nType) elseif (#args < 2) then return true; elseif ((args[2] == 'set') and (#args >= 3)) then - __command = table.concat(args," ",3,#args); + __command = quoted_concat(args," ",3); + __command = string.trim(__command); print ("Command to be repeated: " .. __command); return true; elseif (args[2] == 'start') then