I have a message which posts to an object which runs the following code:
table.insert(self.entities, message.id)
This has nothing to do the self.entities however, when I set a breakpoint on this line and manually type the same thing in the LUA evaluator the entity inserts without issue.
What could explain this? I don’t know how to debug it since the lua script logic seems to be disregarded.
No typo/punctuation issues nor errors relating to this code line. I now have even rebuilt the messaging system between the two objects and the issue is still unfixable… There may be some bugs in this new system since I just added it.
It happens inside of an on_message function call. The bug is happening around this part of the function code:
elseif message_id == hash("entity_transferred") then -- TRANSFER ENTITY TO main_ref
table.insert(self.message_posted_entities, message.id)
msg.post(message.id, hash("entity_transferred"))
The logic here is meant to allow an entity to migrate spawned entities (tracked by that object) to the main instance. Then the instance sent to main is sent a message notifying it that it’s been transferred (to update state.)
I also changed the logic to accumulate all posted entities during the messaging stage until the next update loop. Then it sends all entities via a for loop to main at that point. That’s why it’s inserting to self.message_posted_entities now.
However, there are still issues with table.insert not behaving as expected.
Hey, I managed to workaround the issue by spawning those instances in main directly instead of transferring them. I think it had something to do with the timing of messages sent, etc. Not sure but I think there’s an issue w/ pausing in debug mode. I’ve seen other erratic behavior relating to this: