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 ➜ Suggestions ➜ Single word trigger highlighting please!!!

Single word trigger highlighting please!!!

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


Pages: 1  2 

Posted by Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #15 on Sun 23 Feb 2003 07:24 PM (UTC)

Amended on Sun 23 Feb 2003 07:26 PM (UTC) by Shadowfyr

Message
Hmm.. It is supposed to be:

p1 = location of '('
p2 = location of ')'
T1 = '('
T2 = list of skills
T3 = ') # #'

Sounds like 'p2 - p1 - 1' is somehow ending up less than 1 for some reason... This shouldn't happen, unless>

Text = "() 12 12"
p1 = 1
P2 = 2
p2 - p1 - 1 = 0
p1 + 1 = 2

That would produce an invalid value. I had incorrectly assumed that it would return "". In most cases you get:

Text = "(Some Skill) 12 12"
p1 = 1
P2 = 12
p2 - p1 - 1 = 10
p1 + 1 = 2

which will correctly return the 'Some Skill' part. Hmmm...

Ok. Quick fix for the first problem would be:
if p2 - p1 - 1 > 0 then
  T2 = mid(Temp, p1 + 1, p2 - p1 - 1) 'Get our list of skills.
else
  T2 = ""
end if

Replace the existing T2 = mid... lines with the above and it won't ever try to grab data from a blank list. Now as to why it would cause an error when the trigger actually contains data.. You did give the trigger the name 'SkillHlt'? Unless the initial trigger has that exact name it won't return the trigger, but instead returns "", because the script will be getting data on a non-existant trigger.
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #16 on Mon 24 Feb 2003 06:10 AM (UTC)

Amended on Mon 24 Feb 2003 06:28 AM (UTC) by David B

Message
Kool froobies.
Got Addskill, and Remskill working... There was a slight error in the world.addtrigger... a buncha stuff on the end that wasn't needed... I couldn't figure out what it was for(compared to the help file, Yah yah, I RTFM a lot ok? Sue me :P ), so I took it out. I'm gathering it was for timing reasons, no biggity, the timing isn't really needed.

When I lskill to get my list of skills, I get this error

Error number: -2146828275
Event: Execution of line 119 column 7
Description: Type mismatch: 'Skills'
Called by: Function/Sub: ListHlt called by alias
Reason: processing alias "lskill"

The line in question is:
world.tell Skills(count) & space(20 - len(Skills))

Not sure whats wrong with that. I don't see any obvious errors. Your using the split command to split the array and world.tell to show it on the screen.

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 B   USA  (80 posts)  Bio
Date Reply #17 on Mon 24 Feb 2003 04:36 PM (UTC)
Message
Had another idea... A branch off from this one

I'd like to try and set it up so that when I gain a skill on my list, it automatically removes it from the trigger.

I have a decent idea about how to do this but I was hoping you'd help me refine it a bit.

Alias: gain *
Label: whatever
script Removehlt

sub Removehlt (aname, line, wilds)
blah blah blah blah no idea what goes here yet
setup a split to split up the trigger,
if t2= wilds (1) then
somehow remove it from the list
else
end sub

Or something like that... It jsut occured to me that by combining some of the addskill and remskill and skillhlt subs I could probably figure it out, as soon as I get skillhlt subroutine working i'll look into it with more detail. I know what needs to be done, and I got a pretty gosh darn good idea of how its gonna look, but its all the little things.
Like setting up pre-split, using dim and what not, that I don't know, things like that whole p1, p2 thing, no idea what that does yet, you tossed out the script without me fully understanding what it does.
Not that, that bothers me, but Its a bit of a pain to figure it out on your own just by looking at it and reading help files(which I do often).

