Module:Explode: Difference between revisions
From StrategyWiki, the video game walkthrough and strategy guide wiki
removed broken/unused functions
Notmyhandle (talk | contribs) (more debugging formatting) |
Notmyhandle (talk | contribs) (removed broken/unused functions) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
function p.explode(frame) | function p.explode(frame) | ||
--[[ | --[[ | ||
By Notmyhandle | By Notmyhandle, working August 9th, 2014, compatibility is Lua 5.1 or 5.2, not sure | ||
args: | args: | ||
1:string | 1:string | ||
Line 15: | Line 15: | ||
local finalstring,rindex,s,e = 0 | local finalstring,rindex,s,e = 0 | ||
local rindexdebug,capturedstring,capturedstringdebug = "string" | local rindexdebug,rindexnegativedebug,capturedstring,capturedstringdebug = "string" | ||
--capture the starting index | --capture the starting index | ||
s = string.find(frame.args[1],frame.args[2]) | s = string.find(frame.args[1],frame.args[2]) | ||
Line 21: | Line 21: | ||
if (frame.args[3]=='left') then | if (frame.args[3]=='left') then | ||
--capture the index of the left side of the first delimiter character | --capture the index of the left side of the first delimiter character | ||
rindex = (s) | rindex = (s-1) | ||
rindexdebug = string.format ("%s %d %s", "rindex = ", rindex, "<br>") | capturedstring = string.sub(frame.args[1], 1, rindex) | ||
if (frame.args[4]=='debug') then | |||
rindexdebug = string.format("%s %d %s", "rindex = ", rindex, "<br>") | |||
rindexnegative = rindex * -1 | |||
rindexnegativedebug = string.format("%s %d %s", "rindexnegative = ", rindexnegative, "<br>") | |||
capturedstringdebug = string.format("%s %s", "capturedstring = ", capturedstring) | |||
finalstring = string.format("%s %s %s", rindexdebug, rindexnegativedebug, capturedstringdebug) | |||
else | |||
finalstring = capturedstring | |||
end | |||
else | else | ||
--capture the index of the right side of the first delimiter character | --capture the index of the right side of the first delimiter character | ||
Line 34: | Line 40: | ||
return finalstring | return finalstring | ||
end | end | ||
Line 67: | Line 52: | ||
]]-- | ]]-- | ||
return string.find(frame.args[1],frame.args[2],frame.args[3],frame.args[4]) | return string.find(frame.args[1],frame.args[2],frame.args[3],frame.args[4]) | ||
end | end | ||
return p | return p |