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
➜ Python dict, and iteration
Python dict, and iteration
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rakon
USA (123 posts) Bio
|
Date
| Tue 15 Nov 2005 01:27 AM (UTC) |
Message
| Greetings once agian.Simple question, hopefully has a simple answer.Im attemping to put a curelist together through scripting, and well, I cant figure out how to get the right cure for a certian affliction.Heres a part of what I have so far
def cureit(name,output,wildcards):
pbal = world.GetVariable("pbal")
anor = world.GetVariable("anorexia")
eq = world.GetVariable("eq")
paralysis = world.GetVariable("paralysis")
pipes = int(world.GetVariable("pipes"))
pipe1 = world.GetVariable("pipe1")
pipe2 = world.GetVariable("pipe2")
pipe3 = world.GetVariable("pipe3")
asleep = world.GetVariable("asleep")
cures1 = {"stupidity":"goldenseal"}
if pbal == "no":
return
if anor == "yes":
world.Send("smoke " + pipe2)
return
else:
cures = {"stupidity":"goldenseal","paralysis":"bloodroot","confusion":"ash"}
for c, v in cures.iteritems():
world.SetVariable("pbal","no")
world.Send("outr %s" % (v))--now here,no matter the affliction, script sends "outr ash" to the world.
world.Send("eat %s" % (v))--and here it always sends "eat ash"
return
What I am trying to do is have a trigger call cureit, and use the approatie cure.Heres is the test trigger I have for it
<triggers>
<trigger
enabled="y"
match="* casts a net of stupidity over your mind."
script="cureit"
send_to="12"
sequence="100"
>
<send>world.ColourTell ("red", "black", "[AFFLICTED]: ")
world.ColourNote ("white", "black", "Stupidity")
world.SetVariable("stupidity", "on")</send>
</trigger>
</triggers>
Thanks. --Rakon
|
Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 15 Nov 2005 05:41 AM (UTC) |
Message
| |
Posted by
| Rakon
USA (123 posts) Bio
|
Date
| Reply #2 on Thu 22 Dec 2005 06:04 PM (UTC) |
Message
| Well, I decided not to muck around ith the Dictionary, and all, Just have a standard if/elif clause going.Thanks though!
--Rakon |
Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for. | Top |
|
Posted by
| Jestre
(13 posts) Bio
|
Date
| Reply #3 on Sat 24 Dec 2005 04:44 AM (UTC) |
Message
| You can use a dictionary you just need to use it properly. Your For loop is just iterating through the dictionary without checking whats on so it will always cure what it sets as first. | Top |
|
Posted by
| Rakon
USA (123 posts) Bio
|
Date
| Reply #4 on Sat 24 Dec 2005 09:39 PM (UTC) |
Message
| Jestre,thanks for your reply.I have the if/elif working like I need it to, but the whole issue with the Python Dict, was to try and use less memory so that MUSHclient wouldn't crash when it gets to be too much.So far, no problems,so I hope it stays that way.
--Rakon |
Yes, I am a criminal.
My crime is that of curiosity.
My crime is that of judging people by what they say and think, not what they look like.
My crime is that of outsmarting you, something that you will never forgive me for. | 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,423 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top