generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Adding multiple light sources

Previous Thread :: Next Thread 
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
09 Jun 2016 04:39 PM
I made a rudimentary tile lighting system here:
https://www.roblox.com/games/429844472/Tile-lighting-systme#

and I thought about how easy it would be to add another light source?

Would it be easy and how would I go about doing it?


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
09 Jun 2016 04:44 PM
to clarify, I'm not asking for an entire script. I'm just asking for basic information on how to go about adding multiple light sources


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
09 Jun 2016 05:18 PM
it depends on how you made this script
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 02:06 AM
bv


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 02:06 AM
"it depends on how you made this script"

i loop through the grid and make the surfaceguis on there change color based on their distance from the lightsource.


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 09:13 AM
bz


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 10:15 AM
xz


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 10:40 AM
b


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
MiniNob is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
10 Jun 2016 10:50 AM
easy just average the values
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 10:51 AM
"easy just average the values"

can you elaborate


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
MiniNob is not online. MiniNob
Joined: 14 May 2013
Total Posts: 822
10 Jun 2016 10:55 AM
like when there are multiple light intensities on each tile, you do the average their Color3 values to find the tile's color
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
10 Jun 2016 10:55 AM
Don't average them.

Either add them or pick the highest.
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 11:21 AM
still don't know what you're asking me to do

if it makes it any better, here's my loop.

game["Run Service"].RenderStepped:connect(function()
local lightFact = (lightSource.Position-v.Position).magnitude
lightBrightness = lightPower - (lightFact*10)/255
if lightFact < 40 then
v.SurfaceGui.Frame.BackgroundColor3 = v.SurfaceGui.Frame.BackgroundColor3.r >= 0 and Color3.new((100/255)+lightBrightness*.85,(50/255)+lightBrightness*.85,10/255+lightBrightness) or Color3.new(0,0,0)
elseif lightFact > 40 and lightFact < 41 and v.SurfaceGui.Frame.BackgroundColor3.r > 0 then
v.SurfaceGui.Frame.BackgroundColor3 = Color3.new(0,0,0)
end
end)

the if statement checking if lightfact is higher than 40 is so that it doesn't keep on making parts that are far away black (which causes lag)


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 11:37 AM
b


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 11:48 AM
b2


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 12:02 PM
b


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 12:26 PM
bbb


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 01:11 PM
\\\


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
10 Jun 2016 04:43 PM
Is that renderstepped script inside of each tile?
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 04:46 PM
no but it's inside the loop that goes through the model which holds the tile (v being the tile)


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
BanTech is not online. BanTech
Joined: 31 Dec 2015
Total Posts: 886
10 Jun 2016 04:53 PM
Oh right okay, you only need one of those renderstepped events to be honest, and have a loop that goes through each tile in there if you want. But anyway, here's an idea based on what you provided:

-- This table would be near the start of your script
local lightSources = {}

-- This loop would go inside some initiation function or in the body of the script
for _, child in pairs(LIGHTSOURCEPARENT:GetChildren()) do
if child.Name == 'LightSource' then
table.insert(lightSources, child)
end
end

game["Run Service"].RenderStepped:connect(function()
local lightFact = 0

for _, lightSource in pairs(lightSources) do
local newFact = (lightSource.Position-v.Position).magnitude
lightFact = newFact > lightFact and newFact or lightFact
end

local lightBrightness = lightPower - (lightFact*10)/255

if lightFact < 40 then
v.SurfaceGui.Frame.BackgroundColor3 = v.SurfaceGui.Frame.BackgroundColor3.r >= 0 and Color3.new((100/255)+lightBrightness*.85,(50/255)+lightBrightness*.85,10/255+lightBrightness) or Color3.new(0,0,0)
elseif lightFact > 40 and lightFact < 41 and v.SurfaceGui.Frame.BackgroundColor3.r > 0 then
v.SurfaceGui.Frame.BackgroundColor3 = Color3.new(0,0,0)
end
end)
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 05:06 PM
they cancel eachother out.

they don't have an individual light


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
10 Jun 2016 05:08 PM
Average it
Report Abuse
badfitz67 is not online. badfitz67
Joined: 03 Jun 2010
Total Posts: 13165
10 Jun 2016 05:09 PM
"Average it"

i dont understand how to do that

please explain yourself


Goosey Goosey Gander. Whither dost thou wander? Only through the Rhineland Pray excuse my Blunder!
Report Abuse
iiEssence is not online. iiEssence
Joined: 18 Jun 2014
Total Posts: 3467
10 Jun 2016 05:10 PM
Get the r,g,b values of all light sources

add each of the r,g,b values individually

divide the sums by the number of the light sources

Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image