Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function index:strech(x, y)
- local tbl = self
- if not self then
- error("try using : instead of .", 0)
- end
- if type(x) == "number" and type(y) == "number" then
- local strechmap = {}
- local strechmapy = {}
- local final
- local mulx = 1
- local muly = 1
- strechmap["offset"] = tbl.offset
- strechmapy["offset"] = tbl.offset
- for k, v in pairs(tbl) do
- if type(k) == "number" then
- for k2, v2 in pairs(v) do
- for i = 1, x do
- if x > 1 then
- mulx = x
- end
- if not strechmap[k * mulx + i] then
- strechmap[k * mulx + i] = {}
- end
- if not strechmap[k * mulx + i][k2] then
- strechmap[k * mulx + i][k2] = {}
- end
- strechmap[k * mulx + i][k2] = tbl[k][k2]
- end
- end
- end
- end
- if y > 1 then
- for k, v in pairs(strechmap) do
- if type(k) == "number" then
- for k2, v2 in pairs(v) do
- for i = 1, y do
- if y > 1 then
- muly = y
- end
- if not strechmapy[k] then
- strechmapy[k] = {}
- end
- if not strechmapy[k][k2 * muly + i] then
- strechmapy[k][k2 * muly + i] = {}
- end
- strechmapy[k][k2 * muly + i] = strechmap[k][k2]
- end
- end
- end
- end
- end
- if not next(strechmap) then
- strechmap = tbl
- end
- if y > 1 then
- final = strechmapy
- else
- final = strechmap
- end
- return setmetatable(final, getmetatable(tbl))
- else
- return tbl
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement