Thread Tools Display Modes
10-30-19, 12:38 PM   #1
daylighted
A Murloc Raider
Join Date: Oct 2019
Posts: 3
save string to variable from slash command?

currently my slash command looks like this, and what i want to happen is in comments/pseudocode


Code:
local function MyAddonCommands(msg, editbox)
    if msg == "test" then
        --str1 = everything written after "test" 
    end

SLASH_HELLOWORLD1, SLASH_HELLOWORLD2 = "/test1", "/test2"

SlashCmdList["HELLOWORLD"] = MyAddonCommands
so basically, if i type

/test1 test save this string

i want "save this string" to be saved to a variable

could someone help me out on how to do this?
  Reply With Quote
10-30-19, 12:41 PM   #2
daylighted
A Murloc Raider
Join Date: Oct 2019
Posts: 3
think the thread got double posted? sorry, no idea why
  Reply With Quote
10-30-19, 01:26 PM   #3
daylighted
A Murloc Raider
Join Date: Oct 2019
Posts: 3
figured it out

made a solution using concatenation of string

Code:
    str1 = string.sub(msg, 1, 3)
    if str1 == "msg" then
        len = string.len(msg)
        str2 = string.sub(msg,5,string.len(msg))
        print("Current message: ")
        print(str2)
    end
if i type /test1 msg ddddddd

it will save ddddddd
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » save string to variable from slash command?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off