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
➜ General
➜ Half second timers
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2 3
Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
Date
| Reply #15 on Tue 17 Apr 2001 10:16 PM (UTC) |
Message
| Regular expressions
The examples I gave used:
^ - start of line
$ - end of line
Just leave them out if that is not what you want.
eg.
^Nick$ - "Nick" alone on the line
^Nick - "Nick" at the start of the lione
Nick$ - "Nick" at the end of the line
Nick - "Nick" anywhere on the line
Wildcards in timers
Quote:
I know how to use addtimer, but what if i wanted to put a wildcard into it
world.addtimer "blah", 0, 0, 2, "(need to punt wildcard here)", 5, ""
I'm not sure what you mean here. A timer goes off after so many seconds, you don't put a wildcard in it. However if you mean the wildcard from the trigger, here is an example. Say you have a trigger that matches on a monster name, eg.
* attacks you!
Then in this case the monster name is wildcard #1. So, to make a timer that says "kick dragon" after 2 seconds (assuming that the monster is a dragon) you would do this:
sub OnAttack (TriggerName, TriggerLine, Wildcards)
World.addtimer "my_timer", 0, 0, 2, "kick " + Wildcards (1), 5, ""
end sub
By using "+" you concatenate together two strings, in this case "kick" and the contents of wildcard 1.
Wildcards in aliases
Quote:
Same goes for an alias I need to make
Alias:
^(.*)= (.*) (.*)$
Punch right=rp @attacker
You would do a similar thing there ...
sub OnAliasCreation (TriggerName, Triggerline, arrWildCards)
world.AddAlias ("alias_" + cstr (world.getuniquenumber), arrWildCards (1), arrWildCards (2) + arrWildCards (3), 1 + 1024, "");
end sub
What the above is doing is:
Alias name: alias_22 (just a unique name for it)
Match on: Wildcard 1
Send: Wildcard 2 + Wildcard 3
Flags: Enabled + Replace any existing one of the same name
Script: None
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #16 on Wed 18 Apr 2001 03:28 AM (UTC) |
Message
| I need to know the flag for extended variables
Or where i can find it
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #17 on Wed 18 Apr 2001 04:46 AM (UTC) |
Message
| Ok NM on the flag, I found it after a little searching
You mentioned several posts back about a script that "walks" a trigger.
Pardon me for my cluelessness, but I don't even have a clue where to start something like that.
If you could, Please give me some Idea of what i would need to do to make a "walking " script
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
Date
| Reply #18 on Wed 18 Apr 2001 11:10 PM (UTC) |
Message
| Hmm - after a bit of research I found the "split" function, which is just what you need. :)
I quote from the VBscript manual, which shows the general idea ...
Split
Description
Returns a zero-based, one-dimensional array containing a specified number of substrings.
Syntax
Split(expression[, delimiter[, count[, compare]]])
The Split function syntax has these parts:
expression
Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.
delimiter
Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
count
Optional. Number of substrings to be returned; -1 indicates that all substrings are returned.
compare
Optional. Numeric value indicating the kind of comparison to use when evaluating substrings, as follows:
0 Perform a binary comparison.
1 Perform a textual comparison.
Remarks
The following example uses the Split function to return an array from a string. The function performs a textual comparison of the delimiter, and returns all of the substrings.
Dim MyString, MyArray, Msg
MyString = "VBScriptXisXfun!"
MyArray = Split(MyString, "x", -1, 1)
' MyArray(0) contains "VBScript".
' MyArray(1) contains "is".
' MyArray(2) contains "fun!".
In your case you want to use "split" on a space delimiter (which is the default anyway), so (without testing it) I would guess you would want something like this:
Dim MyArray
MyArray = Split (wildcards (1))
Now you can "walk" (there's that word again!) each of the elements in the array, as in this example:
Dim i
for i = lbound (MyArray ) to ubound (MyArray )
world.note MyArray (i)
next
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #19 on Thu 19 Apr 2001 12:15 AM (UTC) |
Message
| So lets see if I am as smart as I think I am.
I have this for a trigger match:
Combonation! ( rp s lp s r )
Match on: ^Combonation \( (rp|lp|s|r) * \)^
send to world: Blank
flags:enabled, and regular expression clicked on, all else off
Name:AutoCombo(for lack of a Better name)
script: OnAutoCombo
Now for the doozy:
sub OnAutoCombo (TriggerName, Triggerline, arrWildCards)
Dim AutoCombo
Autocombo= split (arrWildCards (1))
Dim i
for i=lbound (AutoCombo ) to ubound (AutoCombo )
world.send AutoCombo (i)
next
end sub
Ok Now about the trigger
^Combonation \( (rp|lp|s|r) * \)^
Is the (rp|lp|s|r) a wildcard?
I don't think it is
so what i think I can do is this
^Combonation \( (.*) \)^
That should work.
I am off to try to imp this, Get back to you soon with sucess, I hope.
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #20 on Thu 19 Apr 2001 12:38 AM (UTC) |
Message
| Ok, here is my results
First I could not get the regular expression trigger to work
Maybe i did something wrong, i am sure after playing with it i will get it to work
Now. I change the trigger to:
Combination! ( * )
And did the aforementioned code
It worked almost perfectly:
When i did:
world.note AutoCombo (i)
next
end sub
It worked perfectly
However, when I did:
world.send AutoCombo (i)
next
end sub
It did not work
I got the typical huh? type ? or help commands for help
I how would I change it so that i made it walk the combo using variables?
rp=punch right @attacker
sending rp at the command box works fine, sending rp from the script doesn't
what do I have to do to make it think rp=punch right @attacker
Just so you know that Split works perfectly
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
Date
| Reply #21 on Thu 19 Apr 2001 05:07 AM (UTC) |
Message
| I would do something like this:
'
' loop through each possible response
'
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
' ----> and so on for each different one
case "s" attack = "blah"
case "r" attack = "blah
case else attack = "" ' unknown attack type
End Select
' send our response if we found one
if attack <> "" then
world.send attack + " " + world.GetVariable ("attacker")
end if
next
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #22 on Thu 19 Apr 2001 05:49 AM (UTC) |
Message
| sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if attack <> "" then
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Wasn't 100% sure how to add the code you gave me.
I guessed in the implementaion,
I got an error:
-2146828275
Execution of line 77 column 1
AutoCombo split (arrWildCards (1))<--- Line 77
Type mismatch: 'AutoCombo'
Function/Sub: OnAutoCombo called by trigger
Reason: processing trigger "AutoCombo"
Unable to invoke script subroutine 'OnAutoCombo' While Processing trigger 'AutoCombo'
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #23 on Thu 19 Apr 2001 05:55 AM (UTC) |
Message
| Of course, 5 minutes after I post something, I figure out what i did wrong, I re looked at the code,
I re-read all the posts regarding it, and I noticed, i am missing an = sight
It shouls be:
AutoCombo = split (arrwildcards (1))
It was:
AutoCombo Split (arrWildCards (1))
I fixed it, and put everything the way I thought it should be...
It worked like a charm
Thanks Nick
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #24 on Tue 01 May 2001 06:24 AM (UTC) |
Message
| Ok, new problem
Autocombo works great
I want to add a twist to it now
Match on:Combination! ( rp rp r s r )
Now I end up getting the 5 attacks based on the select case part
What I want to do is end the combo, and insert another command instead of the last attack
In this case:
punch right
punch right
roundhouse
sweep
----- End string of characters ----
insert, Throw <Variable> down, instead of roundhouse
Someone mentioned using a counting function
if rp rp r s r=5 arrays
then select case for 4
and after next:
end if
next
world.send "throw " + world.getvariable ("attacker") + " down"
end sub
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
Date
| Reply #25 on Tue 01 May 2001 08:19 AM (UTC) |
Message
| That sounds about right.
You know the number in the array, so your test would be something like:
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #26 on Tue 01 May 2001 09:21 PM (UTC) |
Message
|
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Does this look right to you? |
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
Date
| Reply #27 on Tue 01 May 2001 09:46 PM (UTC) |
Message
| You took out my suggested test for a blank attack (in an earlier post) but yes, that looks about right.
Doesn't it work? |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #28 on Tue 08 May 2001 07:16 AM (UTC) |
Message
| Sorry, Yes it works beautifully. However I need to do something else now...
There are mob names that are more than one string of characters.
For instance, if i am fighting a playe(only one word names)
I.E. Bob, Blastoid, etc...
However, Some mobs have multi-names
King Cold, Frieza's Henchman, Android 17, Android 18, etc...
The throw command has a variable in it.
throw <target> down, or Throw <target> West
This code:
world.send "throw " + world.GetVeriable ("Attacker") + " Down"
Works perfect for characters or mobs that have a single name. I.E. Saibaman, Or any PC name.
It does not work on multi-named mobs.
My question is, Using the split command how wuld I use it to set variables using the second array
sub UnNamed (TriggerName, Triggerline, arrWildCards)
Dim UnNamed
UnNamed= split (arrWildCards (1))
Dim i
for i=lbound (UnNamed ) to ubound (UnNamed )
world.SetVariable "UnNamed" + UnNamed (i)
next
end sub
I think this how I might do it.
This will give me the result I think I want, but it will be kinda sloppy in My opinion.
reason being, it will be continuesly setting multiple variables, potentially hogging CPU speed(although it will prolly be next to nothing)
I would like to tighten it up. so that it will only set the ubound (UnNamed ) as the variable, and ignores the ibound (UnNamed )
I thought about uusing the if, command
if i= ubound (UnNamed ) then
world.setvariable "UnNamed" + UnNamed (i)
end if
next
end sub
I don't think thats right, could you please correct me if I am wrong
Thanks again
Dave |
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
Date
| Reply #29 on Tue 08 May 2001 09:58 PM (UTC) |
Message
| This seems strangely complicated to me.
First, what do you type into the MUD when you see a two-named monster?
throw Android 17 down?
throw 'Android 17' down?
throw "Android 17" down?
Knowing this will help answer the question.
Also, looking back through the messages in this section it isn't obvious how the monster name gets into the variable in the first place. How do you put it there? Through an alias?
|
- 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.
105,427 views.
This is page 2, subject is 3 pages long:
1
2 3
It is now over 60 days since the last post. This thread is closed.
Refresh page
top