A Bug in code, need help figuring out the problem
Posted: Fri Dec 11, 2020 12:38 pm
Here is the strangest Bug I have ever got in my code, for I know exactly where the bug is, yet I can't figure out why it does that.
I am not able to provide a short working example, but due to its nature, I can explain it with a couple of lines:
What the fails is that it complains that at MapDataLocation 162 it doesnt have .path.
However, it does have. The strange thing here is that If I use variable "MapDataLocation", even that MapDataLocation in debugprint shows 162, it doesnt work.
But If I directly either write self:Draw_Path(Actions.Availablemoves[162].path, or if I manually set "MapDataLocation = 162" it works just fine.
But if I get it as Index, even using ToNumber() wont help. It simply keeps complaining that "path" doesnt exist.
To add more to this is that other MapDataLocation numbers work just fine, and they are set in same ForEach function elsewhere in the program as is index 162, so I see no reason why this specific 162 index would fail, while the rest don't.
I am not able to provide a short working example, but due to its nature, I can explain it with a couple of lines:
Code: Select all
ForEach(Actions.Availablemoves, Function(MapDataLocation, notused)
MapDataLocation = ToNumber(MapDataLocation)
DebugPrint("MapdataLocation: "..MapDataLocation)
self.Map_MouseOverFuncs[MapDataLocation] = Function() self:Draw_Path(Actions.Availablemoves[MapDataLocation].path) EndFunctionHowever, it does have. The strange thing here is that If I use variable "MapDataLocation", even that MapDataLocation in debugprint shows 162, it doesnt work.
But If I directly either write self:Draw_Path(Actions.Availablemoves[162].path, or if I manually set "MapDataLocation = 162" it works just fine.
But if I get it as Index, even using ToNumber() wont help. It simply keeps complaining that "path" doesnt exist.
To add more to this is that other MapDataLocation numbers work just fine, and they are set in same ForEach function elsewhere in the program as is index 162, so I see no reason why this specific 162 index would fail, while the rest don't.