Help with your scripting

Light Flicker

Light Flicker

Postby TattieBoJangle » 08 Dec 2016, 21:54

Trying to get a point light to flicker anyone got any idea ?

Code: Select all
intensity={}
intensity[0] = 1.1
intensity[1] = 0.9
intensity[2] = 1.2
intensity[3] = 0.8
intensity[4] = 1.1
intensity[5] = 0.8
intensity[6] = 1.3
intensity[7] = 0.8
intensity[8] = 1.1
intensity[9] = 1.18
intensity[10] = 0.9
intensity[11] = 1.3
intensity[12] = 0.7
intensity[13] = 1.2
intensity[14] = 0.9

count = 0
firstTimer = 0
obj = 0;
function onInit( objID )

   sky.lprint("script is active");
   obj = objID
   difR,difG,difB = light.getDiffuseColor(obj)
   rand = math.random(1,100)
   firstTimer = 1
   time.startTimer( 1, obj, 100 );

   sky.lprint("init complete");
end

function onTimer( )
   sky.lprint("timer.. running");

   if(firstTimer == 0)then
      if(count == 15)then
         count = 0
      else
         value = intensity[count]
         light.setIntensity(obj,value)
         count = count + 1
      end
   else
      time.stopTimer( 1, obj )
      firstTimer = 0
      time.startTimer( 1, obj, 100 )
   end
end

function onStop( )
   time.stopTimer( 1, obj )
   light.setDiffuseColor(obj,difR,difG,difB)
end
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Community Manager
Community Manager
 
Posts: 858
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative

Re: Light Flicker

Postby SolarPortal » 08 Dec 2016, 22:00

yes, it works fine. But since its a script it will only run in play the game.

Here is the code back without the lprints which will slow it down.
Code: Select all
intensity={}
intensity[0] = 1.1
intensity[1] = 0.9
intensity[2] = 1.2
intensity[3] = 0.8
intensity[4] = 1.1
intensity[5] = 0.8
intensity[6] = 1.3
intensity[7] = 0.8
intensity[8] = 1.1
intensity[9] = 1.18
intensity[10] = 0.9
intensity[11] = 1.3
intensity[12] = 0.7
intensity[13] = 1.2
intensity[14] = 0.9

count = 0
firstTimer = 0
obj = 0;
function onInit( objID )

   --sky.lprint("script is active");
   obj = objID
   difR,difG,difB = light.getDiffuseColor(obj)
   rand = math.random(1,100)
   firstTimer = 1
   time.startTimer( 1, obj, 100 );

 --  sky.lprint("init complete");
end

function onTimer( )
  -- sky.lprint("timer.. running");

   if(firstTimer == 0)then
      if(count == 15)then
         count = 0
      else
         value = intensity[count]
         light.setIntensity(obj,value)
         count = count + 1
      end
   else
      time.stopTimer( 1, obj )
      firstTimer = 0
      time.startTimer( 1, obj, 100 )
   end
end

function onStop( )
   time.stopTimer( 1, obj )
   light.setDiffuseColor(obj,difR,difG,difB)
end


If you cant see the light, make sure you dont have overpowering sunlight as you wont see smaller lights unless slightly darker.
Also make sure the point light is encompassing models :D

Hope this helps :D
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Light Flicker

Postby epsilonion » 08 Dec 2016, 22:01

Is that the script from the Asset store?
There was a problem with that, I reported it in the thread I made before.. :)
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: Light Flicker

Postby TattieBoJangle » 08 Dec 2016, 22:02

yes, it works fine. But since its a script it will only run in play the game.


haha my bad works great now :lol:
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Community Manager
Community Manager
 
Posts: 858
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron