// The guts of the system.
// NOTE: This can also be done without the darkness plane, by putting the master_plane and light sources on the same plane (eg: 2)
// However, this will cause things to be interlayered in a way that will make players running in software rendering mode able to see fully as if no darkness existed.
// This method will give them a fully black screen with no advantage.
image
master_plane
// I place the master plane on 0 so it'll on the default plane of most everything in the game.
// If things exist above plane 0, they'll appear above the master.
plane = 0
name = "darkness"
blend_mode = BLEND_MULTIPLY // Anything covered by this will have its color multiplied as they blend.
appearance_flags = PLANE_MASTER | PIXEL_SCALE | NO_CLIENT_COLOR // Specifies the plane is a master and it will ignore client.color values.
color = list(null,null,null,"#0000","#000f") // Sets a color matrix to pure black with full alpha.
mouse_opacity = 0 // Makes sure all mouse events ignore the plane.
darkness
// The darkness will appear behind the master plane and cover the entire screen
// I do it this way to allow finer control over the alpha levels and color of the "darkness" players see on their screen.
// In reality it's just a scaled-up white block.
name = "the darkness"
plane = -1
blend_mode = BLEND_ADD // Any color value applied to this image will be added to the color of anything blending with it.
mouse_opacity = 0
icon = 'darkness.dmi'
layer = 1
New()
..()
var/matrix/m = matrix()
m.Scale(100)
transform = m
// Scaling it up to cover the screen, I can probably use a single screen object for this...
// ... but I've found some cool screen-wide effects you can pull off by using a single graphic.
light
// The darkness will appear behind the master plane and cover the entire screen
// I do it this way to allow finer control over the alpha levels and color of the "darkness" players see on their screen.
// In reality it's just a scaled-up white block.
name = "the darkness"
plane = 0
blend_mode = BLEND_ADD // Any color value applied to this image will be added to the color of anything blending with it.
mouse_opacity = 0
icon = 'light.dmi'
layer = 1
New()
..()
var/matrix/m = matrix()
m.Scale(50)
transform = m
// Scaling it up to cover the screen, I can probably use a single screen object for this...
// ... but I've found some cool screen-wide effects you can pull off by using a single graphic.
obj
var
obj/light/light
matrix
on_matrix = matrix()
off_matrix = matrix()
light
plane = -1
blend_mode = BLEND_ADD
icon = 'light.dmi'
icon_state = "circle"
mouse_opacity = 0
// The light and darkness share a plane and most traits, when adding the pure white color of the light, and its alpha values.
// And the color and alpha values of the darkness image...
// ... you end up blending away the master plane's blacking out of the view.
lamp
icon = 'lamp.dmi'
icon_state = "off"
density = 1
// A basic light source object.
New()
// With some fancy turning off and on animation...
..()
light = new(src.loc)
light.alpha = 75
on_matrix.Scale(20)
off_matrix.Scale(0)
light.transform = off_matrix
Toggle()
Click()
Toggle()
proc/Toggle()
if(icon_state == "off")
icon_state = "on"
animate(light,transform=on_matrix,time=5)
sleep(6)
// And flickering...
animate(light,color=rgb(220,220,220),time=4,loop=-1)
else
icon_state = "off"
animate(light,transform=off_matrix,time=5)
light.color = null
mob
var
// You don't actually need variables for the master_plane and darkness, unless you plan on fiddling with them on the fly.
// You can get away with simply outputting the /image to the mob and being done with it.
// The light object has a variable for obvious purposes.
obj/light/light
image
darkness/darkness
master_plane/master_plane
light/light2
/*Move()
..()
// Simply keeps the player's light on the same tile as the player
if(light) light.loc = src.loc*/
Problem description:
SO I downloaded this light lib and love it. But I am trying to see, what is the best and most efficient way to make that light source only viewable on the client's screen. Right now the light is an obj that follows the player around, but....everyone can see it.....How can I make it a personal onscreen light....
One thng that came to mind was images, but I don't if thats possible or even a good way of going about it.