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: Darkness Detector?

Previous Thread :: Next Thread 
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
15 Apr 2015 12:18 PM
Don't ask why. I need a script that detects the darkness somehow, but I have no idea where to start. Help?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
15 Apr 2015 12:23 PM
This is not possible unless you use raycasting, you know the settings in Lighting, and you have a list of every light in your game.
Report Abuse
BowtieMod is not online. BowtieMod
Joined: 01 Apr 2013
Total Posts: 804
15 Apr 2015 12:28 PM
Ooh, this sounds fun owo
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
15 Apr 2015 12:41 PM
Not fun enough. I considered doing it, but it is somewhat boring.

Guess what though? It can work with natural light too, because of GetSunDirection.
Report Abuse
BowtieMod is not online. BowtieMod
Joined: 01 Apr 2013
Total Posts: 804
15 Apr 2015 12:46 PM
Coool

Wish they exposed the voxel functions for the light .3.
Report Abuse
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
16 Apr 2015 01:33 PM
I am thinking on making a game on the Vashta Nerada. "The flesh devouring shadows" So ROBLOX has locked the function. Great. ROBLOX! Y U DO DIS! MAIK DE FUNCTION! I am open to ideas.
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
16 Apr 2015 01:34 PM
Seems like too much trouble for a small outcome.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
16 Apr 2015 01:35 PM
It is too much trouble for a small outcome. Is detecting darkness a necessity?

-=Robo=-
Report Abuse
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
16 Apr 2015 01:43 PM
Not necessarily. But it would sure make it a lot easier. I have a few ideas if it is not possible to directly detect the shadows.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
16 Apr 2015 01:54 PM
I already pretty much told you how to. Just get the direction of the sun, and send a ray to it. If it doesn't hit anything, it is not a shadow. If it does hit something, then iterate through all the lights in your game, raycast to them based on their range, and if any of the rays doesn't hit anything, then it is not a shadow.
Report Abuse
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
16 Apr 2015 02:00 PM
Ok,thats perfect. But my problem is that I don't care about the sun, I am talking dynamic lights.
Report Abuse
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
16 Apr 2015 02:02 PM
You probably told me all I really need to know, but I have no experience in raycasting.
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
16 Apr 2015 02:04 PM
http://wiki.roblox.com/index.php?title=Raycasting
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
16 Apr 2015 02:05 PM
I think CloneTrooper1019 did this

Look at his Twitter or something. I remember seeing it
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
17 Apr 2015 12:53 PM
@Novus,
his example isn't open sourced.

-=Robo=-
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
17 Apr 2015 12:55 PM
Boohoo, ask him how then
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
17 Apr 2015 01:07 PM
Why ask him how when I already told you the best way?
Report Abuse
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
20 May 2015 11:48 AM
I know it's been a while since I came back to this post, but we didn't really finished what we started. Could someone put some time into making a darkness detector for all to use?
Report Abuse
epicbreaker is not online. epicbreaker
Joined: 23 Apr 2011
Total Posts: 2791
20 May 2015 01:05 PM
Sorry, it's fairly basic.. But it should get the job done.

ModuleScript:
------------
local function Recursion(Par, Tab)
if not Tab then
Tab = {}
end
for _,a in pairs(Par:GetChildren()) do
if a:IsA("PointLight") then
table.insert(Tab, a)
return Tab
else
Tab = Recursion(a, Tab)
end
end
return Tab
end

local this = {}

this.DetectLevel = function(self, Pos, Par)
local Lights;
if Par then
Lights = Recursion(Par)
else
Lights = Recursion(game.Workspace)
end
local Low;
for _,a in pairs(Lights) do
if not Low then
Low = (a.Brightness * a.Range) - (a.Parent.Position - Pos).magnitude
elseif (a.Brightness * a.Range) - (a.Parent.Position - Pos).magnitude > Low then
Low = (a.Brightness * a.Range) - (a.Parent.Position - Pos).magnitude
end
end
if Low < 0 then
Low = 0
end
return Low
end

return this
------------

Normal script:
-------------

Light = require(script.ModuleScript)
wait(5)
while wait(1) do
local x = Light:DetectLevel(game.Players.Player1.Character.Torso.Position)
print(x)
end
Report Abuse
kingstarwest is not online. kingstarwest
Joined: 15 Aug 2010
Total Posts: 1156
20 May 2015 01:07 PM
fairly basic he says
Report Abuse
TheCreationWorld is not online. TheCreationWorld
Joined: 02 Nov 2014
Total Posts: 568
20 May 2015 01:12 PM
Dosen't even work
Report Abuse
turdethan98 is not online. turdethan98
Joined: 31 May 2012
Total Posts: 81
20 May 2015 01:28 PM
Epic, can you explain the script?
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
20 May 2015 01:35 PM
Thats not what he wanted, he wants a script that detects where shadows are, which can also be said as, where light is not shining.
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
20 May 2015 01:36 PM
I think you'd have to strip the voxel lighting down to the core to create this, Ill also bee needing something similar for a game ill be making in 2 years.
Report Abuse
distalDigitPhalanx is not online. distalDigitPhalanx
Joined: 25 Jan 2015
Total Posts: 1509
20 May 2015 01:40 PM
Every light instance has a range property. Spotlights have an angle property. To check if a point in world space is dark, do this:
For each light in the game, compare the distance from that light to the point with that lights range. If the distance is smaller than the range, that point might be illuminated by that light. Then, for each light in range, check if there is line of sight. Then, if the light is a spotlight, check if it points close enough to the point.
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