Register forum user name Search FAQ

Gammon Forum

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 ➜ VBscript ➜ Little help please

Little help please

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


Posted by Metsuro   USA  (389 posts)  Bio
Date Tue 20 Apr 2004 07:54 AM (UTC)
Message
greetings! I was wondering if it was possible to trigger a fews lines, and have the send there stuff not in order of how they were triggered. Like...

You are infected with semideadly posion
You are infected with Deadly posion
You are infected with posion

was wondering if you could do the deadly posion first then the semideadly then the normal, while waiting for another trigger stating.

You may eat another herb.

thank you for any help and suggestions.

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 20 Apr 2004 08:18 AM (UTC)
Message
You want to work out which herb to eat, is that it?

I would probably make each trigger (the 3 poison lines) store a "flag" in a variable, eg. using SetVariable.

Something like this:

SetVariable "deadlypoison", 1

Then when you get the trigger firing "You may eat another herb." you look at the variables and decide which herb to eat. After that you clear all 3 flags. Something like this:


if GetVariable ("deadlypoison") = 1 then
  send "eat green herb"
elseif GetVariable ("semideadlypoison") = 1 then
  send "eat blue herb"
elseif GetVariable ("poison") = 1 then
  send "eat brown herb"
end if

SetVariable "deadlypoison", 0
SetVariable "semideadlypoison", 0
SetVariable "poison", 0


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #2 on Tue 20 Apr 2004 08:45 AM (UTC)
Message
but say, the trigger you may eat another herb is not sent off, and then the hole thing would not go off, so say you get hit with

You are infected with semideadly posion
You are infected with Deadly posion
You are infected with posion

and when you get it the first one, could you do like

GetVariable ("Herbbal") = 0 then
send "eat green herb" then
SetVariable "deadlyosion", 1

or something like that?



Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #3 on Thu 22 Apr 2004 07:10 AM (UTC)
Message
Sure, you can do anything you want. Your syntax is a little out, you need an "if" like this:



if GetVariable ("Herbbal") = 0 then
  send "eat green herb" 
  SetVariable "deadlyosion", 1
end if

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Gore   (207 posts)  Bio
Date Reply #4 on Thu 22 Apr 2004 07:23 AM (UTC)
Message
I do something like this for another mud I play.

Quote:
but say, the trigger you may eat another herb is not sent off, and then the hole thing would not go off, so say you get hit with

You are infected with semideadly posion
You are infected with Deadly posion
You are infected with posion

and when you get it the first one, could you do like

GetVariable ("Herbbal") = 0 then
send "eat green herb" then
SetVariable "deadlyosion", 1

or something like that?


What you could do, is trigger ea. affliction to go through sort of a queue, so to speak.

I.E. Trigger

You are infected with semideadly posion

to call this sub routine:

Sub SemiDeadly_Poison (a,b,wildcard)
  If World.GetVariable("Herbbal") = 1 then 
    World.Send "eat semideadly poison cure"
  World.SetVariable("Herbbal") = 0
End Sub


And what that does is, checks to see if you have herb balance (1 means true, or, you have herb balance), if so, send the command to cure yourself, and then set your herb balance variable to 0 (0 means false, or, you don't have herb balance.

Then you could do that for all of them, as well as have a small "queue" for your afflictions set to set off on the herb balance trigger. A more complex example would be something like this, and so I don't confuse you, I'll leave the actual triggers out.


Trigger Pattern: You are infected with semideadly posion
calls Subroutine: SemiDeadlyPoison

Trigger Pattern: You are infected with deadly posion
calls Subroutine: DeadlyPoison

Trigger Pattern: You are infected with posion
calls Subroutine: Poison

Trigger Pattern: You are cured of the semideadly posion
calls Subroutine: SemiDeadlyPoison_Cure

Trigger Pattern: You are cured of the deadly posion
calls Subroutine: DeadlyPoison_Cure

Trigger Pattern: You are cured of the posion
calls Subroutine: Poison_Cure

Trigger Pattern: You may eat another herb
calls Subroutine: Herb_balance


Dim SDPoison, DPoison, RegularPoison, HerbBalance

SDPoison = 0
DPoison = 0
RegularPoison = 0
HerbBalance = 1

Sub SemiDeadlyPoison (name,output,wildcard)
  SDPoison = 1
  If HerbBalance = 1 then
    World.Send "eat semi deadly cure"
    HerbBalance = 0
  End If
End Sub

Sub SemiDeadlyPoison_Cure (name,output,wildcard)
  SDPoison = 0
End Sub

Sub DeadlyPoison (name,output,wildcard)
  DPoison = 1
  If HerbBalance = 1 then
    World.Send "eat deadly cure"
    HerbBalance = 0
  End If
End Sub

Sub DeadlyPoison_Cure (name,output,wildcard)
  DPoison = 0
End Sub

Sub Poison (name,output,wildcard)
  RegularPoison = 1
  If HerbBalance = 1 then
    World.Send "eat reg poison cure"
    HerbBalance = 0
  End If
End Sub

Sub Poison_Cure (name,output,wildcard)
  RegularPoison = 0
End Sub

Sub Herb_Balance (name,output,wildcard)
  If SDPoison = 1 then
    World.Send "eat semi deadly poison cure"
    HerbBalance = 0
  ElseIf DPoison = 1 then
    World.Send "eat deadly poison cure"
    HerbBalance = 0
  ElseIf RegularPoison = 1 then
    World.Send "eat regular poison cure"
    HerbBalance = 0
  End If
End Sub


Now, the explanation. The trigger patterns are the triggers you'd put into the mud client itself. You'd put the name of the respective sub routines in the "Script" part. You'd need to make a script file, and put all of the vbscript code into that.

Dim SDPoison, DPoison, RegularPoison, HerbBalance

That's where you make all of the variables you want to use for your script. Note, these aren't permanent, and if you close the world, everything that's in there goes away. Under that, is where you define your variables. Obviously, when you log on, you're generally going to be clean of afflictions, and going to have herb balance. those four variables can be 1 or 0. 1 means you have it, 0 means you don't. So if SDPoison is 1, then you have the affliction. The sub "Poison" for example, checks to see if you have herbbalance, if you do, it eats the cure for it, and sets herbalance to off. When you actually cure the affliction, another subroutine is called and then sets the appropriate variable to off. When you get Herb balance back, it calls a subroutine called Herb_balance, that has a "queue" of afflictions listed in it, and it goes through these if statements to see what afflictions you have. If you have the first one, it'll heal it, then stop there. If you -don't-, it'll move on to the next affliction in the queue. Etc. Etc. This is -really- basic, and I would do stuff like, turn herb balance off when I actually eat an herb, etc. I hope this helps, post back if you have any questions (and this post is kinda sloppy, so I reckon you will :p)
Top

Posted by Metsuro   USA  (389 posts)  Bio
Date Reply #5 on Thu 29 Apr 2004 09:54 PM (UTC)
Message
Excuse me if i am wrong but doesn't both suggestions basicly do the same thing?

Everything turns around in the end
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 30 Apr 2004 10:07 PM (UTC)
Message
Quote:

but say, the trigger you may eat another herb is not sent off, and then the hole thing would not go off,


What is the problem? I agreed with your suggested solution. If your flag indicates you haven't taken a herb you eat one straight away.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


22,429 views.

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

Go to topic:           Search the forum


[Go to top] top

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