I want to add a function that, if tArgs[2] (the second argument) equals "-l" then the rest of that is the label
When you say 'label', do you mean the name of the chat box?
I didn't know you could set the name, but the mod I used to use may have updated, or you might be using a mod I don't know about.
Anywho, it shouldn't really matter, I just wanted to know.
Some preliminary sudo-code:
Spoiler
(When using the 'say' command)
tArgs[1] will be "say"
tArgs[2] to tArgs[#tArgs] will the message.
However, if "-l" is an argument inbetween tArgs[2] to tArgs[#tArgs], then tArgs[2] to tArgs[ pos of "-l" - 1 ] is the message, and tArgs[ pos of "-l" + 1 ] to tArgs[ #tArgs ] is the labelSo with that in mind:
tArgs = {...}
local labelPos = #tArgs+1 --# A variable to store the position of "-l" - It defaults to the length of tArgs
for i = 3, #tArgs do --# Start from 3, 1 is "say" and 2 is the message - lets assume the message has to be at least 1 word
if tArgs[i] == "-l" then
labelPos = i
break
end
end
local msg = {} --# Stores the message
local label = {} --# Stores the label, if there was one
for i = 2, labelPos-1 do --# Continue until one before "-l", or the end of tArgs if we didn't find "-l"
msg[ i-1 ] = tArgs[i] --# Copy the message from tArgs to msg
end
msg = table.concat(tArgs , " " , 2 , labelPos-1)
label = table.concat(tArgs , " ", labelPos+1 , #tArgs)
--# Note the second one shouldn't do anything if "-l" wasn't found
When this code has finished, 'label' and 'msg' will each be a string.
This SHOULD work, though I may have made an off-by-one error somewhere - its 11:41 PM :P/>Tested, it works as intended
Any questions feel free to ask :)/>