Affects in infobar script

Posted by Afkeraeon on Sat 18 Dec 2004 09:23 AM — 6 posts, 22,069 views.

#0
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 :(
Amended on Sat 18 Dec 2004 10:16 AM by Afkeraeon
Australia Forum Administrator #1
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.

#2
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
Australia Forum Administrator #3
Have you looked at the file exampscript.pys that ships with MUSHclient? That shows setting up functions and calling them from triggers etc.
#4
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? :)
#5
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!