ID:138707
 
Code:
voidstep()
var/vtimer=0
var/vstepped=0
for(var/turf/Void/Void1/M in world)vstepped=1
loop
spawn(100)
if(vstepped==1)
vtimer++
usr<<output("<font color=white><b>You have been on the void for [vtimer] seconds.","infobox")
if(vtimer==10)
usr<<output("<font color=white><b>You have been jailed.","infobox")
vstepped=0
else
goto loop


Problem description: This is the first time I'm trying something. Im coding this in a NNG rip just to try it out. What I want it to do is when you are on the "Void" turf it outputs every second in a timer fashion and then after ten seconds I want it to put them in jail. (I know I havent put the actual code to put them in jail, I can figure that out myself). It causes major lag and since this turf is used nearly everywhere, everytime I step on it (even if it is a different tile) it outputs a new timer. I hope this is enough for you to help me.

I doubt people'll help people working on RIPs.

By the way, I don't even know why have you used this line.

for(var/turf/Void/Void1/M in world)vstepped=1


Sounds crazy to me to check all the "voids" on the world for a single step made on a void... Anyway, you haven't told us when is voidstep() called...
In response to Eternal_Memories
I'm really only working on the rip to help improve my coding knowledge, after all whats a better learning experience than doing it yourself?
Voidstep() gets called when a person steps onto the void.
 for(var/turf/Void/Void1/M in world)
voidstep()//this calls the proc

voidstep()
var/vtimer=0
var/vstepped=1
loop
spawn(100)
vtimer++
usr<<output("<font color=white><b>You have been on the void for [vtimer] seconds.","infobox")
if(vtimer==10)
usr<<output("<font color=white><b>You have been jailed.","infobox")
vstepped=0
else
goto loop

Also, I have no idea how to check if a person steps on that specific tile other than that. If you could show a reference or explain it to me I would be very grateful.
mob/var/void_timer = 0
turf
Entered(mob/m)
if(src & m & ismob(m))
m.void_timer = 0
..()
turf/void
Entered(mob/m)
if(src && m)
if(ismob(m))
if(!m.void_timer)
m.void_timer = world.time
else
if(world.time - m.void_timer > 1000) //10 seconds
//here we have detected the person has been on the void for longer than 10 seconds
m << "you've been in the void for too long"
..()


Sorry, I wrote this fast, but it should work.
Not the best way, but at least it should work.
mob
var void_timer = 0
proc
// Starts the timer
begin_void_timer() spawn
// Don't start another loop if one already exists.
if(void_timer) return

// 100 * 1/10th of a second = 10 seconds.
// Check if the mob is on a void turf every 0.1 seconds.
while(void_timer++ < 100 && istype(loc, /turf/void))
sleep(1)

// The timer was not interrupted
if(void_timer == 100)
void_timer = 0
go_to_jail()

turf/void
Entered(mob/m)
if(istype(m))
m.begin_void_timer()
..()
Wouldn't you actually want to spawn that m.begin_void_timer()??
That would probably be best. I'm not sure if it would completely halt movement until the loop finishes.