My current project is creating a "galaxy map" window that plots all the planets in the game. Planet locations are set up on an X/Y axis, so I created a trigger to pull this data and put all the planets in a Lua table called systems. The basic structure is something like this:
Once I have the actual planet data in a table, I want to create a label for each one of these planets. I actually did accomplish this, but I don't think it's working how I am intending it to. I've tried various versions of code to fit this label inside the actual table structure. For example the following function, which is what actually adds the planets:
Doing this I get the an error when the commented label code is actually not commented out:
LUA: ERROR running script System Grab (Trigger20) ERROR:../src/mudlet-lua/lua/TableUtils.lua:101:
stack overflow
The commented out code is where I have run into issues. I've tried filling up the "Systems" table first, then using a different function later to fill it out with labels rather than do it the moment the planet is inserted, like this:
So the error message I receive is actually being thrown from the Lua table function "table.contains". The error is only thrown after labels have been inserted into the table structure. I've noticed some strange behavior when inserting labels into the table hierarchy and I think I may be doing something wrong. If I generate the systems first, without labels, then generate labels for them afterwards in a loop it works fine. However, when I look at my variable list.. only the first index in the system table has the "label" index. Inside this label is an entire hierarchy of all the containers and labels for the ENTIRE script, which I think is causing the recursive function call "table.contains" to get the stack overflow warning.
Does anyone have any advice for how to approach this or where I'm going wrong. In order to dynamically add and remove planets as this project piece grows in complexity, I will need to be able to check the table to prevent duplicate entries. I felt the most elegant way to do this would be to create the labels as soon as the system is created at all, then later using another function to arrange the points on the map based on scale.
I've actually worked out most of the hard stuff, or so I thought. However, I think my inexperience with both Lua and Geyser is holding me back. I managed to create the map itself and it looks pretty decent so far, but I want the functionality to add hidden systems and recalibrate the map as needed.
Here's a picture of what it looks like:
https://dl.dropboxusercontent.com/u/958 ... 5%3A19.png