FANDOM


local p = {}
 
-- Checks if an index of a table is empty
function empty(s)
    if s == nil or s == '' then 
        return true
    else
        return false
    end
end
 
-- Slices an image up into bits
function p.slice(s)
    if empty(s.args[1]) or empty(s.args[2]) then
        return '<span class="module-error">Please supply the width and height of the image</span>'
    end
 
    if empty(s.args[3]) or empty(s.args[4]) then
        return '<span class="module-error">Please supply number of rows and columns to split into</span>'
    end
 
    if empty(s.args[5]) then
        return '<span class="module-error">Please supply slice width</span>'
    end
 
    if empty(s.args[6]) then
        return '<span class="module-error">Please supply image url</span>'
    end
 
    local table = '<table>'
 
          -- Generate split image
          local wx = s.args[1] / s.args[4]     -- width of image / # of columns
          local hx = s.args[2] / s.args[3]     -- height of image / # of rows
 
          for j = 0, s.args[3] - 1, 1 do
              table = table .. '<tr>'
 
              for i = 0, s.args[4] - 1, 1 do
                  table = table .. '<td>' .. s.args[6] .. '/window-crop/width/' .. s.args[5] .. '/x-offset/' .. wx * i .. '/y-offset/' .. hx * j .. '/window-width/' .. wx .. '/window-height/' .. hx .. '</td>'
              end
 
              table = table .. '</tr>'
          end
 
    table = table .. '</table>'
 
    return table
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.