ID:139678
 
Code: Footprints
mob
proc
WinterWalk()
if(Winter == 1)
if(src.dir == 2)
var/obj/FootUD/T = new(src.loc)
sleep(5)
del(T)
spawn(1)
src.WinterWalk()
if(src.dir == 1)
var/obj/FootUD/T = new(src.loc)
sleep(5)
del(T)
spawn(5)
src.WinterWalk()
if(src.dir == 4)
var/obj/FootLR/D = new(src.loc)
sleep(5)
del(D)
spawn(5)
src.WinterWalk()
if(src.dir == 8)
var/obj/FootLR/D = new(src.loc)
sleep(5)
del(D)
spawn(5)
src.WinterWalk()


Problem description: Im trying to make consistant footprints in the snow every step the player takes and disappear after a few seconds but as you can imagine attempting it this way is quite laggy especially when you cant create multiple steps without waiting for the first to delete without making multiple procedure functions which once again is laggy. As you can see i have specific footprints set up for the direction your facing.

Create them on Move().

Don't have four separate types of objs, just use a single type which has the appropriate directional states, and set their dir to equal your dir after you create them.
In response to Garthor (#1)
Garthor man... all i can really say is kudos on still being on byond ^_^. So that being said, I think i have a rough idea on how to do it based on your movement proc idea (Assuming i remember how) but the great thing about coding is you can create something youve never done before as long as you have the basic structure.

I got it, had some minor issues where my character kept warping, but screwing around with something fixed it, so i got my footprint trail now thanks i really appreciate it :D
In response to Isharu (#2)
Your other option is to place something into the snow turf's Exited() proc like this
turf/snow/Exited(atom/M)
if(ismob(M,/mob/player)) //make sure it is a player
var/obj/footprint/O=new(src) //place a footprint in the snow
O.dir=M.dir //make sure the footprint is facing the correct direction

obj/footprint
New()
..()
spawn(30) del src //make the footprint delete after a few seconds.

And then just give the footprint the proper graphic to slowly disappear withing those 3 seconds or however long you want it there.
In response to Gunbuddy13 (#3)
What if the footprint gets deleted before the spawn(30) is done? you'd get a runtime error. using if(src) would prevent this.
In response to Darker Legends (#4)
Darker Legends wrote:
What if the footprint gets deleted before the spawn(30) is done? you'd get a runtime error. using if(src) would prevent this.

The only thing in the example that deletes the footprint is the 3 second delay. There's no reason to believe that anything else could cause its deletion.

When an object is deleted all of its pending procs are removed from the schedule. In this case if the footprint object is somehow deleted before the 3 seconds are up, the "del src" line will never run anyway.

This is a more valid concern if the code was structured like this:

turf/snow/Exited(atom/M)
if(ismob(M,/mob/player))
var/obj/footprint/O=new(src)
O.dir=M.dir
spawn(30) del O

obj/footprint


The spawn() call is not inside a proc that belongs to the footprint object, if the footprint is deleted the "del O" line will still execute. Yes, you'd get a runtime error but it won't cause any problems.
In response to Darker Legends (#4)
Darker Legends wrote:
What if the footprint gets deleted before the spawn(30) is done? you'd get a runtime error. using if(src) would prevent this.

If src is deleted, then the proc will end. if(src) is very close to being a completely and utterly useless line.
In response to Garthor (#6)
Garthor wrote:
Darker Legends wrote:
What if the footprint gets deleted before the spawn(30) is done? you'd get a runtime error. using if(src) would prevent this.

If src is deleted, then the proc will end. if(src) is very close to being a completely and utterly useless line.
Agreed, if the footprint gets deleted before the spawn(30) is up, then all the procs running from that footprint immediately end, meaning you wouldn't not have that runtime error