Vyzor, UI Manager for Mudlet

Share your scripts and packages with other Mudlet users.
User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Akaya »

I think Vyzor.Map() is bugged now. It keeps returning the following error:
vyzor\component\map.lua:166: attempt to compare number with string.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Oneymus »

Line 166 is...
Code: [show] | [select all] lua
if x >= 0.0 and x <= 1.0 then
x, in this case, is passed to .Map() as the first argument. If you're getting that error, the most likely problem is that a string is being passed. I would suggest taking a close look at what you've got there.

Failing that, I could have inadvertently changed (I haven't touched map.lua in 10 months) something important somewhere. This is unlikely, since I've only made minor changes to unrelated files recently, but you never know.

Let me know if double-checking the arguments doesn't solve your problem, and I'll do some more extensive research.

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Akaya »

:shock: Gah! You're right. I overlooked something. I had:
Code: [show] | [select all] lua
The_Map = Vyzor.Map("The_Map", 0, 0, 1, 1 )
There's no argument for the map name. I'm guessing this is because only one map can be added at a time. Frames and most Components have the name as the first argument. This isn't the first time I've fallen victim to this error.

The correct way:
Code: [show] | [select all] lua
The_Map = Vyzor.Map( 0, 0, 1, 1 )
So this isn't a bug! My apologies!

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Oneymus »

No worries. I did, indeed, leave out a name argument because you can only have one map. Truth be told, it's gotten me a couple times.

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Akaya »

Is it possible to name a frame from a variable? So if I have a variable named FrameName set to Apple, would it be possible to FrameName = Vyzor.Frame(FrameName) and have it be named Apple? So if I want to create/manipulate another Frame, I could set the FrameName variable to something else, like Banana and create/manipulate the Banana Frame? Been toying with the idea for a bit now but haven't gotten any decent results.

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

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Vadi »

I this would do (going off Lua only, nothing Vyzor specific), if you wanted the resulting FrameName to be global:
Code: [show] | [select all] lua
_G[FrameName] = Vyzor.Frame(FrameName)

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Oneymus »

Unless I'm misunderstanding your question, I would do pretty much exactly what Vadi suggests. In fact, I do that in a couple places (especially for the Chat Compound) to set some global, variable-named functions so that I can use them in Events.
Code: [show] | [select all] lua
	_G[switch_func] = function (channel)
		if channel == current_channel then
			return
		end
		for n, console in pairs( mini_consoles ) do
			if n == channel then
				console:Show()
			else
				console:Hide()
			end
		end

		for i, n, tab in tabs() do
			if n == channel then
				if tab.Components["Background"] then
					tab:Remove( "Background" )
				end
				tab:Add( active_background )

				if pending_channels[n] then
					pending_channels[n] = nil
				end
			else
				if not pending_channels[n] or channel == "All" then
					if tab.Components["Background"] then
						tab:Remove( "Background" )
					end
					tab:Add( inactive_background )
				end
			end
		end

		current_channel = channel
	end

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Akaya »

I'm writing a script that will create Frames for you. In order to create a Frame with the Vyzor.Frame() function you must first assign it to a variable so it can be used much easier later down the line when you add things to it, like backgrounds, borders and such.

So here's my alias that *should* create a frame with the name given in the alias pattern.
Code: [show] | [select all] lua
PATTERN
^Frame Name: (.*)$

SCRIPT

NameFrame = matches[2]

NameFrame = Vyzor.Frame(NameFrame)

Config[NameFrame] = {
	XPos = .5,
	YPos = .5,
	XSize = .1,
	YSize = .1,
	Drawn = false
}

NameFrame:Move(Config[NameFrame].XPos,Config[NameFrame].YPos)
NameFrame:Resize(Config[NameFrame].XSize,Config[NameFrame].YSize)
Now though this will create a new Frame, it doesn't create a unique frame each time. Users are going to want to create multiple Frames and I need a way to reference to them for I don't know what they're going to name each one. The above example creates a frame called NameFrame and not whatever was stored in matches[2].

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by chris »

I haven't ran it, but some guesses at what may help:
1) use a local variable for matches[2], not named NameFrame
2) I'm not sure what object Vyzor.Frame is, and whether lua allows it as a table key, keys usually need to be hashable - I doubt a Vyzor object is. Try Config[local_var], to point at the NameFrame, so something like:
Config[local_var] = Vyzor.Frame(.....) and just init everything in there. Keep all your attributes, etc. attached to the object instead of having to do multiple mappings.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Vyzor, UI Manager for Mudlet [Beta?]

Post by Oneymus »

It may be a little odd, but you could so something like this:
Code: [show] | [select all] lua
PATTERN
^Frame Name: (.*)$

SCRIPT
NameFrame = matches[2]

-- Some global reference to a frame table...
-- If you want, you could even put them in _G.
-- _G[FrameName] = Vyzor.Frame( FrameName, ... )
_frames[FrameName] = Vyzor.Frame( FrameName, ... )

Config[FrameName] = {...}
Vyzor.Frame will return a table and, while the address of a table (tostring()) can be used as a table key, it's not pretty. As I illustrate above, if you're not going to place them directly in _G, you should maintain your own table of Frames indexed by name. That's the easiest way, and the method I use for my GUIs.

Post Reply