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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Tips and tricks
. . -> [Subject]  Triggers and putting a balance on them

Triggers and putting a balance on them

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1 2  

Posted by Natasi   (79 posts)  [Biography] bio
Date Sat 19 Jun 2004 06:30 AM (UTC)
Message
Hello all, I need help setting up triggers so that when they go off they check first for herb/salve balance before eating/drinking the cure. I've heard this has been done alot for Zmud, but the posts I've seen confused me a little, if someone can show me how to set it so that it checks before using the cure I'd appreciate it, thanks!


<triggers>
<trigger
custom_colour="9"
enabled="y"
group="Reflex"
match="^Your mind feels suddenly dulled and slow\.$"
regexp="y"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>send &quot;outb goldenseal&quot;
send &quot;eat goldenseal&quot;</send>
</trigger>
</triggers>
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #1 on Sat 19 Jun 2004 08:24 AM (UTC)
Message
Best thing to do is to use scripting either through the main script file or in a plugin. Here's an example script in Python, with comments:


from time import clock

class Balance(object):
    """ This is the main balance class. All types of balances
    (herb, salve, tree, focus, etc.) can be derived from it. """
    def __init__(self, timer):
        """ This is called when a new balance is created. We set the
        initial state for the given balance to True, and supply the timer
        period for the balance - the time it takes to recover this balance.

        herbBalance = Balance(2.0)"""
        self.state = True
        self.timer = timer
        self.offTime = clock()

    def __setattr__(self,name, value):
        """ This is for internal use only, it is called when the value of self.state
        is changed """
        if name == "state":
            if value:
                object.__setattr__(self, name, value)
                if globals().has_key("CureAfflictions"):
                    CureAfflictions()
            else:
                if self.state:
                    self.offTime = clock()
                    object.__setattr__(self, name, value)

    def CheckTime(self):
        """ Checks how much time has passed since the balance's been set False,
        if it's been longer than self.timer then we set it back to True. This method
        if for internal use only, you'll never have to use it """
        if (clock() - self.offTime) >= self.timer:
            return True
        else:
            return False

    def TimerExpired(self):
        """ Called to figure out whether the balance timer has expired """
        if not self.state:
            self.state = self.CheckTime()

#Create a herb balance
herbBalance = Balance(2.0)

#Create a list to hold afflictions you have
afflictions = []

def SaveAffliction(name, value):
    """ This can be called by triggers to set/reset afflictions. To set an affliction use:
    SaveAffliction("curare", 1)
    To reset it:
    SaveAffliction("curare", 0) """
    global afflictions
    if value:
        if name not in afflictions:
            afflictions.append(name)
    else:
        if name in afflictions:
            afflictions.remove(name)

def CureAfflictions():
    """ Call this to cure afflictions according to priority or just how they appear in the
    list. """
    global afflictions, herbBalance
    #If we have herb balance then cure prioritized
    if herbBalance.state:
        if "curare" in afflictions:
            world.Send("outr bloodroot")
            world.Send("eat bloodroot")
            #set herb balance false
            herbBalance.state = False
        elif "aconite" in afflictions:
            world.Send("outr goldenseal")
            world.Send("eat goldenseal")
            #set herb balance false
            herbBalance.state = False



Then from your affliction triggers you could send to Script, and send
SaveAffliction("aconite", 1)
to note that you now have stupidity, and
SaveAffliction("aconite", 0)
to note that you are no longer stupid. The only other thing you'll need is either a prompt trigger or a plugin with OnPluginPartialLine event defined, either of these should call the TimerExpired method for each balance object, i.e. like this:


herbBalance.TimerExpired()


As long as the CureAfflictions function can recognize all the afflictions by name, and you have triggers for all afflictions, the script will take care of all the gruesome details automatically by curing whatever you have when you have a corresponding balance.
[Go to top] top

Posted by Natasi   (79 posts)  [Biography] bio
Date Reply #2 on Sat 19 Jun 2004 11:27 AM (UTC)
Message
Is all that actually how it looks or was that just a global example? For the triggers I posted earlier, can you show me what that would look like when done in Python as you have said?
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #3 on Sun 20 Jun 2004 09:22 PM (UTC)
Message
Your trigger catches an affliction, so it would look almost the same, save for the <send> portion:


<triggers>
<trigger
custom_colour="9"
enabled="y"
group="Reflex"
match="^Your mind feels suddenly dulled and slow\.$"
regexp="y"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
<send>SaveAffliction(&quot;aconite&quot;, 1)</send>
</trigger>
</triggers>


Given that Stupidity is known as "aconite" in your script. The affliction is saved in a list by the SaveAffliction function, but is actually cured by the CureAfflictions one, so that's where you'll need to add more afflictions to be cured at.
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #4 on Mon 21 Jun 2004 04:04 AM (UTC)
Message
With due respect, hasn't this been covered a half-billion times in these forums? Hasn't anyone who plays those affliction muds written a plugin yet?

