Solved BeamNGTrigger enable PointLight

Discussion in 'Mod Support' started by Car_Killer, Jun 26, 2018.

  1. Car_Killer

    Car_Killer
    Expand Collapse
    QA / Mod Support
    BeamNG Team

    Joined:
    Sep 24, 2013
    Messages:
    1,542
    I want to create Trigger which enable PointLight for some time. Anybody can help?
     
  2. meywue

    meywue
    Expand Collapse
    Administrator
    BeamNG Team

    Joined:
    Nov 19, 2015
    Messages:
    340
    One approach could be something like this:

    Code:
    local M = {}
    
    local light
    local isOn = false
    local timer = 3
    
    local function onClientStartMission()
      light = scenetree.findObject('myPointLight')
    end
    
    local function onUpdate(dt)
      if isOn then
        timer = timer - dt
      end
      if timer < 0 then
        timer = 3
        isOn = false
        if light then
          light.isEnabled = false
        end
      end
    end
    
    local function onBeamNGTrigger(data)
      dump(data)
      if data.triggerName == "lightTrigger" then
        if light then
          light.isEnabled = true
          isOn = true
        end
      end
    end
    
    M.onClientStartMission = onClientStartMission
    M.onUpdate = onUpdate
    M.onBeamNGTrigger = onBeamNGTrigger
    
    return M
    Video - Click to Play - Direct Link
     

    Attached Files:

    • Like Like x 2
  3. Car_Killer

    Car_Killer
    Expand Collapse
    QA / Mod Support
    BeamNG Team

    Joined:
    Sep 24, 2013
    Messages:
    1,542
    Thanks for help. Everything works great.As always quick response of support ;)

    Gfycat Video - Click to Play - Direct Link
     
    • Like Like x 4
  4. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,685
    Ahah that's pretty neat/creative :D
     
    • Like Like x 1
    • Agree Agree x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice