Jump to content




Grabbing Arguments


  • You cannot reply to this topic
4 replies to this topic

#1 Csstform

  • Members
  • 410 posts
  • LocationU.S.A.

Posted 23 April 2014 - 03:18 PM

Alright. I know how to grab arguments when the program is run, tArgs and all that, but is there any way to grab text with io.read() or something, then look for arguments in that? Thanks.

#2 OReezy

  • Members
  • 91 posts

Posted 23 April 2014 - 04:25 PM

Check out the string library.
http://lua-users.org...LibraryTutorial

Once you have your string you can use functions like string.match() to search for words or patterns.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 23 April 2014 - 04:46 PM

Check out how the shell splits them out of the command string if you're looking for similar functionality.

#4 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 23 April 2014 - 07:01 PM

Here's a little function that I threw together
function getArguments( mask )
    local args = {}
    local input = read( mask )
    for word in input:gmatch("%S+") do
        table.insert( args, word )
    end
    return args
end
But you should check out this code and the lua wiki aswell to get a better understanding of it.

#5 Csstform

  • Members
  • 410 posts
  • LocationU.S.A.

Posted 23 April 2014 - 09:10 PM

Thanks, guys!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users