Override getWindow function?

Geyser is an object oriented framework for creating, updating and organizing GUI elements within Mudlet.
Post Reply
Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Override getWindow function?

Post by Nyyrazzilyss » Tue Feb 09, 2016 5:26 am

I've just started playing with nested labels.

The first issue i've run across is that it -appears- to only work with labels created at the top level, not inside another window. I've cut/paste the getWindow function itself below.
Code: [show] | [select all] lua
--- Returns the Geyser object associated with the label name
-- @param label The name of the label to use

function Geyser.Label:getWindow(label)
    for i,v in pairs(Geyser.windowList) do
        if v.name == label then
            return v
        end
    end
end
In the short term, I made it search down one level - It really should search until final level, this was just a temporary fix for me.
Code: [show] | [select all] lua
function Geyser.Label:getWindow(label)
   for i,v in pairs(Geyser.windowList) do
        if v.name == label then
            return v
        end
		
	for key,val in pairs(v.windowList) do
		if val.name == label then
			return val
		end
	end
   end
end
How do I set a function in my script to override that function completely? I would want the geyser lua package included with mudlet to call my function, not it's own. At the moment i've just manually changed the GeyserLabel.lua file. That doesn't work for a distributed package though, I can't expect other people to change the file.

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Override getWindow function?

Post by Nyyrazzilyss » Tue Feb 23, 2016 3:34 am

I'm not sure if it worked 100%, but it appears that just pasting that into my package itself (since it gets loaded after geyser) replaced the function. I'm not sure if that only effects my script calling the function, or also (if) geyser itself tries calling the function.

User avatar
Vadi
Posts: 4667
Joined: Sat Mar 14, 2009 3:13 pm

Re: Override getWindow function?

Post by Vadi » Sat Mar 04, 2017 4:11 pm

Just pasting it into the package works, you then overwrite the default implementation.

Is this your final fix and have you seen any sideeffects? Flyout labels (I renamed them from nested labels - seems to make more sense to me) were originally made with the caveat that they're not nestable, but if this fixes it, would be happy to include the fix.

I've also went through and explained them a lot better, let me know what do you think of http://wiki.mudlet.org/w/Manual:Geyser#Flyout_Labels.

Nyyrazzilyss
Posts: 334
Joined: Thu Mar 05, 2015 2:53 am

Re: Override getWindow function?

Post by Nyyrazzilyss » Sun Mar 05, 2017 7:53 pm

I'd totally forgot about the change i'd made to getWindow - The lua code in the original post is identical to what i'm using.

I've never run into any problems over the past year that took me back to it, though looking at it now the change i'd made was searching down 1 additional level. It had never popped up again that I'd needed it, however, it should probably be re-written to search down an unlimited number of levels.

Glancing at the instructions, yes that change does eliminate 'Note that the main flyout label cannot go into a container and needs to be on its own.'

User avatar
Vadi
Posts: 4667
Joined: Sat Mar 14, 2009 3:13 pm

Re: Override getWindow function?

Post by Vadi » Sun Mar 05, 2017 8:58 pm

Awesome. Would you mind throwing this up as a PR to https://github.com/vadi2/mudlet-lua/blo ... rLabel.lua? You can just hit the edit button right on the page once logged in.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests