ID:170680
 
I have houses size 32x32 on the map in which if you enter, you get added to a list belonging to the house(called persons). Now lets say Bob went inside the house and was added to the list(and also appears UNDER the house, by moving Bob to the house's location and messing with the LAYER variable). Later George comes and thinks, hey hold on a second, that's my house not Bob's! So he wants him to get out(by getting removed from the list and to not appear UNDER the house). How would I decide where Bob moves?

Considering O is that house(the obj), I'm trying this:

            for(var/mob/M in O.persons)
world << O //just to prove to you guys that O does exist and is being used.
world << M //again to prove.
O.persons -= M
M.Move(locate(O.x-1,O.y,O.z))


However, M doesn't excatly Move() out.

But that isn't even the main point. The point is, what if there was something blocking O.x-1? That would mean the mob never moves out. So how would I check that there's an empty space and then move them onto there(by empty space I mean no mobs or objs are present there)? And also a little help on why the mob isn't even moving won't hurt :)

And lets say there are 2 objs on top of each other(on the map). How would I delete one of them? No I dont want to just not add two objs on top of each other in the map...

I'm trying this:

for(var/turf/T in world)
for(var/obj/O in T)
for(var/obj/P in T)
if(!O==P)
if(O.loc==P.loc)
var/list/A = list(O,P)
var/delete = pick(A)
del(delete)


But it says cannot read null.loc.
for(var/turf/T in world)
for(var/obj/O in T)
for(var/obj/P in T)
if(!O==P) //false statement is wrong, if no O (null) is P?
if(O.loc==P.loc)
var/list/A = list(O,P)
var/delete = pick(A)
del(delete)


Your false statement is wrong, it should be like this

            if(O!=P)  //if O is not P
In response to ZDarkGoku
Ah ok thanks. Now a little on on Get Outa My House please?
            for(var/mob/M in O.persons)
world << O //just to prove to you guys that O does exist and is being used.
world << M //again to prove.
O.persons -= M
//M.Move(locate(O.x-1,O.y,O.z)) //try setting M's loc
M.loc = locate(O.x-1,O.y,O.z) //this is the same as the above code.
In response to VUnit321
"O.persons -= M"
Shouldn't you use Remove?(O.persons.Remove(M))
In response to Hell Ramen
Hell Ramen wrote:
"O.persons -= M"
Shouldn't you use Remove?(O.persons.Remove(M))

Well, actually, no. He's perfectly correct therre.
In response to VUnit321
Ok fine that works but there's still the main point that remains. What if there's something at x-1? Ok sure with setting the location you'll still appear at x-1 but it'd look stupid...

Anyone have any idea? I was thinking of something like this:

for(var/turf/T in oview(1))
for(var/obj/O in T)
if(O!=T)
M.loc = T.loc


Would that be right? And are there any better ways out there?
In response to DeathAwaitsU
No, it isn't. T.loc is an area. You just want M.loc = T

Secondly, why are you checking if O is equal to T?

O will NEVER be equal to T when T is a turf and O is an obj, especially when O is only being taken from T.contents.

Try this:

for(var/turf/T in oview(1,src))
if(T.Enter(M))
M.loc = T
In response to Ter13
If you're going to use movement procs, you might as well use Move(). And you should quit out of the loop when you have a successful move.

for(var/turf/T in oview(1,src))
if(T.Move(M))
break
In response to Crispy
I tried this:

                var/list/Ts = list()
for(var/turf/T in oview(1,O))
var/mob/A = new
var/obj/N = new
if(!T.contents.Find(A) && !T.contents.Find(N))
Ts += T
var/turf/a = pick(Ts)
var/cor = M.loc
while(M.loc==cor)
if(M.Move(a))
return
sleep(5)


It works sometimes but other times M doesn't move out. I'm guessing thats because M is trying to move where the player is but can't.
In response to DeathAwaitsU
That means there was a dense blockage, or no turf.
In response to Ter13
The dense blockage was either a mob or an obj.

Which is the whole point, it shouldn't be moving into places with a mob or an obj.
In response to DeathAwaitsU
So, if it works, why are you complaining?
In response to Ter13
But it doesn't.

If it can't enter a turf with an obj or a mob, I wanted it to go to another "empty" turf.
In response to DeathAwaitsU
Bump.

I don't want to bump both my posts but a lil help on this and the reboot world thing please =3.