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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  Affects in infobar script

Affects in infobar script

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


Posted by Afkeraeon   (7 posts)  [Biography] bio
Date Sat 18 Dec 2004 09:23 AM (UTC)

Amended on Sat 18 Dec 2004 10:16 AM (UTC) by Afkeraeon

Message
Currently playing bard so I got about 10 protections i want to keep track off, first i thought i'd do it in the statusbar nick did but i couldn't figure any good way to update it. So this is what i need help with;

if strength == "Up!":
world.InfoColour ("green")
world.Info("Str " + strength + "; ")
else:
world.InfoColour ("red")
world.Info("Str " + strength + "; ")

if dex == "Up!":
world.InfoColour ("green")
world.Info("Dex " + dex + "; ")
else:
world.InfoColour ("red")
world.Info("Dex " + dex + "; ")

And so on...

Would it be possible to write one function for doing this, and if so, how do i add it to mushclient?

Was thinking I'd do something like this:

def ibar(prot)
if prot == 'Up!':
world.InfoColour ("green")
world.Info("prot " + prot + "; ")
else:
world.InfoColour ("red")
world.Info("prot " + prot + "; ")
I can't figure how to make it print the name of the variable though :(
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sat 18 Dec 2004 07:12 PM (UTC)
Message
I'm not a great expert on Python, but you seem to be on the right track. I would start with InfoClear to clear the previous text.

To get the variable use GetVariable, eg.

world.Info("Str " + world.GetVariable ("strength") + "; ")


You could put it into a function, or just put the whole lot into a timer "send" box, set the timer to fire every couple of seconds, and "send to script". That way, the commands get done every couple of seconds.


- Nick Gammon

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

Posted by Afkeraeon   (7 posts)  [Biography] bio
Date Reply #2 on Sat 18 Dec 2004 07:53 PM (UTC)
Message
Oh yeah, perhaps I should print the whole trigger :)
This is what I currently do:

world.send("nevstuff Skill drink [%^GREEN%^UP%^RESET%^]") #sends notice to world.

#Gets all vars:
strength = world.getVariable("str")
dex = world.getVariable("dex")
wis = world.getVariable("wis")

#Updates the prot that has fallen
world.setVariable("skilldrink","Up!")

#Get more vars:
achman = world.getVariable("achman")
limber = world.getVariable("limber")
skilldrink = world.getVariable("skilldrink")
cha = world.getVariable("cha")
grithmal = world.getVariable("grithmal")
kreativ = world.getVariable("kreativ")

#Clear info bar, set font, and print the text

world.InfoClear()
world.InfoFont("Comic sans ms", 10, 1)
world.Info("Str " + strength + "; Dex " + dex + "; Wis " + wis + "; Cha " + cha + "; Grithmal " + grithmal + "; Kreativ " + kreativ + "; Achman " + achman + "; Limber " + limber + "; Skilldrink " + skilldrink)

Now what I would like to do that instead of the last line that prints out all the stuff on infobar I want to make a pythoon function to which i send the variables and then colour that part of info text red respectively green wether the value of the variable is "Up!" or "Down!".

My biggest problem is to make python print the name of the variable and also to put the function in a script file and make it "callable" from MC.

/Afke
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 18 Dec 2004 08:09 PM (UTC)
Message
Have you looked at the file exampscript.pys that ships with MUSHclient? That shows setting up functions and calling them from triggers etc.

- Nick Gammon

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

Posted by Afkeraeon   (7 posts)  [Biography] bio
Date Reply #4 on Sat 18 Dec 2004 08:14 PM (UTC)
Message
Umm no, i'll do that :) thanks.
Still the problem with printing the name of the variable and not the value of it remains. Anyone know how to do it? :)
[Go to top] top

Posted by Afkeraeon   (7 posts)  [Biography] bio
Date Reply #5 on Sun 19 Dec 2004 06:03 PM (UTC)
Message
Ok finally got this shit working. For those who are interested I do like this now:

def IBar(protName, protStatus):
if protstatus == "Up!":
world.InfoColour ("green")
world.info(protName + " " + protstatus + "; ")
else:
world.InfoColour ("red")
world.info(protName + " " + protstatus + "; ")

This is done on all Up/Down triggers
Update var that changes. Get all vars. Clear infobar and set font and then send all the vars together with a name to the IBar function.

world.setVariable("wis","Down!")

strength = world.getVariable("str")
dex = world.getVariable("dex")
wis = world.getVariable("wis")
achman = world.getVariable("achman")
limber = world.getVariable("limber")
skilldrink = world.getVariable("skilldrink")
cha = world.getVariable("cha")
grithmal = world.getVariable("grithmal")
kreativ = world.getVariable("kreativ")

world.InfoClear()
world.InfoFont("Comic sans ms", 10, 1)

IBar("Str", strength)
IBar("Dex", dex)
IBar("Wis", wis)
IBar("Cha", cha)
IBar("Grithmal", grithmal)
IBar("Kreativ", kreativ)
IBar("Achman", achman)
IBar("Limber", limber)
IBar("Skilldrink", skilldrink)

Enjoy, and huge thanks to nick!
[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.


15,056 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]