Module:Explode: Difference between revisions

From StrategyWiki, the video game walkthrough and strategy guide wiki
added necessary syntax to make the function a child of p
(added local p)
(added necessary syntax to make the function a child of p)
Line 3: Line 3:
]]--
]]--
local p = {}
local p = {}
function explode(div,str) -- credit: http://richard.warburton.it
 
function p.explode(div,str) -- credit: http://richard.warburton.it
 
   if (div=='') then return false end
   if (div=='') then return false end
   local pos,arr = 0,{}
   local pos,arr = 0,{}
Line 13: Line 15:
   table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
   table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider
   return arr
   return arr
end
end


return p
return p