Author Topic: Need help with lua/computercraft  (Read 412 times)

Why wont this code work.

the variables = space or nil im not sure it does not print out anything though.

Code: [Select]
  cmd = "1|Send[ 10 20]{3}message"
 
  elseif string.find(cmd,"%|Send") ~= nil then
    message = string.gsub(cmd,"(.-)}","")
    _, _, idList = string.match(cmd,"%[(.+)%]")
    --idList = string.gsub(idList,"[","")
    --idList = stirng.gsub(idList,"]","")
    print(idList)
    _, _, sender = string.match(cmd,"{(.+)}")
    --sender = string.gsub(sender,"{","")
    --sender = string.gsub(sender,"}","")
    print(sender)
   
    print(message)


What the forget is "_, _, sender"

string.match only returns the match and not where the match was found, i think that's where you're confused. e.g. it should just be

idList = string.match(cmd,"%[(.+)%]")

without the _, _, at the beginning.