Hello! How can I check if player in light (in dark)? I am about sun, not artificial light. Thanks.
Can anyone help me?
You can devide your map into dark and sun sectors by using "ents" library
[editline]3rd April 2013[/editline]
[LUA]
local min = Vector(0,0,0) // Origins of dark room, area.
local max = Vector(500,500,500) // Origins of dark room, area.
darkside = ents.FindInBox(min,max)
for k,v in pairs(darkside) do
if v:IsPlayer() then
v:Kill() // What happens if player try to enter the created box
print("Do not enter dark rooms on my server lol")
end
end
[/LUA]
Sry for bad English :)
[QUOTE=Maxitronix;40149398]You can devide your map into dark and sun sectors by using "ents" library
[editline]3rd April 2013[/editline]
[LUA]
local min = Vector(0,0,0) // Origins of dark room, area.
local max = Vector(500,500,500) // Origins of dark room, area.
darkside = ents.FindInBox(min,max)
for k,v in pairs(darkside) do
if v:IsPlayer() then
v:Kill() // What happens if player try to enter the created box
print("Do not enter dark rooms on my server lol")
end
end
[/LUA]
Sry for bad English :)[/QUOTE]
My gosh, no, don't do that!
[QUOTE=EvacX;40149779]My gosh, no, don't do that![/QUOTE]
Justify your opinion or offer other ways how to do it.
[url]http://wiki.garrysmod.com/page/render/ComputeLighting[/url]
[editline]4th April 2013[/editline]
That wont tell the difference between sunlight and interior light however, I think you're stuck there.
[QUOTE=Drakehawke;40150061][url]http://wiki.garrysmod.com/page/render/ComputeLighting[/url]
[editline]4th April 2013[/editline]
That wont tell the difference between sunlight and interior light however, I think you're stuck there.[/QUOTE]
Thanks for information) I knew nothing about this function
[QUOTE=Drakehawke;40150061][url]http://wiki.garrysmod.com/page/render/ComputeLighting[/url]
[editline]4th April 2013[/editline]
That wont tell the difference between sunlight and interior light however, I think you're stuck there.[/QUOTE]
You can simply do a trace to check if you're inside a room tho.
[QUOTE=Loures;40154526]You can simply do a trace to check if you're inside a room tho.[/QUOTE]
Yeah but it's still not perfect, light from the sun can illuminate rooms with windows
That's as close as you can get I think tho.
[QUOTE=Drakehawke;40150061][url]http://wiki.garrysmod.com/page/render/ComputeLighting[/url]
[editline]4th April 2013[/editline]
That wont tell the difference between sunlight and interior light however, I think you're stuck there.[/QUOTE]
[QUOTE=JetBoom;40153197][url]http://wiki.garrysmod.com/page/render/GetLightColor[/url][/QUOTE]
Is there any way to get the actual lighting level instead of the color? Or am I really misreading them?
It's a mixture of both, as a rough guide you can probably use
[lua]render.GetLightColor(pos):Length()
render.ComputeLighting(pos, norm):Length()[/lua]
GetLightColor gives you rgb in the form of numbers ranging from 0 to some arbitrary number around 5 for really bright. You'll have to test it to see. I don't remember if it gave you a vector back or 3 numbers so the light level would be sqrt(r^2 + g^2 + b^2) / 5
Sorry, you need to Log In to post a reply to this thread.