Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Code Infobar
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Halig
Portugal (123 posts) Bio
|
Date
| Fri 20 Feb 2015 09:41 AM (UTC) |
Message
| Hi to all. What is wrong with this piece of code?
What i want is to show in the infobar, the vnum of the room that i'm in. I have everything working, but i can't make the colour to change. If the variable vnum is equal to 1205, then the text will be red, if the room is diferent, the colour will be blue.
InfoFont("FixedSys", 12, 0);
InfoColour("black");
Info("Sala: ");
if (room == 1205)
then
InfoColour ("red")
InfoFont("FixedSys", 12, 2)
Info(vnum)
else
InfoColour ("blue")
InfoFont("FixedSys", 12, 2)
Info(vnum)
end -- if
Thank you | Top |
|
Posted by
| Meerclar
USA (733 posts) Bio
|
Date
| Reply #1 on Fri 20 Feb 2015 06:40 PM (UTC) |
Message
| What exactly are you trying to match on? |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | Top |
|
Posted by
| Halig
Portugal (123 posts) Bio
|
Date
| Reply #2 on Fri 20 Feb 2015 09:03 PM (UTC) |
Message
| Hi. I'm trying to match the room vnum, in this case, 1205.
I already have a variable that changes when i change room. So i'm just trying to get the infobar showing when i'm in room 1205 it will be red, when i'm on any other room, it will be blue. I have that working, but in Jscript. I want this in lua. ;) | Top |
|
Posted by
| Meerclar
USA (733 posts) Bio
|
Date
| Reply #3 on Fri 20 Feb 2015 09:36 PM (UTC) |
Message
| What is the exact text you are trying to match? If you have it working in java, paste that here as well and the conversion should be simple enough. |
Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org | Top |
|
Posted by
| Halig
Portugal (123 posts) Bio
|
Date
| Reply #4 on Fri 20 Feb 2015 09:54 PM (UTC) |
Message
| <aliases>
<alias
match="^-infobar(.*)"
enabled="y"
expand_variables="y"
regexp="y"
send_to="12"
keep_evaluating="y"
sequence="100"
>
<send>var cor; cor = "Blue"; //info font color
var back; back = "#D6D6D6"; //backgroud color
var other; other = "Red"; //other font color
var show;
if("%1"==" 0") show = 0;
else show = 1;
var wield;
var sanc;
arma_1 = world.getvariable("wield");
sanc = world.getvariable("sanc");
ShowInfoBar(0);
InfoClear();
InfoBackground(back);
InfoFont("FixedSys", 12, 0);InfoColour("Black");
Info("Wielded: ");
InfoFont("FixedSys", 12, 1);
if(wield == "nada") InfoColour(other); else InfoColour(cor);
Info(arma_1 + " ");
InfoFont("FixedSys", 12, 0);InfoColour("Black");
Info("Sanctuary: ");
InfoFont("FixedSys", 12, 1);
if(sanc == "on")InfoColour(cor);
else if(sanc == "off")InfoColour(other);
Info(sanc + " ");
ShowInfoBar(show);</send>
</alias>
</aliases> | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #5 on Sat 21 Feb 2015 01:31 AM (UTC) |
Message
| Variables from GetVariable are strings. In Lua strings and numbers compare differently. Try:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Halig
Portugal (123 posts) Bio
|
Date
| Reply #6 on Sat 21 Feb 2015 01:42 AM (UTC) Amended on Sat 21 Feb 2015 11:34 PM (UTC) by Nick Gammon
|
Message
| Nick, i'm sorry, but i can't manage to figure where to put that in this code:
<aliases>
<alias
match="^-infobar"
enabled="y"
expand_variables="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>vnum = GetVariable("vnum")
wizi = GetVariable("wizi")
wield = GetVariable("wield")
players = GetVariable("players")
room = tonumber("vnum")
ShowInfoBar(False)
InfoClear()
InfoBackground("grey")
InfoFont("FixedSys", 12, 0)
InfoColour("black")
Info("Sala:")
if (room == 1205)
then
InfoColour ("red")
InfoFont("FixedSys", 12, 2)
Info(vnum)
else
InfoColour ("blue")
InfoFont("FixedSys", 12, 2)
Info(vnum)
end -- if
InfoFont("FixedSys", 12, 0)
InfoColour("black")
Info(" Wizinvis:")
InfoFont("FixedSys", 12, 2)
InfoColour("blue")
Info(wizi)
InfoFont("FixedSys", 12, 0)
InfoColour("black")
Info(" Weapon:")
InfoFont("FixedSys", 12, 2)
InfoColour("blue")
Info(wield)
InfoFont("FixedSys", 12, 0)
InfoColour("black")
Info(" Horas:")
InfoFont("FixedSys", 12, 2)
InfoColour("blue")
Info(hours)
InfoFont("FixedSys", 12, 0)
InfoColour("black")
Info(" Players:")
InfoFont("FixedSys", 12, 2)
InfoColour("blue")
Info(players)
ShowInfoBar(true)</send>
</alias>
</aliases>
| Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #7 on Sat 21 Feb 2015 11:41 PM (UTC) Amended on Sat 21 Feb 2015 11:42 PM (UTC) by Nick Gammon
|
Message
|
Yes, but the literal string "vnum" will never be 1205, right?
You need:
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Halig
Portugal (123 posts) Bio
|
Date
| Reply #8 on Sun 22 Feb 2015 07:50 AM (UTC) |
Message
| Thank you Nick. It's working now :). | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
23,886 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top