on_event causes blank lines in console

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

Moderator: Forum Moderators

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

on_event causes blank lines in console

Post by arobinson »

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
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: on_event causes blank lines in console

Post by Elvish_Hunter »

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 these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
User avatar
arobinson
Posts: 208
Joined: June 6th, 2010, 12:05 am

Re: on_event causes blank lines in console

Post by arobinson »

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