WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   save string to variable from slash command? (https://www.wowinterface.com/forums/showthread.php?t=57646)

daylighted 10-30-19 12:38 PM

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?

daylighted 10-30-19 12:41 PM

think the thread got double posted? sorry, no idea why

daylighted 10-30-19 01:26 PM

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


All times are GMT -6. The time now is 03:27 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI