Page 1 of 2

How to make 'Labels'

Posted: Sun Aug 22, 2010 2:53 pm
by Naito
Okay, I've been all over this forum and the Mudlet Manual.

I've read up on how to make Labels and think I have a pretty good understanding of what they are and how they work... I just have a few questions that the manual didn't cover and that I need answered before I can move on with my project.

Where do the 'labels' go? Do I make them within the 'script' section?

Secondly, what would you coding look like if I wanted the labels to change color when they are activated? Like say I was making a 'label' that was called 'Slickness' and I wanted to make it so that when I had 'slickness' the label would change to red and when it was cured it would change to white.

I'm unsure of how to do this and would appreciate a step by step... Not a redirection to someone else's coding to look at, as I am a new coder and I find it extremely easier if someone just explains it to me rather then me having to rip apart someone else's coding and still come out not knowing what I am doing.

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 3:42 pm
by Vadi
You make them with coding - createLabel spawns you a label.

To change colour, you can uset setLabelStylesheet and adjust the background-colour property

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 4:42 pm
by Naito
Didn't know about 'setLabelStylesheet' thanks.

Just a few questions, I currently have my coding set up like so:

WindowWidth=0;
WindowHeight=0;
WindowWidth, WindowHeight = getMainWindowSize();

function affliction_gauges()
createLabel("Slickness",0,0,0,1);
setBackgroundColor("Slickness",32,124,215,255)
end


Just to get a label started so it gives me something to work with, but when I have a new script set with just affliction_gauges() it comes up saying 'wrong argument type' so it doesn't really work... Am I doing something wrong here?

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 5:02 pm
by Vadi
Yes, you were missing the height argument of createLabel. This will work:

createLabel("Slickness",0,0,0,0,1);


... but it's not like you'll see anything, because the given label has a height and width of zero.

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 5:15 pm
by Naito
Aye, I was attempting to just get the code working first.

Now I have it set up so that it shows up and the like... Few problems though.

1) I can't seem to get it so that 'Slickness' is shown on the Label

2) I couldn't find any information for 'setLabelStylesheet' so I'm not exactly sure as to how it would be used....?

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 5:20 pm
by Vadi
echo("Slickness", "Slickness")

You just give it CSS code... my fancy gauges here on forums makes use of it.

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 5:33 pm
by Naito
I have no clue what CSS coding means.... Would you mind just giving me an example of what it would look like? It's much easier for me to figure things out that way.

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 6:11 pm
by Naito
I've tried to look at your 'Fancy Gauges' and change them to what I need... But I just can't seem to understand the coding behind it.
Code: [show] | [select all] lua
function create_hp_bar(x,y)
    createGauge("hp_bar", 0, 0, 0, 0, nil, "red")
    moveGauge("hp_bar", x,y)
    resizeGauge("hp_bar", 100, 20)
    setGaugeStyleSheet("hp_bar", [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #f04141, stop: 0.1 #ef2929, stop: 0.49 #cc0000, stop: 0.5 #a40000, stop: 1 #cc0000);
    border-top: 1px black solid;
    border-left: 1px black solid;
    border-bottom: 1px black solid;
    border-radius: 7;
    padding: 3px;]],
    [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #bd3333, stop: 0.1 #bd2020, stop: 0.49 #990000, stop: 0.5 #700000, stop: 1 #990000);
    border-width: 1px;
    border-color: black;
    border-style: solid;
    border-radius: 7;
    padding: 3px;]])
end

function create_end_bar(x,y)
    createGauge("end_bar", 0, 0, 0, 0, nil, "green")
    moveGauge("end_bar", x,y)
    resizeGauge("end_bar", 100, 20)
    setGaugeStyleSheet("end_bar", [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #98f041, stop: 0.1 #8cf029, stop: 0.49 #66cc00, stop: 0.5 #52a300, stop: 1 #66cc00);
    border-top: 1px black solid;
    border-left: 1px black solid;
    border-bottom: 1px black solid;
    border-radius: 7;
    padding: 3px;]],
    [[background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #78bd33, stop: 0.1 #6ebd20, stop: 0.49 #4c9900, stop: 0.5 #387000, stop: 1 #4c9900);
    border-width: 1px;
    border-color: black;
    border-style: solid;
    border-radius: 7;
    padding: 3px;]])

end

create_hp_bar(0,0)
create_end_bar(100,20)
Thats your coding as I'm sure you know.... But I don't see how that helps me in anyway to get something as simple as:
Code: [show] | [select all] lua
createLabel("Slickness",1000,0,80,20,1);
  setBackgroundColor("Slickness",32,124,215,255)
  echo("Slickness", "Slickness")
To change to a red color if I have Slickness... Is there no way to simply put in an 'if' statement in there so that it changes the color?

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 8:27 pm
by Vadi
setGaugeStyleSheet("Slickness", [[background-color: green]])

Re: How to make 'Labels'

Posted: Sun Aug 22, 2010 9:44 pm
by Naito
Holy crap.... I understand now, thank you and sorry for the many questions