sd_DynamicAreaLighting

by Shadowdarke
Fast and easy dynamic lighting [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Shadowdarke.sd_DynamicAreaLighting##version=10

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Shadowdarke.sd_DynamicAreaLighting##version=10

2267 downloads
Version 10
Date added: Dec 12 2002
Last updated: Jul 29 2009
14 fans
The sd_DynamicAreaLighting library provides dynamic lighting with minimal cpu and bandwidth usage by shifting turfs between areas which represent varying shades of darkness.

Version 10: 5-27-08
  • Added support for custom darkness icons, including customization of how many shades of darkness there are.
  • Included several demo darkness icons and updated the demo program to allow you to switch them at runtime.


Version 9: 1-29-07
  • SetOpacity() no longer causes errors due to mob.sight settings.


Version 8: 4-6-05
  • Added some optimizations by Lummox JR.
  • Fixed a bug that caused outside areas to generate improperly. (Xooxer)


Version 7: 2-23-04
  • Added global sd_top_luminosity to cut down on the size of internally used lists.
  • Added the turf sd_LumReset() proc.
  • Changed area.New() to allow zeroing an area's sd_lighting var in the same tick it is created without the need to strip the darkness overlay manually. If you set sd_lighting after the first tick, you should be sure to remove the sd_darkimage from the area's overlays.


Version 6: 3-6-03
Extended the mob procs slightly to compensate for mob.sight settings. The old versions would allow the light to shine through opaque walls if a mob's sight was set to SEE_TURFS.

Version 5: 2-25-03
Changed the turf.sd_lumcount var to a tmp var, so sd_DAL works properly with save files.

Version 4: 12-21-02
Fixed a bug that prevented outside areas from lighting properly if sd_outside was set in the map editor.

Version 3:
Added support for daylight spilling indoors.
Fixed an error involving atoms moving into and out of the contents of non-turfs.

Version 2:
A major rehash of the internal workings. sd_DAL now works with the areas already in your game!

Anyone already using version 1 will need to make some changes. Please read the comments in the library file.

Comments

Syama108: (Nov 5 2016, 11:24 am)
I have a problem and I dont know what's going on. My head hurts trying to understand.. so here is a pic Image and video hosting by TinyPic

Little black spots everywhere!
SuperSaiyanGokuX: (Aug 4 2013, 12:51 pm)
Murder Mansion still uses it. But mostly because it's tied into the game too tightly for me to easily replace it with something nicer. At least not until I get a lot more motivated.
D4RK3 54B3R: (Aug 4 2013, 12:08 pm)
People still use this and not my own or FIREking's or Forum_Account's alternatives?
Plemith: (Aug 3 2013, 8:50 am)
var
daytime = "" // Used by mob/Stat() to disply the time of day

world
New()
..()
#if DM_VERSION>=400
// Only use the alpha blended icon if supported
sd_SetDarkIcon('sd_dark_alpha7.dmi',4)
#endif
// kick off the daylight cycles
spawn() DemoDayCycle()

proc/DemoDayCycle()
// a simple day/night cycle
var
time = 10 // how long it stays in this light state
light = 0 // how much light there is outside
d = 1 // amount of light increase
while(1) // keep doing until the program ends
sleep(time) // wait time ticks
time = 10 // set time to the default
light += d // shift the light amount

// if light level is outside the allowed range
if((light < 0) || (light > 4))
d = -d // switch the direction of light changes
light += d // put light back where it was
time = 100 // make this light period last longer

// just sets the time of day for the stat display
switch(d*light)
if(-4,4)
daytime = "Day"
if(-3,-2,-1)
daytime = "Dusk"
if(0)
daytime = "Night"
if(1,2,3)
daytime = "Dawn"

sd_OutsideLight(light)

I have changed it to use the alpha7, so what part of this needs to be changed/go , i know the daytime = "Dawn,night,dusk,day" goes
SuperSaiyanGokuX: (Aug 3 2013, 8:17 am)
Well, the demo procedure is just that, a demo. You'd have to tweak the cycle to match what you want (timing between light levels, basically, is what it boils down to)