A couple of Lua bugs and a suggestion

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
GroundCombo
Posts: 4
Joined: Tue Feb 14, 2017 10:06 am

A couple of Lua bugs and a suggestion

Post by GroundCombo »

I bumped into some oddities while hooking up some game features into the built-in Lua interpreter:

Code: Select all

local foo = 4
for i = foo, 1, -1 do ... end
print(foo)
...prints 0. If you assign foo to some other variable before the loop, that variable gets modified too. You can work around this by forcing the interpreter to evaluate an expression instead of an assignment, like this:

Code: Select all

for i = foo+1-1, 1, -1
Another bug is that table.getn() throws an exception for a 'new LuaTable()' that hasn't been used. It doesn't seem to properly check for null list/dict values.

These aren't big problems and they can be worked around, but I thought I'd mention them anyway.

Also, it would be nice to have a QuestEntryStateChanged event, with the quest and entry number; this might be a bit tricky with how BroadcastMessage() is currently used for sending dialogue events, but it would make detailed quest tracking easier. I've solved it for now by overriding the default SetQuestEntryState Lua function.

Thanks for an excellent asset.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: A couple of Lua bugs and a suggestion

Post by Tony Li »

Hi,

Thank for reporting those Lua bugs! I'll try to get them fixed for the next release.

When you overrode SetQuestEntryState(), what did you end up passing? Did you still use BroadcastMessage(), Unity's event message system, something else? For better consistency with the existing messages, I'm thinking of adding an option to send a struct with the quest title and entry number, rather than switching to a new paradigm like Unity's event message system.
GroundCombo
Posts: 4
Joined: Tue Feb 14, 2017 10:06 am

Re: A couple of Lua bugs and a suggestion

Post by GroundCombo »

Basically I added a new UnityEvent<string, int> to DialogueSystemEvents, unregistered the existing SetQuestEntryState() and registered a replacement that takes the appropriate arguments and invokes the event.

Passing a struct would also be completely fine.
User avatar
Tony Li
Posts: 22062
Joined: Thu Jul 18, 2013 1:27 pm

Re: A couple of Lua bugs and a suggestion

Post by Tony Li »

Thanks! I'll probably do both of those things.
Post Reply