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

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Python
. . -> [Subject]  Python dict, and iteration

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Python dict, and iteration
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Sat 24 Dec 2005 09:39 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Jestre   (13 posts)  [Biography] bio
Date Sat 24 Dec 2005 04:44 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Thu 22 Dec 2005 06:04 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 15 Nov 2005 05:41 AM (UTC)  quote  ]
Message
I'm not a Python expert, but take a look at this post:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=6074

It covers something very similar to what you are trying to do here.

- Nick Gammon

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

Posted by Rakon   USA  (123 posts)  [Biography] bio
Date Tue 15 Nov 2005 01:27 AM (UTC)  quote  ]
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.
[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.


3,262 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

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

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]