At any rate, Natasi, if Python isn't your bag, search the forums. This is a common project that has been mentioned many times before.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #5 on Mon 21 Jun 2004 12:30 PM (UTC)
Message
I think someone had written this huge plugin that cured all afflictions and was somewhere on the forums... Could I be any more vague?

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Opto   (3 posts)  [Biography] bio
Date Reply #6 on Mon 21 Jun 2004 01:42 PM (UTC)
Message
and where may i ask is this? i can't seem to find it on the forum
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #7 on Mon 21 Jun 2004 04:02 PM (UTC)
Message
Hm, I don't know, do a forum search for it, otherwise if someone remembers they could post it... It wasn't long ago, although I may be totally off and it could have been something different... Maybe look at the plugins page, it should be there.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #8 on Mon 21 Jun 2004 04:31 PM (UTC)

Amended on Mon 21 Jun 2004 04:39 PM (UTC) by Magnum

Message
Here's an old thread I participated in somewhat, but there is no finalized plugin, just script routines posted here and there:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2125&page=1

Try doing a forum search using keywords based on the afflictions or their cures. For example, there are quite a few results if you search the forums for "goldenseal".

Hmm, this thread seem relevant, don't know if his plugin does what you want...

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

Also, this one looks good:

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

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Reply #9 on Wed 23 Jun 2004 03:43 PM (UTC)
Message
Greets all,

As yet, there's no plugin for healing these affliction MUDs, I'm working on one right now though. The repetitive postings on this subject is starting to drive me nuts too. I've never done a real plugin before, but if it passes muster, I'll submit it. Hopefully it'll stem the "How do I make herb balance" tide.

Open the watch.
[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Reply #10 on Fri 09 Jul 2004 04:25 PM (UTC)
Message
Greets all,

Of got a kind of "beta" version of the "herb balance" plugin. When I try it, it seems to work well, but I don't know about other people. I have one other person testing it right now, but he's been delayed a bit. Would it be possible to submit this plugin? I could then post on a few boards related to Aetolia and see if anyone else would be willing to download it and test it. If it's alright to submit works in progress, where do I submit it to?

Thanks!

Open the watch.
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #11 on Fri 09 Jul 2004 10:55 PM (UTC)
Message
Someone should run a plugin CVS server :p

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #12 on Sun 11 Jul 2004 03:23 AM (UTC)
Message
Nick Gammon hosts several plugins here:

http://www.gammon.com.au/mushclient/plugins/

Most are his own, but there are a few by other authors. In order to get him to a host a plugin for you, you would have to use the form on his contacts page to send him a message. If he is interested (and likely would be), he will respond via Email, and tell you that you can reply and attach the plugin file to that reply Email.

This can be somewhat combersome for works in progress that may require frequent updating.

As of this posting, Nick does not have any automated method of submitting [updated] plugins for hosting.

So... if you can build your own web page somewhere, then it may be advisable to do that, and host your own plugins there, and provide a link personally to friends. You could also publish the link in your signature like I do.

If you are unable to build your own web page anywhere, then I would be willing to host the file for you on my webpage. See what I have now for current examples of how I do that. (URL is in my sig.)

Still, you would be relying on me to accept your Email, then FTP the stuff up to my website. As Shadowfyr will acknowledge, sometimes it can take me a couple of days to getting around to do this... Heh. So, best bet is host it yourself somewhere if you can. At least for now.

I am reminded of web sites for popular games, where visitors can upload game maps for usage by other players. Such sites usually have a setup where the uploaded maps are available immediately to other visitors. Perhaps one day Nick may be able to arrange a similar setup, except for plugins.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] bio
Date Reply #13 on Sun 11 Jul 2004 05:55 AM (UTC)
Message
If someone has a static IP, and feels like running MC (perhaps on a seperate computer), someone could wip up a chat plugin to allow plugins to be transferred like that. (an automated plugin where you connect, and upload your plugin, download others, etc).

I guess then someone could mirror it to a webpage occassionally too (or, with scripts, could update the webpage immediately).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
[Go to top] top

Posted by Bobble   Canada  (76 posts)  [Biography] bio
Date Reply #14 on Fri 20 Aug 2004 05:12 PM (UTC)
Message
Alright, I'm slow, but I finally got my password issues with my ISP worked out and have access to my own webspace. Here's the plugin address: http://home.cogeco.ca/~tchristensen38/Aetolia_affliction_healer.xml

This is still a work in progress. It's designed for Aetolia, but, with some simple modding, it could be made to work on any IRE MUD. I'd love any feedback anyone has. I'm actually a little proud of it, though I imagine there will be some bugs in it. As those get submitted to me, I will try to make updates.

If anyone feels so inclined and wants to look at the scripting and so on and tell me if there's any way to make things more parsimonious, I'd love that. I'm all for parsimony in scripting.

Please send any questions, bugs, via the forum's "e-mail this user" function. Take care all.

Open the watch.
[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.


61,281 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]