My autocombo script I partially wrote with Nick started out as a trigger that copied the wild card into the clipboard and the alias just pasted that into the send. and it evolved from there, I knew variables were a better way to go, but I didn't know how to get there from where I was.
Needless to say, one thing led to another, and pretty soon, Nick and I were working on the script you see blow this, in my sig. I gotta hand it to Nick, he has a great Program, and unlike... well unlike anything I've ever seen, he takes the time to cruise the forums and reply to people, I don't know if there are any other client programs out there that are better than This one, but even if there were.
1. I highly doubt they have the coustmer support that MUclient(I LOVE the new name) does.
2. Simple.. Simple.. Simple.. I can not stress how user friendly MUclient is, Sorry as I digress, but props must go where they belong, Simple and user friendly is the way to go, And lemme tell you I've watched mushclient evolve into a more and more user friendly gui, the only thing that I can see as making it even better than it is, is a short tutorial about the basics of setting up a world. Also perhaps an introductory walk through on how to setup a world, perhaps an interactive gui that assists newbs in setting up their first world, explaing what some of the features are... Just an Idea mind you.
3. Scripting... This is so powerful, its unbelievable, it allows a user with some patience, and a head on their shoulders, to customize their MU* experience completely. It allows you to do things with information at speeds your mind, not reflexes can even begin to compare to.

Ok... I've rambled enough, its now 11:30am, I'm still awake and tired... You can usually tell by my ramblings, but thats another story..

I hope you all have a good day, thanks for putting up with my excessivly long post.

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 Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #18 on Mon 24 Feb 2003 07:38 PM (UTC)

Amended on Mon 24 Feb 2003 07:43 PM (UTC) by Shadowfyr

Message
Gah.. It was supposed to be 'world.addtriggerex', for an extended set of options. However, those last two options are only for defining SendTo and Sequence number (where it appears in the trigger list). They really aren't needed as you noticed. ;)

As for:

world.tell Skills(count) & space(20 - len(Skills))

no obvious errors huh? How about trying to get the 'string' length of the entire array, not just the element we are displaying? Doh! ;) It should be:

world.tell Skills(count) & space(20 - len(Skills(count)))

As for the last item. I had kind of assumed that skills worked a bit like on mine, where you get the skill, but then have to train it a bit after. Or that it used something a bit like the Shadowrun rules where each level of the skill cost (current level + 1) to get the next. I take it that instead you just pay the cost for it and 'bingo' you now have it?

Then things are quite simple. Scripts for aliases don't really care what aliases (or even trigger) calls then. You can use some interesting tricks that involves checking the 'name' parameter that gets passed to them in cases where you want the script to do something different depending on the trigger or alias that called it. In one setup I have, there are about 20 triggers that match on protection and booster spells that all call the same sub and fire off announcements to party members based on which trigger called it.

What this means is that you can simply do this:

Alias: gain *
Label: GainIt
script: Remskill
Send: gain %1

The alias can send text 'and' call scripting at the same time, so you can reuse the same script for both cases. ;)

As for some explaination of how things actually work:

DIM and REDIM - The first of these is used to declare variables. Back in the sane pre-VBScript days you would use something like STATIC, COMMON or SHARED. However this was back when Basic actually knew the difference between a String and an Integer. VBScript however uses what is known as a Variant. This means that every variable is initially declared something like a = V123, where V means variant. If you then do something like a = a + 1, then VBScript looks at the contents and changes it to a = I124 or something like that. This is confusing as hell in some cases, because if you accidentally do something that changes it to S123 (string), and then do a = a + 1, get a = S1231 instead. VBScript basically 'guesses' based on the code you give it what the actually variable type is supposed to be. This can cause some odd bugs... More on REDIM later.

What all of this means is that since VB doesn't know the difference between a string or a number until you use them as such, they removed all the convenient options of doing COMMON a AS INTEGER and replaced it with DIM (this makes no sense to me, but.. it is Microsoft we are talking about. lol) The 'only' type you can declare with DIM that acts like it should are arrays, i.e. DIM a(10), but even then it doesn't have a clue if it should be integers, strings or flying pigs, until you place something into it. The only real advantage being that you can probably place anything you want into each seperate element and the script will only complain if you later try to use it some way that isn't allowed. How this is an advantage I leave to someone else to decide. ;)

