Creations Favorites Posts ID:147798
 ID:147798   Nov 22 2003, 6:58 pm Let's start off with a little background. I have a an object grid of 5x10. These are in a list where the objects are in no particular order. The bottom left object's location is x1, y1. I'm lookng for a procedure that when I input a tx and ty value. This will move that object's location to x1+tx,y1+ty . Now I can perform this task easily but I have another problem. The objects that are being relocated can't EVER overlap. This means that I must go through the list in a specific order. This is because when this object moves it moves all other objects on its square with it. overlap could easily cause strange translocations. Also how would I rotate this 5x10 grid 90 degrees into a 10x5 grid. Also a way to rotate it again and again would be nice :/ Also is there a way I could do this so that instead of just a 5x10 grid it would work for an arbitrarily sized grid?
Simple, check to see if the tile can be entered.

ex:

 ```var/turf/T=locate(X,Y,Z)//Replace the X,Y,Z with the coords you want.if(T.loc)//Checks to see if that location is accessible src<<"YEE!"//If it is, you get a yeeelse src<<"NEE!"//If not, you get a nee ```
 #2 Nov 23 2003, 3:18 am In response to Goku72 (#1) Uh... Goku... that will always return true. =P Unless it's possible for turfs to not be inside an area, which I don't think it is. Either way, it won't work correctly. I'd suggest looping through the list and seeing if there's already an object at the given location. As for the rotating, this shouldn't be too hard given a little thought. Set each object's X location to its Y location, then set each object's Y location to the X size of the grid, minus its old X location (and add 1 if the minimum X location is 1 rather than 0). This should work for any size grid.
 #3 Nov 23 2003, 5:38 am (Edited on Nov 23 2003, 6:06 am) In response to Crispy (#2) I was able to do the movement but I need to work on the rotating a bit. I understand what your saying though... Although the fact the grid is rectangular will make problems. :/ Ack having major problems. I'll have to scrap 180 degree movement and then convert it to 2 90 degrees movements. For now its not going to work because of object rtation problems :/
 #4 Nov 23 2003, 7:25 am (parts are the parts that are being rotated. note the extra translocation to prevent ovverlap. Also however you must note that the objects are not rotsting properly. They look disjoined.) proc/rotate(direct) var/obj/move/origin = pick(parts) //lowerleft for(var/obj/move/M in parts) if((M.x
 #5 Nov 23 2003, 7:55 am If you translate or rotate the objects, they will never end up overlapping each other unless they were overlapping each other to begin with. For each object in the list, you should first check to see if it can be moved to its destination ignoring other objects in that same list, and only being concerned about other objects that would block its movement. If each object can be moved, then go ahead and move all of them. You shoudl just mark the objects at a given tile so they know what object in the grid they are assigned to. That way it doesn't matter what order you move them in. I think it'd be easier and more efficient to do that than to find a way to move the objects so that no two of them ever overlap.