PDA

View Full Version : TReflectGroundItemArray.GetAll function not functioning correctly



Rangerxmage
02-17-2017, 02:38 AM
When using the GetAll function, it does not find items correctly. After a whole bunch of testing, I worked out what the problem is. I narrowed it down to the sort function. When it sorts through each item in the array, if it finds the item at the tile, it sets the new array's value to that. The problem being that when there was a stack of objects, all the objects would appear as the same object. Meaning when trying to find something such as feathers like this guy https://villavu.com/forum/showthread.php?t=116860 If there were other things in that stack, there was a chance the getall function (and in turn any function that used the getall function, such as get and find) would not return feathers as being there at all. So if there is a stack on the ground of raw chicken, feathers and bones, Getall would return Raw chicken Raw Chicken Raw Chicken.

So after narrowing it down to the sort function and managed to see what the problem was.

So, in the GroundItems script, line 17

for C := 0 to L - 1 do
if (Tpa[I].Y = Self[C]._Tile.Y) and (Tpa[I].X = Self[C]._Tile.X) then
begin
Temp[I] := Self[C];
exit; // add this line
end;


EDIT: Okay, now it's really fixed. Rather than increment in the C for loop, i just exit out, so that it does the I for loop again, automatically doing it. No more errors!

My Original Nickname
03-09-2017, 06:19 PM
After I edit the file and add what you've said it works. Although won't the GroundItems script be changed again back to default when Reflect lib updates? If so is there another way to do this without modifying the Reflection library script?

tls
03-09-2017, 10:23 PM
After I edit the file and add what you've said it works. Although won't the GroundItems script be changed again back to default when Reflect lib updates? If so is there another way to do this without modifying the Reflection library script?

Override the reflection function in the local script.

My Original Nickname
03-10-2017, 07:59 PM
Override the reflection function in the local script.

Didn't know how to at first but with a bit of trial and error figured it out. Thanks, everything works perfectly now.