In most cases you don't even need DIM, you can simply use a variable when you need it and have VBScript automatically declare it. However, plugins that Mushclient generates include a statement 'OPTION EXPLICIT', which forces the script to reject any variables you try to use that you didn't create using DIM first, so it is a good thing to remember to do, or you will spend a lot of time asking why the script you just placed in a plugin doesn't work right. ;) The joke being that 'option explicit' only checks to make sure a variable is pre-declared. It can't/won't warn you that you failed to give it a value before using it. Exactly why this is useful in a language that doesn't care if the variable has been declared, what it contains, the type you wanted it to be, etc. is something I am still trying to figure out. The only case I can see where it 'may' be helpful is with global variables and since you can't use 'common' or the like to 'explicitly' (note the correct use here) declare the variable as global this is pretty worthless imho.

Now p1 and p2 use a function called 'instr'. This finds the first instance of a string 'in' another string and returns the location it was found. If it finds nothing, then it returns 0. I use these positions to basically save everything before and after the part I am interested in changing in T1 and T3 using 'right' and 'left'. I think you can figure out what they do. ;) I also use these numbers to figure out where in the middle of the original string the actual list is and place that into T2 using 'mid'.

Which brings us to 'split'. This command takes a string, searches it for the string you request and splits the result into and array, while dumping the character(s) you had it look for. One very important thing to note here, it for some reason I don't get (Ask MS about bugs some time) it will create an array that can be resized, but acts like one that has been created with DIM otherwise. What do I mean? DIM variable(number of places) creates a non-resizable array. REDIM creates a 'dynamic' array, which means you can go back later and use REDIM it to a size that is bigger or smaller than it currenty is. I.e. REDIM a(10), then later do REDIM Preserve a(20). The 'Preserve' command is where split arrays fail, if you do a = split("a,b,c,d",",") you get:

a(0) = "a", a(1) = "b", a(2) = "c", a(3) = "d"

However, if you then tell it 'redim preserve a(10), you 'should' get:

a(0) = "a", a(1) = "b" ... a(9) = ""

Instead it ignores 'preserve' and gives a(0) = "" ...

I definitely think that this is a bug that MS just hasn't gotten fixed, but it is something to watch out for, not to mention quite irritating if, unlike with your script, you want to add something to an array that is in alphabetical order. And of course, to make life even more impossible, VBScript has no built in sort command.

Some things in Java and Perl definitely make life easier, but VB is a bit easier to understand, so it tends to be a trade of between sometimes doing things the hard way, but being able to understand someone elses code, or being able to do things the easy way and never touching someone elses code. ;) lol

Hope the last bit of rambling is useful. ;)
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #19 on Tue 25 Feb 2003 07:19 AM (UTC)

Amended on Tue 25 Feb 2003 02:49 PM (UTC) by David B

Message
Simply marvy, Thanks for the explanations...

Making this new alias:
alias: gain *
label: Gainit
Script: Remskill
send: gain %1

Works like a charm... except...
In order to get the gain list.
You need to type:
Gain list

Furthermore, you can change practices into train by typing:
gain train

Is there an easy way to check the wildcard, and if it's equal to gain train or gain list, it ignores the script?
Else it does the remskill sub?

I would imagine that just adding a simple line to the remskill sub you could put this check into it. I have an idea as to how to do it, but I'm not sure where to put it in, or would I need a whole entire new script?

Also, I was hoping maybe you could help me figure out how to do something else.

I have a trigger that helps me practice my spells by pamming it 10 times, then sleeping to regen mana, then standing and casting it 10 more times.

What I'd like to do is beable to change that spell that is spammed 10 times with an alias.

