Jump to content

Module:Inventory slot: Difference between revisions

m
Added parseString function to take a string and treat it to generate the item with a name
imported>Ttv pedro270707
(DOES NOT WORK currently!)
imported>Ttv pedro270707
m (Added parseString function to take a string and treat it to generate the item with a name)
Line 28: Line 28:
return slotContainer
return slotContainer
end
function p.parseString(input)
  local strings = {}
  for str in input:gmatch("[^;]+") do
    table.insert(strings, str:match("^%s*(.-)%s*$"))
  end
  local result = {}
  for _, str in ipairs(strings) do
    local name, item = str:match("^%[(.-)%](.*)$")
    if name then
      table.insert(result, { name = name:gsub("^%s*(.-)%s*$", "%1"), item = item:gsub("^%s*(.-)%s*$", "%1") })
    else
      table.insert(result, { name = str:gsub("^%s*(.-)%s*$", "%1"), item = str:gsub("^%s*(.-)%s*$", "%1") })
    end
  end
  return result
end
end


return p
return p