manavortex / DailyAutoShare

2 stars 5 forks source link

Error DasChatMessage #45

Closed vortex9 closed 3 years ago

vortex9 commented 3 years ago

Hi Got error in game with new 4.1

How get:

Received 2 Gold Coast quests: arena, evil Autoinvite active all time Passed one (arena).

When arena bingo appeared in chat got the message window:

user:/AddOns/DailyAutoShare/DasChatMessage.lua:43: attempt to index a nil value stack traceback: user:/AddOns/DailyAutoShare/DasChatMessage.lua:43: in function 'HandleChatMessage' |caaaaaa<Locals> messageText = "+arena", fromDisplayName = "@PeaceSmith", found = F, _ = T, bingoCode = "arena" </Locals>|r user:/AddOns/DailyAutoShare/DasChatMessage.lua:91: in function 'DAS.OnChatMessage' |caaaaaa<Locals> eventCode = 131105, channelType = 31, fromName = "Abraxiis^Mx", messageText = "+arena", _ = F, fromDisplayName = "@PeaceSmith", _ = T, result = 1 </Locals>|r user:/AddOns/DailyAutoShare/00_startup.lua:293: in function 'OnChatMessage'

mychaelo commented 3 years ago

@vortex9 Where exactly was your character located at that moment? That's crucial to know because it should trip on this:

/script d(DAS.bingo[DAS.GetZoneId()]["arena"])

(you can paste that into chat and see if you get any LUA errors)

The good news is that it's happening in the code that I didn't touch.

vortex9 commented 3 years ago

Hmmmmm... I think that caught error before enter local dungeon. But not sure.

But I am sure that bingo at that time should not work.

manavortex commented 3 years ago

@mychaelo: You can avoid that kind of error by simply accessing any table as something like othertable[var] or {}

I'd escape the above statement as

/script d((DAS.bingo[DAS.GetZoneId()] or {})["arena"])

so it's exception-proof. Bit cumbersome, but better than all the ifs.

mychaelo commented 3 years ago

@manavortex The main problem I have with this error is that it can only happen if DAS.bingo == nil, right? Because if I try DAS.bingo[nil]["arena"], LUA will eat it up and just give me a nil in return.

And a DAS.bingo == nil is not really possible unless something messed around with bingo table. That table is (should be) written only before init when all the data files are read.

manavortex commented 3 years ago

@mychaelo: I can imagine it happening because of libAsync - if a call gets queued 1 frame before the player enters the dungeon. Then, the AddOn will run DAS.bingo[DAS.GetZoneId()] and get nil, because they're in a different zone. It's an extreme edge case, but... I simply do or {} everywhere rather than thinking about it :D