2025-07-21 05:09 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0004404Spring engineLuapublic2014-06-02 20:32
Reportermsafwan 
Assigned Toabma 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version96.0.1+git 
Target Version98.0Fixed in Version 
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
Checked infolog.txt for Errors
Attached Files

-Relationships
+Relationships

-Notes

~0013173

msafwan (reporter)

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

~0013174

silentwings (reporter)

Last edited: 2014-05-31 19:24

View 4 revisions

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.

~0013176

jK (developer)

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.

~0013178

silentwings (reporter)

Last edited: 2014-06-01 20:50

View 7 revisions

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).

~0013183

jK (developer)

> 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?

~0013184

jK (developer)

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

~0013185

abma (administrator)

Last edited: 2014-06-02 11:07

View 3 revisions

just remove this?

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

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

~0013186

silentwings (reporter)

yep, that's the fix
+Notes

-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 View Revisions
2014-05-31 19:23 silentwings Note Edited: 0013174 View Revisions
2014-05-31 19:24 silentwings Note Edited: 0013174 View Revisions
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 View Revisions
2014-06-01 19:33 silentwings Note Edited: 0013178 View Revisions
2014-06-01 19:34 silentwings Note Edited: 0013178 View Revisions
2014-06-01 19:41 silentwings Note Edited: 0013178 View Revisions
2014-06-01 20:46 silentwings Note Edited: 0013178 View Revisions
2014-06-01 20:50 silentwings Note Edited: 0013178 View Revisions
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 View Revisions
2014-06-02 11:07 abma Note Edited: 0013185 View Revisions
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
+Issue History