Davin626 Posted June 20, 2020 Share Posted June 20, 2020 Hey, if anyone's still on this *Foorum* (I just discovered this game last year), I have a mod I'm making, a good fun romp through a 12-level dungeon. One thing I'm having an issue with is a "Bad Object". Apparently if a monster is killed (by the engine, e.g. normal damage, not via monster:destroy() AFAIK), and I try to get its data the same frame, it crashes. Sometimes. Arbitrarily (1% chance?). local entity = findEntity (id) -- Finds a seemingly valid entity local name = entity.name -- Crashes, sometimes So it may be something like a Lua-esque dangling pointer - thinking it's a valid pointer/reference, but to data that is now overwritten. (That's just a guess, and just one possibility). Is there a good way to work around this? I've tried "if entity == nil", "if.entity.id == nil", and "pcall()" (Lua's version of try-catch, which doesn't exist in this implementation). As I said, "findEntity()" thinks the entity is valid, but any attempt to further verify that (entity.name, etc.) crashes.Googling - Lua "bad object" - doesn't help. This currently seems to be specific to one script I'm using, but one that I really don't want to abandon. (Mwahahahaha! Got some nice tricks in this mod).That script does cache old data, and is perfectly happy with *handled* failure (using cached data instead of fresh data), but this has no handling, just a crash. Davin Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now