ID:269644
 
Here is the code I have made:

obj
Fire
proc
Spread(M as turf in oview(1))
sleep(10)
if(M.flamable == 1)
var/obj/Fire/F = new
F.loc = locate(M)


Whenever I run this code I get the error:

Fire.dm:6:error:M.flamable:undefined var

Could someone please help me.
Do turfs have a 'flamable' var? (It's spelt 'Flammable', by the way. Synonomous with 'inflammable', by a quirk of English)
In response to Jp
The flamable(flammable) variable is my own that I made up.
ADT_CLONE wrote:
Here is the code I have made:

> obj
> Fire
> proc
> Spread(M as turf in oview(1))
> sleep(10)
> if(M.flamable == 1)
> var/obj/Fire/F = new
> F.loc = locate(M)
>

Whenever I run this code I get the error:

Fire.dm:6:error:M.flamable:undefined var

You haven't defined the turfs 'flamable' var.

turf/var/flamable


~Sinyc.
In response to Sinyc
Ok. I did actually define the variable. Here is all my code:

obj
Fire
icon = 'Fire.dmi'
icon_state = "Fire"

turf
Grass
icon = 'Ground.dmi'
icon_state = "Grass"
var/flamable = 1
var/burnt = 0
verb
Light()
set src in oview(0)

mob
icon = 'mob.dmi'
var/money = 0
obj
Fire
proc
Spread(M as turf in oview(1))
sleep(10)
if(M.flamable == 1)
var/obj/Fire1/F = new
F.loc = locate(M)
F.whomoney = usr.key
M.burnt = 1
New()
..()
Spread()
usr.money += 1
Fire1
icon = 'Fire.dmi'
icon_state = "Fire"
var/whomoney
New()
..()
whomoney.money += 1
Spread()
proc
Spread(M as turf in oview(1))
sleep(10)
if(M.flamable == 1)
var/obj/Fire1/F = new
F.loc = locate(M)
F.whomoney = usr.key
M.burnt = 1


Could you please help me
In response to Sinyc
I did actually define that varible elseware in my code.
In response to ADT_CLONE
You've defined it within turf/Grass not turf as a whole.
In response to Sinyc
oh thanks
In response to ADT_CLONE
Its still not working.
In response to Sinyc
Ill change that to compile code.
In response to ADT_CLONE
My question was, is it defined for turfs?

EDIT:

Oh, and the 'm as turf in oview(1) makes no sense. You want the proc to be defined like this:

Spread(var/turf/m)

And then you just call it with a turf as an argument. If you use view() or range() in procs, be aware that they default to the view or range of usr, so you'll need to override that in the proc.
In response to Jp
The proc is defined for the Fire object. Ive now got this code:

obj
Fire
proc
Spread(var/turf/Grass/M)
sleep(10)
if(M.flamable == 1)
var/obj/Fire/F = new
F.loc = M.loc
Spread()
New()
..()
Spread()

obj
Fire
icon = 'Fire.dmi'
icon_state = "Fire"

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

turf/var/flamable = 0
turf/var/burnt = 0
mob
icon = 'mob.dmi'
icon_state = "Man"
var/money = 0


Could you please correct this.

Oh and I get this runtime 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 (1,1,1) (/turf/Grass): Light()
In response to ADT_CLONE
ADT_CLONE wrote:
obj
Fire
proc
Spread(var/turf/Grass/M)
sleep(10)
if(M.flamable == 1)
var/obj/Fire/F = new
F.loc = M.loc
Spread()
New()
..()
Spread()


That is because you called Spread() without any arguments. You need to call it with it's location as the argument. You also don't need to call Spread() in the Spread proc when it already gets called in New(). You'd basically be calling it twice.

        New()
..()
src.Spread(src.loc)


Though I'm willing to bet that isn't what you want to do. If you put this in right now, you'd get no actual "Spread" since it's only spreading in one location. This will make it "spread" around all of the locations.

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) // check if it is
// flamable and if there isn't fire on it already
new /obj/fire/F (T) // create another fire
// this will already spread since it is called in the New() proc,
// so no point defining it


Basically what it does is that it creates flames everywhere around (and at) the turf, only if it is flamable and there isn't already a fire in that location. If I didn't add that check, the place would be spammed with useless fire. (Since it is on top of each other.) If you want to delete the fire after a few seconds, just do it in the New() proc.

obj/fire
New()
..()
src.Spread(src.loc)
spawn(50) // five seconds
del(src)


~~> Dragon Lord


In response to Unknown Person
Thanks
In response to Unknown Person
It still comes up with the same error.

ill add on to that that it runs the proc but doesnt create the fire in the first place.
In response to ADT_CLONE
This is the error I get:

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()