View Issue Details

IDProjectCategoryView StatusLast Update
0004404Spring engineLuapublic2014-06-02 20:32
Reportermsafwan Assigned Toabma  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version96.0.1+git 
Target Version98.0 
Summary0004404: Gadget's ChatAction() always call a function twice
DescriptionI mean, if I do: /luarules testabc (using the following gadget)

then the function "TestFunction" is always called twice. This never happen in Spring 91.

*This might hint some underlying bug and also cause problem in creating a toggle action.
Tagschat action
Attached Files
dbg_gadgetAction.lua (Attachment missing)
Checked infolog.txt for Errors

Activities

msafwan

2014-05-31 16:55

reporter   ~0013173

Please try the gadget, its mod independent and is really simple. Just do "/luarules testabc" and watch echo

silentwings

2014-05-31 19:21

reporter   ~0013174

Last edited: 2014-05-31 19:24

Reproduced this.

I tried it with BA and 96.0 and the TestFunction was only called once after sending "/luarules testabc". However, with BA and 96.0.1-443, the TestFunction was called twice.

Imo this should be fixed before a release.

jK

2014-06-01 13:00

developer   ~0013176

It's not called twice ...
There are 2 callins for handling chat messages GotChatMsg & ConfigureLayout, the latter is deprecated.
The failure is on your side, chat actions are _control_ events, means when a receiver returns true _any_ further processing is stopped.
You instead return nothing := false, and so tell the engine & addon handler that you didn't processed the chat action, and that it should test further if other receivers may be interested in it. And when no one was, it will try the other chat msg event.

silentwings

2014-06-01 14:00

reporter   ~0013178

Last edited: 2014-06-01 20:50

Well - I simply inherited code (written by others) that used to work & was broken by a change within the engine.

I think you should mark the relevant part of the changelog as a breaking change. I didn't find any documentation to say that the return argument of chat actions actually did something.

Edit: I tried adding return true to the example gadget above, with the BA svn, and the test function was still called twice. I added some debug info to the gadgethandler, and it seems that gadgetHandler:GotChatMsg is actually called twice (it returns false the first time it is called).

jK

2014-06-02 00:58

developer   ~0013183

> Edit: I tried adding return true to the example gadget above, with the BA svn, and the test function was still called twice. I added some debug info to the gadgethandler, and it seems that gadgetHandler:GotChatMsg is actually called twice (it returns false the first time it is called).

Synced & Unsynced?

jK

2014-06-02 01:00

developer   ~0013184

bluestone_irc: [LCC]jK, i guess the problem with GotChatMsg being called twice is that unsycned now also recieves GotChatMsg and the gadgethandler is not prepared for this (it calls SendToUnsynced)


k that's might be

abma

2014-06-02 10:41

administrator   ~0013185

Last edited: 2014-06-02 11:07

just remove this?

https://github.com/spring/spring/blob/develop/cont/base/springcontent/LuaGadgets/gadgets.lua#L890

  if (IsSyncedCode()) then
    SendToUnsynced(player, msg)
  end

silentwings

2014-06-02 20:27

reporter   ~0013186

yep, that's the fix

Issue History

Date Modified Username Field Change
2014-05-31 16:52 msafwan New Issue
2014-05-31 16:52 msafwan File Added: dbg_gadgetAction.lua
2014-05-31 16:53 msafwan Tag Attached: chat action
2014-05-31 16:55 msafwan Note Added: 0013173
2014-05-31 19:21 silentwings Note Added: 0013174
2014-05-31 19:22 silentwings Note Edited: 0013174
2014-05-31 19:23 silentwings Note Edited: 0013174
2014-05-31 19:24 silentwings Note Edited: 0013174
2014-06-01 00:59 abma Target Version => 98.0
2014-06-01 13:00 jK Note Added: 0013176
2014-06-01 14:00 silentwings Note Added: 0013178
2014-06-01 19:33 silentwings Note Edited: 0013178
2014-06-01 19:33 silentwings Note Edited: 0013178
2014-06-01 19:34 silentwings Note Edited: 0013178
2014-06-01 19:41 silentwings Note Edited: 0013178
2014-06-01 20:46 silentwings Note Edited: 0013178
2014-06-01 20:50 silentwings Note Edited: 0013178
2014-06-02 00:58 jK Note Added: 0013183
2014-06-02 01:00 jK Note Added: 0013184
2014-06-02 10:41 abma Note Added: 0013185
2014-06-02 10:42 abma Note Edited: 0013185
2014-06-02 11:07 abma Note Edited: 0013185
2014-06-02 20:27 silentwings Note Added: 0013186
2014-06-02 20:32 abma Changeset attached => spring release 70b3a9f7
2014-06-02 20:32 abma Assigned To => abma
2014-06-02 20:32 abma Status new => resolved
2014-06-02 20:32 abma Resolution open => fixed