ID:178908
 
I want to warp 2 players to battle arena. But it doesnt seem to take them there.

turf
var
occupied = 0
icon = 'icons.dmi'
battlestart
icon_state = "s"
occupied = 0

proc/StartBattle()
var/turf/battlestart/X
var/ox = usr.x
var/oy = usr.y
var/oz = usr.z
for(X in world)
if(X.occupied == 0)
world << "The battle begins!"
usr.loc = X.loc
X.occupied = 1
spawn(300)
world << "The battle is over!"
usr.loc = locate(ox,oy,oz)


It doesnt seem to take me anywhere.


Edit: I bascially want it so that you challenge a person to battle (or some other creative means of starting a battle, any suggestions welcome :D) and see if there is an open battle arena, to take them to it.

var/ox = usr.x
var/oy = usr.y
var/oz = usr.z

Wouldn't that set the variables to the user's current position? I don't know much about coding, but that's what I've gathered from your snippet.
In response to Mertek
no that was after the battle was over. I didn't see where you defined X as any location. cuz you had usr.loc = X.loc
In response to Canar
var/turf/battlestart/X
I think the problem is this:
usr.loc = X.loc

Since X is a turf, it's loc would be the area under it. You want to set the usr's loc to the turf, not the area containing the turf.
In response to Cinnom
It still won't take me there.

I put, usr.loc = X and usr.loc = X.loc.loc

It also says this when I test the proc

The battle begins!
The battle begins!
The battle begins!
The battle begins!
The battle is over!
The battle is over!
The battle is over!
The battle is over!


And I have 4 battleturfs
In response to Sariat
One of the problems with the for loop is that even after you find an unoccupied battleturf it will continue searching the rest of them. To fix that break out of that loop after you find an unoccupied battleturf. Back to your first problem. Setting usr.loc = X should work as would usr.Move(X).