ID:262573
 
Code:
obj/Fire
proc
Spread(turf/Grass/M)
sleep(10)
if(M.flamable)
for(var/turf/T in range(1, src))
if(T.flamable && !(locate(/obj/Fire)) in T)
new /obj/Fire (T)
New()
..()
src.Spread(src.loc)

turf
Grass
icon = 'Ground.dmi'
icon_state = "Grass"
flamable = 1
verb
Light()
set src in oview(0)
var/obj/Fire/F = new
F.loc = usr.loc



turf/var/flamable = 0


Problem description:

Whenever I run this code it comes up with this error:

runtime error: Cannot read null.flamable
proc name: Spread (/obj/Fire/proc/Spread)
usr: ADT_CLONE (/mob)
src: Fire (/obj/Fire)
call stack:
Fire (/obj/Fire): Spread(null)
Fire (/obj/Fire): New()
Grass (2,1,1) (/turf/Grass): Light()

When you click on light it creates a fire underneath you and every second it trys to create another fire in a square next to it if it can.


You've got your parentheses in the wrong spot:

!(locate(/obj/Fire)) in T


...should be:

!(locate(/obj/Fire) in T)


Always put parentehses around an expression that uses the in operator, if it's part of another expression like a complex if() statement.

Lummox JR
In response to Lummox JR
Thanks, thought it still isnt working. Now if I put a fire on the map it works but when I use the light verb(which creates a fire under the usr) it comes up with the error message.
new /obj/fire (loc)
Try that.
In response to Ol' Yeller
It still comes up with the error.
src.Spread(src.loc)

Are you sure the obj has a loc at this point? Check to see if M is not null.
In response to ADT_CLONE
ADT_CLONE wrote:
Thanks, thought it still isnt working. Now if I put a fire on the map it works but when I use the light verb(which creates a fire under the usr) it comes up with the error message.

Aha, I see the problem.

When you create the flame, you're not doing it correctly, so it has no loc when it starts. It should be new(usr.loc) instead of calling new() and then setting loc afterward. Directly in the flame's New() proc it calls Spread(src.loc), which at that point is null because of the bad init. So in the Spread() proc, the M argument is null, thus M.flamable is null.flamable.

Lummox JR