[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Code Infobar

Code Infobar

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Halig   Portugal  (123 posts)  [Biography] 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
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] 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
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] 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. ;)
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] 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
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] 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>
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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:


room = tonumber (room)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] 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>
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] 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

room = tonumber("vnum")


Yes, but the literal string "vnum" will never be 1205, right?

You need:


room = tonumber(vnum)

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Halig   Portugal  (123 posts)  [Biography] bio
Date Reply #8 on Sun 22 Feb 2015 07:50 AM (UTC)
Message
Thank you Nick. It's working now :).
[Go to top] 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.


20,655 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]