Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local positions = {
- -- input your positions for all your lights here
- -- {x,y,z,rotation}
- }
- local lights = {}
- function createLight(x,y,z,rotation)
- local id = #lights+1
- lights[id] = {
- objects = {
- createObject(2889, x, y, z, 0, 0, 129.40130615234),
- createObject(2888, x, y, z, 340, 0, 129.40130615234),
- bulb = createObject(2887, x, y, z, 340, 0, 129.40130615234),
- }
- }
- return id
- end
- function setLightActivated(id,state)
- if state == true then
- if lights[id].light ~= nil then return end
- local posX, posY, posZ = getElementPosition(lights[id].objects.bulb)
- local spotLightObjectMatrix = getElementMatrix(lights[id].objects.bulb)
- local targetPos = Vector3(spotLightObjectMatrix[4][1] + spotLightObjectMatrix[2][1] * 50, spotLightObjectMatrix[4][2] + spotLightObjectMatrix[2][2] * 50, spotLightObjectMatrix[4][3] + spotLightObjectMatrix[2][3] * 50)
- lights[id].light = createSearchLight(posX, posY, posZ+0.85,targetPos, 0.5, 20)
- else
- if lights[id].light == nil then return end
- destroyElement(lights[id].light)
- lights[id].light = nil
- end
- end
- function setAllLightsActivated(state)
- for id,_ in pairs(lights) do
- setLightsActivated(id,state)
- end
- end
- function createAllLights()
- for _,pos in ipairs(positions) do
- createLight(pos.x,pos.y,pos.z,pos.rot or 0)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement