So I have this custom echo function. It looks like this:
vg.echo = function(arg)
echo("\n")
local str = {}
local strNumber = 1
local strLimit = 64
local echoString = ""
local splitStr = string.split(arg, " ")
arg = ""
for i = 1, #splitStr do
arg = arg .. splitStr[i] .. " "
if arg:len() > strLimit then
if #str == 0 then
table.insert(str, strNumber, string.cut("<lavender>" .. arg .. " ", 79))
str[strNumber] = str[strNumber] .. "<dark_khaki>|"
arg = ""
strNumber = strNumber+1
elseif #str > 0 then
table.insert(str, strNumber, string.cut("<dark_khaki>|<lavender> " .. arg .. " ", 93))
str[strNumber] = str[strNumber] .. "<dark_khaki>|"
arg = ""
strNumber = strNumber+1
end
end
end
if #str > 0 and arg:len() > 0 then
table.insert(str, strNumber, string.cut("<dark_khaki>|<lavender> " .. arg .. " ", 93))
str[strNumber] = str[strNumber] .. "<dark_khaki>|"
arg = ""
end
if arg:len() < strLimit and #str == 0 then
table.insert(str, strNumber, string.cut("<lavender>" .. arg .. " ", 79))
str[strNumber] = str[strNumber] .. "<dark_khaki>|"
arg = ""
strNumber = strNumber+1
end
for i,v in ipairs(str) do
echoString = echoString .. str[i] .. "\n"
end
if #str > 0 then
cecho("<dark_khaki>+=<orange_red> Vanguard<dark_khaki> " .. string.rep("=", 59) .. "+\n")
cecho("<dark_khaki>| " .. echoString)
cecho("<dark_khaki>+" .. string.rep("=", 70) .. "+\n")
end
end
I'm having a really weird problem with it. If I give it a one line argument from an alias, it works fine:
lua vg.echo("Balance recovered!")
echos:
+= Vanguard ===========================================================+
| Balance recovered! |
+======================================================================+
However, if I set up a trigger with the same exact function call, I get this:
+= Vanguard ===========================================================+
| Balance recovered!
|
+======================================================================+
I really don't understand how that linebreak is getting there. The same function call echos the string correctly from an alias, the linebreak ONLY sneaks in there when it's called from a trigger. What's going on?