Help Creating a Status Window

Share your scripts and packages with other Mudlet users.
Post Reply
ElJefe
Posts: 2
Joined: Wed Jul 28, 2010 12:24 am

Help Creating a Status Window

Post by ElJefe »

Hello all,

I am incredibly new to Mudlet, and very new to LUA scripting as well.

I'm trying to create a small, status window (miniConsole), that will show the status of certain buffs within my MUD (and update that status whenever the buffs are dispelled or expire due to time).

Quite honestly, I am at a complete loss of how to start aside from defining triggers that toggle the buff status as either on or off.

Is there anyone out there that would be willing to help me do this on a step-by-step basis?

User avatar
tsuujin
Posts: 695
Joined: Fri Feb 26, 2010 12:59 am
Location: California
Contact:

Re: Help Creating a Status Window

Post by tsuujin »

First, because you're going to hear this anyways I'm sure: It's Lua, not LUA. Not an acronym.

Creating windows is pretty easy in Mudlet, but I came from MUSH which made the process as complex as possible (although quite powerful) and before that the Windows API for C++, which -really- made creating a window a complex process.

Give me an idea of what you want the window to look like, where you want it on the screen, and so forth.

Sinnamon
Posts: 3
Joined: Sun Jul 11, 2010 11:02 pm

Re: Help Creating a Status Window

Post by Sinnamon »

Rather than a miniconsole to display spell status, I've used labels. They change color based on their status. They are at the bottom on this screen shot. One reason I chose labels is because you can set a function to be called when you click them. It is still a work in progress, Aardwolf has an awful lot of buffs and I haven't put them all in yet or organised them terribly well. Thinking of changing the labels to gauges to show how long until the spell expires, haven't got around to it yet though. Anyway, just an idea for your consideration.
Image

ElJefe
Posts: 2
Joined: Wed Jul 28, 2010 12:24 am

Re: Help Creating a Status Window

Post by ElJefe »

tsuujin wrote:First, because you're going to hear this anyways I'm sure: It's Lua, not LUA. Not an acronym.

Creating windows is pretty easy in Mudlet, but I came from MUSH which made the process as complex as possible (although quite powerful) and before that the Windows API for C++, which -really- made creating a window a complex process.

Give me an idea of what you want the window to look like, where you want it on the screen, and so forth.
I'd kind of like a little label bar directly above the input bar (if we can make the mud text not fall behind the labels). Ideally, the buttons would contain the name of the buff in question and would toggle colors when the buff is either activated or dispelled (blue for on, red for off, with an easily readable text color inside them. Furthermore, It'd be nice to have a bit of blackspace (like one character's worth) between each one, though this isn't a complete necessity.

I'm going to need buttons for eight buffs total.

I've attached a .pdf file showing a rough drawing of what I'm after.
Attachments
Buttons.pdf
(14.69 KiB) Downloaded 654 times

Knute
Posts: 87
Joined: Fri Mar 05, 2010 12:08 am

Re: Help Creating a Status Window

Post by Knute »

All you would need to do is to set up a table such as:
Code: [show] | [select all] lua
buffsTable = { 
        {name = "buff1", activated = "Buff 1 is active", deactivated = "Buff 1 is deactivated"}.
        {name = "buff2", activated = "Buff 2 is active", deactivated = "Buff 2 disappears."}
}
Then, you can set up a function to run through the table and set the activated and deactivated triggers.
You can use temp triggers or perm triggers. Either one will work.
You will also want another function to actually draw the labels.

To set up the buttons, you could try something along the lines of:
Code: [show] | [select all] lua
setBorderBottom(40)
buffact = {}
buffdeact = {}
function myBuffGauges()
     local width,height = getMainWindowSize()
     local fntwide, fnthigh = calcFontSize(20)
     local buffLabelWidth = width/(#buffstable + 1)
     local barheight = 30
     local x = buffLabelWidth + fntwide
     local y = height - (barheight *.75)
     for k,v in pairs(buffsTable) do
             createLabel(v[name], x*k, y, buffLabelWidth, barheight, 1)
             setBackgroundColor(v[name], 255,0,0,255)
             setFgColor(v[name], 255,255,255)
             showWindow(v[name])
             buffact[v.name] = tempRegexTrigger(v.activated, setBackgroundColor(v[name], 0,0,255,255))
             buffdeact[v.name] = tempRegexTrigger(v.deactivated, setBackgroundColor(v[name].255,0,0,255))
    end
end
myBuffGauges()
Not sure if that'll work for ya or not. You may need to fiddle with the v[name] and make it v.name instead, but that should set it up for you. Then, rather than mucking with the code, all you need to do to change something is to change the table.

HTH

[edit] hehehe.... Forgot to add the showWindow command in there. :) [/edit]

hezman
Posts: 1
Joined: Mon Aug 23, 2010 12:17 am

Re: Help Creating a Status Window

Post by hezman »

I'm a big newbie here with Mudlet but I would also like to implement this feature. Can anyone elaborate on the last post? I can't get the first snippet of code to work, and I'm also not sure how to set up the triggers to set each buff.

Thanks everyone!

Post Reply