My trigger is: you wake and stand up
send: c 'impart str' ring(repeated 10 times)
sleep pillow
Then that triggers:
world.doafter 20, "stand"(might I add doafter is much better than world.addtimer)


alias: spam * *

wildcard (1)= cast 'impart (wildcard (1))'
wildcard (2)= <item>
so it'd look like:

spam strength ring
spam agility necklace
and so on and so forth.

If you do not want to spam the suggestion board with this, we could take this to email if you like.

Further more, I setup a timer for every 2 minutes, to autosave my world that is active.

It runs AutoSave script
The script is:

sub AutoSave (line, name, wilds)
world.worldsave ""
world.colour note "white", "black", "Saving...."
end sub

I get this error saying that it expects an arugument, Well after reading the help file(on that subject) on the website
and playing with it for 10 minutes, I still got the, world.save "" expects an addition argument.

What am I missing to make it work?

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 Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #20 on Tue 25 Feb 2003 05:50 PM (UTC)
Message
Add:

if wilds(1) = "list" or wilds(1) = "train" then
exit sub
end if

to the very beginning of the Remskill sub.

Hmm. For the spell casting thing.. You need to move the stuff the trigger does into a script, then make your alias call a sub to set two variables.
sub Cast10(name, output, wilds)
  dim count
  for count = 1 to 10
    world.send "c " & world.getvariable("SpellName")
  next
  world.send world.getvariable("Sleeper")
end sub

sub SetCast(name, output, wilds)
  world.setvariable "SpellName", wilds(1)
  world.setvariable "Sleeper", wilds(2)
end sub


As for the world.save issue... I thought that had been fixed. In older versions it would incorrectly fail if you didn't give the actually name at least once, but Nick was supposed to have corrected it... However you can probably use this to fix it:

world.save world.worldname
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #21 on Tue 25 Feb 2003 07:44 PM (UTC)
Message
Kool, kool, everything is working out nicely...
I'll work on that 10 cast when I'm not so tired.

About this world.save

No dice on world.save world.worldname

I'm using the latest version of MUclient 3.32

The Exact Error I am recieving is:

Wrong number of arguments for script subroutine "AutoSave" when processing timer "Worldsave"

We expected your subroutine to have 1 argument

Dunno about you but I don't want to fight with my computer, no matter how much its asking for an argument from me :)

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 Shadowfyr   USA  (1,792 posts)  Bio
Date Reply #22 on Wed 26 Feb 2003 05:00 AM (UTC)

Amended on Wed 26 Feb 2003 05:10 AM (UTC) by Shadowfyr

Message
Oh.. Then world.save "" will work. The problem is that Timers don't match on anything that would show up in 'output' or pass anything in wild cards, so the only parameter they do pass to scripting is 'name' like:

sub TimerScript (name)
...
end sub

I am guessing you tried to use the same set of parameters as for triggers and aliases? ;)
Top

Posted by David B   USA  (80 posts)  Bio
Date Reply #23 on Wed 26 Feb 2003 01:16 PM (UTC)

Amended on Wed 26 Feb 2003 02:52 PM (UTC) by David B

Message
After much wailing and gnashing of teeth I worked my way through how to setup that script for counting spells and what not. In the end the machine payed homage to its master...

Works like a charm now... I even have used that counting thingy script for something else *cheers*

As an added thought, I'd like to make the script count down each casting, or perhaps every time it goes through the count

Not entirely certain how to do that really. To make things more difficult I'd like to try and Center the numbers in the middle of the screen instead of on the left side.

Thanks a bunch...

I'm just chock full of idea's.... On this mud we have this thing called hero points, once you go 1 level after 100, you start hero levels, based on your experience per level, you get x amount of points per hero level

They do not have a prompt letter for the amount of hero points you have, I would like to add a trigger that sets up a variable that keeps track of the amount of hero points that I have, and world.note it to me. every single line. sort of like a clientside prompt.

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

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.


70,013 views.

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

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.