ID:2148101
 
(See the best response by Kaiochao.)
Code:
obj/hud/OilLantern
icon='equipment.dmi'
icon_state="lantern"
screen_loc="11,0"
name="Oil Lantern"
Click()
usr.client.screen -= Oil
usr.LanternEquipped=FALSE
usr.light= null
usr.icon_state="base"
usr.light.dir=null
return

var/obj/hud/OilLantern/Oil= new


Problem description: So, the Lantern goes into the on-screen equipment, pretty simple, but upon clicking it to unequip the lantern the light source is still attached to the player, and for the life of me I can't get it removed.

EDIT: Using Forum_account's Dynamic Lighting library
If you're clicking the object that was added to the screen, why not remove src instead of Oil?
In response to Kaiochao
You're right, oops.

EDIT: I still can't figure out the removing light, mind.
In response to Manio
How is the light being added?

Setting a variable to null probably isn't going to affect it if you can see it. You should be getting a runtime error too, since you're trying to access the dir of null.
In response to Kaiochao
Clicking the lantern in the inventory is the goal, but for right now just clicking the lantern in the overworld to test out the code and what-not.

obj/equipment
Oil_Lantern
icon='equipment.dmi'
icon_state = "lantern"



Click()
if(usr.LanternEquipped==FALSE)
usr.icon_state="lanterncarrying"
usr.LanternEquipped=TRUE
usr.light = new(usr,1)
light.dir = pick(NORTH, SOUTH, EAST, WEST)
usr.client.screen += Oil


The equipment lantern, and Hud lantern are two separate objects. Hence the usr.client.screen += Oil
In response to Manio
Best response
Are you using a library, like Forum_account's Dynamic Lighting library? You should probably mention that first.

Setting a variable to null doesn't cause anything to happen on the value contained by the variable. (aside from garbage collection)

If you're using Forum_account's Dynamic Lighting library, you have to actually turn off the light.
In response to Kaiochao
Yes, sorry about that.

Fixed! My stupid mistake.