ID:953828
 
(See the best response by Albro1.)
Code:
turf
var/obj/lighting/lightsource = new/obj/lighting()
New()
..()
src.overlays += src.lightsource
obj
lighting
var/setlighting = "1"
icon = 'lighting.dmi'
icon_state = "1"
layer = 100
proc
updateworldlighting(number)
for(var/turf/a in world)
if(!(isnull(a.lightsource)))
if(!(a.lightsource.icon_state == a.lightsource.setlighting))
a.lightsource.setlighting = num2text(number)
a.overlays -= a.lightsource
updatesetlight(a.lightsource)
a.overlays += a.lightsource
updatesetlight(obj/lighting/light)
light.icon_state = light.setlighting


Problem description: ok so i see no errors, DM sees no errors, but for some reason it wont create a new /turf/lighting and set it to the turfs overlays, can someone help me?


edit: updatesetlight will be used later and more stuff will be added to it
Is your "1" state blank? Your check in updateworldlighting() is not going to pass.
if(!(a.lightsource.icon_state == a.lightsource.setlighting))


Your default values for setlighting and icon_state are the same, so the code wont ever go past this. You may want to do something like:
if(!(num2text(number) == a.lightsource.setlighting))
i changed it to
turf
var/obj/lighting/lightsource = new/obj/lighting()
New()
..()
src.overlays += src.lightsource
obj
lighting
var/setlighting = "1"
icon = 'lighting.dmi'
icon_state = "1"
layer = 100
proc
updateworldlighting(number)
for(var/turf/a in world)
if(!(isnull(a.lightsource)))
if(!(number == a.lightsource.setlighting))
a.lightsource.setlighting = num2text(number)
a.overlays -= a.lightsource
updatesetlight(a.lightsource)
a.overlays += a.lightsource
updatesetlight(obj/lighting/light)
light.icon_state = light.setlighting


and it still dosnt work
all i changed was
if(!(number == a.lightsource.setlighting))

to check if the lighting is already set to the number your trying to set, so if i changed it to 4 and it was already 4 it would not run unnecessary coding, also my problem is them not appearing in the world when they spawn new and get put into the turfs lightsource var, the var remains null

"them" being the lighting
Best response
You have to do "[number]". Right now you're comparing a number to a text string, which is never going to work.
thx :D ive been using a text string for a number >.>
 updateworldlighting("4")

:S i should know better to use a text string for a number BAD SHWB1! xD

thanks again