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.
Entire forum
➜ MUSHclient
➜ Jscript
➜ Help please! I cant script but i need one! :(
Help please! I cant script but i need one! :(
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Tue 17 Dec 2002 08:07 AM (UTC) |
Message
| Hey everyone -
Im looking for a way to easily tally backstabs on the mud i play. Mainly im looking for a way to see the total % of backstabs i hit/miss. Can anyone give me a hand in accomplishing this? I would hate to even think about firing up MM and be subject to its slowness to accomplish this. :P
thanks
NC |
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 17 Dec 2002 11:06 AM (UTC) Amended on Tue 17 Dec 2002 11:08 AM (UTC) by Nick Gammon
|
Message
| Can you give a bit of example MUD output? In any case, it sounds like you need a couple of triggers, one that matches on a successful backstab, and one on an unsuccessful one. They would call a script like this:
function OnBackStab (name, line, wildcards)
{
world.setvariable ("good_backstabs",
(int) world.getvariable ("good_backstabs") + 1);
world.setstatus ("backstabs hit = " +
world.getvariable ("good_backstabs") +
" ... backstabs missed = " +
world.getvariable ("bad_backstabs"));
}
And a similar one for the "bad" backstabs. I haven't tested it but that is the general idea.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Reply #2 on Sun 22 Dec 2002 01:10 AM (UTC) |
Message
| OK... heres some output from the MUD.
(mob) makes a strange sound as you place the Blood-Encrusted Blade of Hecatomb in his back!
(mob) manages to avoid your backstab.
thanks Nick. :) |
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sun 22 Dec 2002 01:16 AM (UTC) |
Message
| Well, the trigger to match on the good backstab would be:
* makes a strange sound as you place the * in his back!
Make that call the script routine I showed further up.
Then for the failure you would match on:
* manages to avoid your backstab.
It would call a similar script except you would add one to "bad_backstabs" rather than "good_backstabs".
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Reply #4 on Mon 23 Dec 2002 04:34 AM (UTC) |
Message
| alright nick.. i get what you are saying.. but where do i plug my rriggers in at? :/ i need to learn how to code one of these days. :/ |
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Reply #5 on Tue 31 Dec 2002 04:19 AM (UTC) |
Message
| blah, no one can help me put it all together to make the script? :/ |
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #6 on Tue 31 Dec 2002 04:56 PM (UTC) |
Message
| I'll have a thrash at it. I have to do this over 2 posts because the first was too big! lol! Ok, I'm assuming here you don't have an existing script and know nothing of how to set up triggers scripts variables and aliases, so I'm making it as basic as I can, and the script is in vbs if you have an existing one.
First of all, the easier way to make a trigger in my opinion is to hit Shift+Ctrl+8 together when you're logged on the mud and you'll get a box pop up for adding triggers. Click the 'add' button near the bottom and you'll have another box pop up. At the top of this box where it says Trigger: you can write in whatever it is that is going to set the trigger off, so in your case you'd want to write in there
* makes a strange sound as you place the * in his back!
The * there just allows for the fact that the mob name is going to vary, and maybe the weapon you're stabbing with will change in time too. In the check boxes down the left make sure the Enabled box is checked. Down the bottom of this box you'll see a field to fill in called 'Script:' , this is telling the trigger that whenever the above line appears for a successful stab, it will call a script. Type in here
GoodStab
Now click the ok button. It will probably give you an error saying there is no script called 'goodstab' but that's no worries, just click ok because you haven't written the script (or sub-routine) yet.
Now you need to do the exact same process as above, but in the trigger field write
* manages to avoid your backstab
and where it says 'Script' down the bottom, type
BadStab
again you'll probably get the same error message, no worries just click ok.
Now you need to set up variables. Scripts will set them up automatically, but I'll get you to do this manually so you know where they are. The variables in this case just serve as a recording of how many good and bad stabs you have. (note: you can go into this area and set them both back to zero at anytime you want as well) This is how ya do it; enter Shift+Ctrl+7 all together and you'll get a box pop up showing all your variables. Click the 'add' button near the bottom and you'll get another box open up. Where it has a field to enter name, write
GoodStabCounter
and in the big area below it labelled 'Contents' just enter a 0 (zero). Click the 'ok' button. That variable is now set up and ready to start counting. Do the exact same process again, but name it
BadStabCounter
kewl. click 'ok' at the bottom and the box will close. Done.
The next thing to do is write the script. The script is basically just a collection of all your subroutines written on one page. The way I do it to start off with is to just open a blank notepad window on your computer and start typing.
Open a notepad window and type (or cut and paste) the following subroutines: (this is a long winded way to do it probably, but it's a bit clearer to see what's going on I think) Note: if you already have a script, then you'll be adding this stuff on to that existing notepad page, not creating a new one.
sub GoodStab (thename, theoutput, thewildcards)
dim oldtotal
dim newtotal
oldtotal = World.GetVariable("GoodStabCounter")
newtotal = (oldtotal + 1)
World.SetVariable "GoodStabCounter", newtotal
end sub
sub BadStab (thename, theoutput, thewildcards)
dim oldtotal
dim newtotal
oldtotal = World.GetVariable("BadStabCounter")
newtotal = (oldtotal + 1)
World.SetVariable "BadStabCounter", newtotal
end sub
Now save this notepad window as 'myscript.vbs' into one of your folders, preferably the folder titled 'scripts' on your computer inside the MUSHclient folder. If you already have a script, you'll just be adding the above to it and saving.
You now need to add this script to your world so whenever you log on to the mud it will load this script as well. While still logged in to the mud (or at least with the world open), hit Shift+Ctrl+6 together and you'll have the scripts window open up. At the top where it says 'Scripting Language', make sure that is set to VBscript, and that the checkbox to the right called 'Enable script' is ticked. On the next line down is a field titled 'Script File:'. Click the browse button to the right of it and browse through to the notepad document you created titled 'myscript.vbs' (or whatever you called it if you had an existing script) and select it and click 'open', and then click 'ok' down the bottom and the script box will go away.
Right, you are now up and running and the stabcounters should now all be working. Now what you need to do is write an alias and yet another script which will display your counters and calculate the success %.
..to be continued | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #7 on Tue 31 Dec 2002 04:57 PM (UTC) Amended on Tue 31 Dec 2002 05:59 PM (UTC) by Guest1
|
Message
| ..continued..
Right, you are now up and running and the stabcounters should now all be working. Now what you need to do is write an alias and yet another script which will display your counters and calculate the success %.
Hit Shift+Ctrl+9 together and a the alias window will pop up for you. Click the 'add' button near the bottom and another box (window) will open. In the field at the top where it says 'Alias:' type in whatever you want to type to bring up your stab stats while playing on the mud. In fact, just type in there
stabstats
Make sure the 'Enabled' box down the left side is checked, and then near the bottom in the field called 'Script:' type
StabStats
click the 'ok' button and again you'll probably get an error message saying no such script, that's fine just ok through it and then click 'ok' again to close the alias window. Now you need to add another script to that same notepad window titled 'myscript.vbs' you had open before.
The script I'm writing belowe will give you your stats as a world.note - that is, nobody else will see it but you. If you want something different then you'll need to amend it. Ok, add the following script to your 'myscript.vbs' notepad window:
sub StabStats (thename, theoutput, thewildcards)
dim goodtotal
dim badtotal
dim rate
goodtotal = World.GetVariable("GoodStabCounter")
badtotal = World.GetVariable("BadStabCounter")
rate = Round((goodtotal / (goodtotal + badtotal)) * 100, 1)
World.Note "stabs: good = " & goodtotal & ", bad = " & badtotal & ", success rate = " & rate & "%"
end sub
Now save it and that will should bring up a box on mudclient asking to confirm re-processing the changes to myscript.vbs. Click ok. ALL DONE.
Now all you need to do is type 'substats' while playing, and you'll get a message come up saying something like
stabs: good = 5, bad = 5, success rate = 50.0%
hopefully.. I haven't tested this so let me know if it spits the dummy. If you wanted this to be said out loud on the mud rather than just to yourself, then in the subroutine above, the line that starts with
World.Note "stabs: good...
just replace it with
World.Send "say stabs: good = " & goodtotal & ", bad = " & badtotal & ", success rate = " & rate & "%"
That should be it :) hope it works ok. If nothing else, it'll give you a good idea how things work on MUSHclient. | Top |
|
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Reply #8 on Wed 01 Jan 2003 07:45 AM (UTC) |
Message
| Well, thanks for your help.. It works kind of in VBscript, but i have a previous script already in place to ID equipment and it is JScript.. i fiddled with the principles from your post and nicks post and couldnt get it to work still.. I keep getting an error saying it expects ) when it has ) where its expecting it. :/ For some reason also, your alias math doesnt add right... its off by a good amount. i manually put in 50 & 50 and it says that i hit 1% and not 50%. :/ im still trying to figure that one out.. If anyone can help me out w/ this script in JScript i would wub you to death. This is the reason why i hate to code. :p
Thanks Again peeps..
|
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Reply #9 on Wed 01 Jan 2003 08:14 AM (UTC) |
Message
| OK, i figured out WHY the math is off.. when you make it add 'goodtotal + badtotal' it just puts them together instead of adding them.. it says 10 + 5 = 105 instead of 15. |
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| Guest1
USA (256 posts) |
Date
| Reply #10 on Thu 02 Jan 2003 02:53 AM (UTC) |
Message
| ahh yup ok, I needed to add in the fact it's an integer..
rate = Round( ( goodtotal / ( cint (goodtotal) + cint (badtotal) ) ) * 100, 1)
that should fix that part. The '(' error I don't know, presumably there's either a '(' missing or else an extra ')' somewhere in your script..
| Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #11 on Thu 02 Jan 2003 07:57 AM (UTC) |
Message
|
Quote:
goodtotal = World.GetVariable("GoodStabCounter")
badtotal = World.GetVariable("BadStabCounter")
rate = Round((goodtotal / (goodtotal + badtotal)) * 100, 1)
Yes, this is a fairly well-known "feature". Variables are stored as strings (after all, you can put names etc. in them) and when VB gets a string and you try to "add" them it concatenates them together.
As Demonsurfer says, you need to Convert them to Integers (CInt) to make it work properly. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| NC99
USA (17 posts) Bio
|
Date
| Reply #12 on Thu 02 Jan 2003 10:02 AM (UTC) |
Message
| ok, it all works fine.. but now my JScript is useless.. no way for me to utilize both VB & JScript is there? Utilizing plugins maybe? |
Im a minster of death...Praying for war!
NC | Top |
|
Posted by
| Shadowfyr
USA (1,788 posts) Bio
|
Date
| Reply #13 on Thu 02 Jan 2003 06:37 PM (UTC) |
Message
| Well.. It shouldn't be that hard to convert to JScript, since you are not doing a lot of complex stuff, but yes, placing the triggers and VBScript into a plugin instead would be a good option too. | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #14 on Thu 02 Jan 2003 10:59 PM (UTC) Amended on Thu 02 Jan 2003 11:00 PM (UTC) by Nick Gammon
|
Message
|
Quote:
no way for me to utilize both VB & JScript is there? Utilizing plugins maybe?
Each plugin can have a script in a different language, so you can do that by using two (or more) plugins. |
- 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.
49,478 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top