on_event causes blank lines in console

Discussion of Lua and LuaWML support, development, and ideas.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
arobinson
Posts: 207
Joined: June 6th, 2010, 12:05 am

on_event causes blank lines in console

Post by arobinson » July 17th, 2015, 2:50 pm

This seems odd, but overriding the on_event in lua causes a bunch of blank lines to be printed every time a hex is highlighted by the mouse (Wesnoth 1.12.4 and Mac 10.10.4). Any idea on what is causing it?

Code: Select all

---[[
-- For debugging:
local old_on_event = wesnoth.game_events.on_event
function wesnoth.game_events.on_event(name)
  --print("On event fired:",name)
  if old_on_event ~= nil then
    old_on_event(name)
  end
  return {}
end
--]]
Just by using that, not even printing anything, I see a lot of blank lines in the console. Commenting this out stops the issue.
Running Wesnoth 1.12.4 on Mac OSX 10.10
Campaigns:

User avatar
Elvish_Hunter
Developer
Posts: 1360
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: on_event causes blank lines in console

Post by Elvish_Hunter » July 21st, 2015, 9:19 am

arobinson wrote:overriding the on_event in lua causes a bunch of blank lines to be printed every time a hex is highlighted by the mouse (Wesnoth 1.12.4 and Mac 10.10.4). Any idea on what is causing it?
I don't see anything in your code that should obviously cause that. However, you can try by removing the return {} line, since functions without a return statement automatically return nil anyway.
Current maintainer of The Sojournings of Grog, Children of Dragons, A Rough Life and Wesnoth Lua Pack
Co-author of The White Troll
On Wesbreak until the 21th of December

User avatar
arobinson
Posts: 207
Joined: June 6th, 2010, 12:05 am

Re: on_event causes blank lines in console

Post by arobinson » July 21st, 2015, 2:09 pm

Elvish_Hunter wrote:
arobinson wrote:overriding the on_event in lua causes a bunch of blank lines to be printed every time a hex is highlighted by the mouse (Wesnoth 1.12.4 and Mac 10.10.4). Any idea on what is causing it?
I don't see anything in your code that should obviously cause that. However, you can try by removing the return {} line, since functions without a return statement automatically return nil anyway.
I tried returning nil and returning the value from the original on_event handler, but still got the blank lines. Just the presence of a custom handler seems to cause the blank lines on mouse movement. Seems odd, but that is what I seem to be experiencing.
Running Wesnoth 1.12.4 on Mac OSX 10.10
Campaigns:

Post Reply