Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --nullifier.lua by Enjl
- --makes it so a range of priorities is not drawn in certain locations, tied to a BGO ID
- --Ver 1.0
- local nullifier = {}
- local registeredRanges = {}
- --CHANGE THIS to change which BGO becomes a nullifier
- nullifier.id = 1
- local tableinsert = table.insert
- local cb = Graphics.CaptureBuffer(800, 600)
- --CALL THIS to add a range of priorities which the nullifier should skip over
- function nullifier.addRange(min, max)
- if min > max then
- max, min = min, max
- end
- tableinsert(registeredRanges, {capturePriority = min, drawPriority = max})
- end
- function nullifier.onInitAPI()
- registerEvent(nullifier, "onCameraDraw")
- registerEvent(nullifier, "onStart")
- end
- function nullifier.onStart()
- if #BGO.get(nullifier.id) == 0 then
- unregisterEvent(nullifier, "onCameraDraw")
- end
- end
- local function insertVertices(t, x1, y1, x2, y2)
- tableinsert(t, x1)
- tableinsert(t, y1)
- tableinsert(t, x2)
- tableinsert(t, y1)
- tableinsert(t, x1)
- tableinsert(t, y2)
- tableinsert(t, x2)
- tableinsert(t, y1)
- tableinsert(t, x1)
- tableinsert(t, y2)
- tableinsert(t, x2)
- tableinsert(t, y2)
- end
- function nullifier.onCameraDraw(camIdx)
- local verts = {}
- local tex = {}
- local cam = Camera.get()[camIdx]
- local cx = cam.x
- local cy = cam.y
- local cw = cam.width
- local ch = cam.height
- for k,v in ipairs(BGO.getIntersecting(cx, cy, cx + cw, cy + ch)) do
- if v.id == nullifier.id and not v.isHidden then
- local x = v.x - cx
- local y = v.y - cy
- local xw = x + v.width
- local yh = y + v.height
- insertVertices(verts, x,y,xw,yh)
- insertVertices(tex, x/cw,y/ch,xw/cw,yh/ch)
- end
- end
- if #verts > 0 then
- for k,v in ipairs(registeredRanges) do
- cb:captureAt(v.capturePriority)
- Graphics.glDraw{
- vertexCoords = verts,
- textureCoords = tex,
- texture = cb,
- priority = v.drawPriority,
- primitive = Graphics.GL_TRIANGLES
- }
- end
- end
- end
- return nullifier
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement