ID:147240
 
I am trying to make obj's fall like with gravity. I was stumped on how to do that with my current gravity system so i made a new proc:
obj
proc
objGravity()
var/turf/aturf = locate(src.x, src.y-1, src.z) // Get the turf directly below you.
var/dense = 0
if(aturf)
for(var/atom/A in aturf)
if(A.density == 1)
dense = 1
if(dense == 0)
src.loc = locate(src.x, src.y-1, src.z)
objGravity()
else
return


i dont know where to call it
i figure it dont belong under obj, but everywhere else it gives me errors. I think i need to call it in the block spawning proc somewhere:

proc
BlockSpawn()
for(var/i = 1; i <= 300; i++)
var/x_level = rand(1,17)
new/obj/blocks/red(locate(x_level,17,1))
sleep(10)


but i dont know where. Uhh yeah thats about it and so.... please help me!
obj
proc
objGravity()
walk(src,SOUTH)


Obviously, you could just call walk. THe following extension of the original proc might work too though:
obj
proc
objGravity()
var/aturf=locate(x,y-1,z)
for(var/atom/A in aturf)
if(!A.density)
loc=locate(x, y-1, z)
objGravity()


Not sure why you wouldn't just call walk() though. I hope this helps :)
In response to Wizkidd0123
allrighty then. IT seems to be fine without error. But where should i call it??
When i spawn the blocks?
In response to Wizkidd0123
Wizkidd0123 wrote:
                    loc=locate(x, y-1, z)
objGravity()


You need to use spawn() to create a new thread (look it up, I'll be damned if I'm going to explain it again) and then call objGravity() in that thread. That way, the current procedure will end, instead of waiting for another procedure to end, which will be waiting for the next procedure to end, and so on, until your computer simply can't handle any more procedures waiting to end (actually, BYOND will kill it before then, but it still isn't pretty).