Unable to compare two tables using metatables.
Posted: Wed Jun 14, 2017 4:14 am
Hi,
I'm trying to learn programming by coding a simple puzzle game in LOVE. Right now there are no controls. Anyway, I'm trying to use .png files to create a map by using color codes to denote different parts of the map. While doing so I realized I could use metatables to simplify color equalities by comparing {r,g,b,a} tables at every pixel on the map, which I would later use to draw the appropriate tiles.
I wrote a metamethod for the equality operator which I translated into python to test for validity.(attachment: equalityTesting.txt)
Unfortunately, the equality operator seems to not be working. It never returns true, hence drawing nothing on the screen. (Line 41: maploader.lua; attachment: gameFolder.love)
Comments at the beginning of main.lua may be useful.
Where did I go wrong?
I'm trying to learn programming by coding a simple puzzle game in LOVE. Right now there are no controls. Anyway, I'm trying to use .png files to create a map by using color codes to denote different parts of the map. While doing so I realized I could use metatables to simplify color equalities by comparing {r,g,b,a} tables at every pixel on the map, which I would later use to draw the appropriate tiles.
I wrote a metamethod for the equality operator which I translated into python to test for validity.(attachment: equalityTesting.txt)
Unfortunately, the equality operator seems to not be working. It never returns true, hence drawing nothing on the screen. (Line 41: maploader.lua; attachment: gameFolder.love)
Comments at the beginning of main.lua may be useful.
Where did I go wrong?