Python Scripted 'morph changer/tracker' using else:

Posted by Ravien on Mon 09 Mar 2009 09:30 PM — 9 posts, 37,786 views.

#0
Hi all,

I'm looking for some friendly help before I start throwing monitors out of windows. I've tried to look for what I need within the forums with no luck. I've tried fellow achaeans and also google... I am not by any means a coder.

OK, I play achaea and I have certain 'morphs' I can use. Each morph has handy little things I can use in, for example, a combat sitiation. Morphing in achaea uses a hell of a lot of enurance so while I can set aliases to go from one to other other depending on the attack I want to do, I can't get it to not morph if I am already in said morph.

Really crappy example but should get the jist of what I am trying to do ( I just don't know how else to work it). I already have variables set for each morph I have based off of a trigger.

(Alias is called 'forage')


if world.GetVariable("squirrel") == "yes":
 world.Send("forage")
else:
 world.Send("morph squirrel")
 world.Send("forage")


My main hunting skill is also maul, to which I have an alias of 'm'. However with the above kind of script, I end up morphing jaguar and mauling my target whenever 'm' is
used in a word.

(Alias is called 'm')


if world.GetVariable("jaguar") == "yes":
 world.Send("maul @target")
else:
 world.Send("morph jaguar")
 world.Send("maul @target")


Is there a way so that a) It doesn't maul whenever I use the letter 'm' in anything and b)solve the same problem as the first alias example. i am god awful at this but giving it a go. I just need directing.

Thanks if anyone can help!
Amended on Mon 09 Mar 2009 11:52 PM by Nick Gammon
Australia Forum Administrator #1
Quote:

Is there a way so that a) It doesn't maul whenever I use the letter 'm' in anything


To answer this first, don't check "regular expression" in the alias. A regular expression of just "m" will match anything with "m" in it.
#2
Ah ok, followed advice from a friend there who I wont listen to anymore!
Australia Forum Administrator #3
Quote:

I can't get it to not morph if I am already in said morph.


Well you need to set the variable you subsequently test, don't you?


if world.GetVariable("squirrel") == "yes":
 world.Send("forage")
else:
 world.Send("morph squirrel")
 world.Send("forage")
 world.SetVariable ("squirrel", "yes")
#4
Well I have a trigger for the line so the variable changes. So as soon as I 'morph squirrel' it sets the variable to yes.


I tried adding what you added and it doesn't recognise anything at all. (thank you for the help by the way)
Australia Forum Administrator #5
What do you mean exactly by "it doesn't recognise anything at all"? Does the trigger not fire, or are you talking about something else?
#6
I added the line to set the variable. When I tried to forage after that as a test, it didn't fire.
Australia Forum Administrator #7
In that case can you show the whole thing? (the alias and the trigger). See:

http://mushclient.com/copying

Also check after you think the variable should be set (ie. "squirrel" is "yes") that the variable is in fact set, by looking in the "variables" tab of the world configuration.
USA #8
Ravien,

Make a variable called morph. Leave it blank for now.
Add triggers for each morph that change the value of that variable to the morph name; eg

MATCH:You are surrounded by the spirit of the jaguar.
SEND: world.SetVariable('morph','jaguar')
SEND TO : Script
GROUP; Morphs

Click the 'convert to reqular experession button.

Do the above for each morph you have, and one for returning to default race.

In an alias, for example m for maul;

MATCH:^m$
SEND:

if world.GetVariable('morph') == 'jaguar':
    world.Send('maul %s' % world.GetVariable('target'))
else:
    al_alert('Not in morph!!')
    world.Execute('morph jaguar')

Check the box, Regular expression and expand variables.

Do that same format for aliases you want to check the morph.

Hope that helps, if you need more, email.