Fireflies turning on and off
Posted: Wed Jan 07, 2015 7:51 pm
Hi guys
i'm new here, and almost new in programming (absolutely new in Lua).
I have a problem with a script to make fireflies appear only during night. I started from skugg code and tried to make something suited me more.
Here is the code:
function lucciole()
-- in 10 passage
tempoInizio = 1.02 -- starting time of the turning lights on
tempoFine = 1.98 -- end time of turninglights of
lucePartenza = 4 -- light brightness when fully lightened (4 is standard)
numeroSciami = 1 -- how much fireflies swarms i have in map
-- turning on
if GameMode.getTimeOfDay() >= tempoInizio and GameMode.getTimeOfDay() < tempoInizio+0.01 then
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:enable()
nomeSciame.light:setBrightness(lucePartenza-3.2)
else end
end
elseif
//
missing code, here i cut to be shorter, basically is the same repeated for 10 times increasing time and brightness nunmber
//
-- lightened during night
elseif GameMode.getTimeOfDay() >= tempoInizio+0.10 and GameMode.getTimeOfDay() < tempoFine-0.10 then
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:enable()
nomeSciame.light:setBrightness(lucePartenza)
else end
end
-- turning off
elseif GameMode.getTimeOfDay() >= tempoFine-0.10 and GameMode.getTimeOfDay() < tempoFine-0.9 then
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:enable()
nomeSciame.light:setBrightness(lucePartenza)
else end
end
elseif
//
missing code, here i cut to be shorter, basically is the same repeated for 10 times decreasing time and increasing brightness nunmber
//
-- fireflies during day, not visible
else
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:disable()
nomeSciame.light:disable()
else end
end
end
end
but i have an issue, i guess with nomeSciame in nomeSciame.particle:anable()
i receive: attempt to index field 'particle' (a nil value)
can't imagine why i receive this error, i tryed to hudprint nomeSciame and it worked fine
can someone help me? ty
-----
Here u can find my last code:
https://onedrive.live.com/redir?resid=D ... 900F%21181
i'm new here, and almost new in programming (absolutely new in Lua).
I have a problem with a script to make fireflies appear only during night. I started from skugg code and tried to make something suited me more.
Here is the code:
function lucciole()
-- in 10 passage
tempoInizio = 1.02 -- starting time of the turning lights on
tempoFine = 1.98 -- end time of turninglights of
lucePartenza = 4 -- light brightness when fully lightened (4 is standard)
numeroSciami = 1 -- how much fireflies swarms i have in map
-- turning on
if GameMode.getTimeOfDay() >= tempoInizio and GameMode.getTimeOfDay() < tempoInizio+0.01 then
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:enable()
nomeSciame.light:setBrightness(lucePartenza-3.2)
else end
end
elseif
//
missing code, here i cut to be shorter, basically is the same repeated for 10 times increasing time and brightness nunmber
//
-- lightened during night
elseif GameMode.getTimeOfDay() >= tempoInizio+0.10 and GameMode.getTimeOfDay() < tempoFine-0.10 then
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:enable()
nomeSciame.light:setBrightness(lucePartenza)
else end
end
-- turning off
elseif GameMode.getTimeOfDay() >= tempoFine-0.10 and GameMode.getTimeOfDay() < tempoFine-0.9 then
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:enable()
nomeSciame.light:setBrightness(lucePartenza)
else end
end
elseif
//
missing code, here i cut to be shorter, basically is the same repeated for 10 times decreasing time and increasing brightness nunmber
//
-- fireflies during day, not visible
else
for sciami=1,numeroSciami do
local nomeSciame="forest_fireflies_"..tostring(sciami)
if nomeSciame~=nil then
nomeSciame.particle:disable()
nomeSciame.light:disable()
else end
end
end
end
but i have an issue, i guess with nomeSciame in nomeSciame.particle:anable()
i receive: attempt to index field 'particle' (a nil value)
can't imagine why i receive this error, i tryed to hudprint nomeSciame and it worked fine
can someone help me? ty
-----
Here u can find my last code:
https://onedrive.live.com/redir?resid=D ... 900F%21181