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
➜ Python
➜ Affects in infobar script
Affects in infobar script
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Afkeraeon
(7 posts) 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 :( | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Afkeraeon
(7 posts) 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 | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) 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 | Top |
|
Posted by
| Afkeraeon
(7 posts) 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? :) | Top |
|
Posted by
| Afkeraeon
(7 posts) 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! | 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.
16,942 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top