ID:138781
 
Code:
    CreateTrackers(mob/M) // Complete
switch(M.Piece)
if("Rook")
var/X = 4
var/D = NORTH
while(0 < X)
var/obj/Tracker/A = new(M.loc)
walk(A,D)
D = turn(D, -90) ; X --
if("Bishop")
var/X = 4
var/D = NORTHWEST
while(0 < X)
var/obj/Tracker/A = new(M.loc)
walk(A,D)
D = turn(D, -90) ; X --
if("Queen")
var/X = 8
var/D = NORTH
while(0 < X)
var/obj/Tracker/A = new(M.loc)
walk(A,D)
D = turn(D, -45) ; X --


Problem description:

For some reason, if you play as any of these three pieces, the trackers aren't created, and I can't figure out why. Does anyone see the error?
Have you checked how far it gets before failing? It could be an issue outside of what's shown if it isn't even making it into any of the if()s.
In response to Robertbanks2
Debugging statements are telling me that the code is being reached at every stage of the creation process. It even registers the if statements.
In response to Lugia319
And M.loc is a valid turf?

Have you tried putting a debug output in the tracker's New() to be sure it's being created?

Is the tracker bumping something and not functioning properly with walk()?

Have you tried spawning walk(), instead of just calling it?

Does the tracker's New() have any ongoing procs that might need to be spawned?
Try using new differently, like this

var/A = new /obj/Tracker
new A.type(M.loc)
In response to Yahee
Yahee wrote:
Try using new differently, like this

var/A = new /obj/Tracker
new A.type(M.loc)

His use of new() is valid, and is actually the method shown in the reference's example of new().
In response to Robertbanks2
M.loc is indeed a valid turf.

The trackers are being created

The bumping is the strange part. When they're created, they should all bump the corners of the board, but there is no record of bumping when I put in my debugging statements.

        New(turf/T)
world << output("Tracker Created","Chat")
..()
src.Move(T)


Is the tracker's New() so I don't think there are any issues there.

I know it's being created, but for some reason it's not making the transition to the turf's location properly. So it's sitting in "negative space" as I like to call it. Thanks.
In response to Lugia319
Lugia319 wrote:
The bumping is the strange part. When they're created, they should all bump the corners of the board, but there is no record of bumping when I put in my debugging statements.

>       New(turf/T)
> world << output("Tracker Created","Chat")
> ..()
> src.Move(T)
>

Is the tracker's New() so I don't think there are any issues there.

Why are you calling src.Move(T)? Is there something specific in Move() that you need to call on the initial location? new() handles placement automatically, so unless you have something important in Move(), you don't need it there.

Have you made sure that turf/T isn't null?
In response to Robertbanks2
Come to think of it, you're right. I really don't need that Move(T). I think it's actually leftover from my previous methods.

Mobs are moved to a turf through

                        if(White == M || Black == M) // If they're white or black
var/list/Turfs = list() // Define Turfs to be an empty list
for(var/turf/T in block(locate(2,2,1),locate(9,9,1))) // Create a list of spawnable turfs
Turfs += T // Add these turfs to the list
var/turf/NT = pick(Turfs) // Define NT to be a random turf in Turfs list
M.Move(NT) // Move the player


They're moved using Move() so they should be put in the turf's contents, so I'm pretty sure turf/T is not null when I pass it using new(M.loc)
In response to Robertbanks2
Doing everything I could think of, I have verified that A. The objects are being created, and B. They are being created at that location. The problem seems to be with the walk(A,D) part. Since there are no dense objects and my Bump() isn't calling, then for some reason the objects aren't walking.
In response to Lugia319
Lugia319 wrote:
Doing everything I could think of, I have verified that A. The objects are being created, and B. They are being created at that location. The problem seems to be with the walk(A,D) part. Since there are no dense objects and my Bump() isn't calling, then for some reason the objects aren't walking.

Well, I have no idea. I copy pasted your code for creation/movement into a clean environment and it worked fine. I can only assume that it's something outside of the code you've posted.
In response to Robertbanks2
I'll take a look then. Thanks for the help.