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
➜ Bitwise scriptiong...
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Gore
(207 posts) Bio
|
| Date
| Thu 08 Jan 2004 02:27 AM (UTC) |
| Message
| Hello, was wondering if someone could help me with bitwise scriptiong.. I'm used to zmud, and I have a slightly complicated script to help me heal. In the mud I play, there's a variety of afflictions to deal with in combat. For instance, when I get an affliction called Vernalius, I trigger the affliction key, Your limbs grow heavy and you groan feebly. to do this -
#color 23
#if (%bitand(@kelp,32) > 0) {
heal} {
#math kelp @kelp+32
#wa 200
heal}
What this does is this:
Colors the line to blue on grey
Checks to see if 32 is a bit in the variable Kelp, if so, then it calls my alias, heal, if not then it increments my variable kelp by 32, pauses for .2 seconds, then calls my alias heal.
How would I go about doing this in MUSHClient? Thanks. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Thu 08 Jan 2004 03:26 AM (UTC) |
| Message
| Bitwise and and or are done with the words "and" and "or" in VBscript.
Testing a variable is done with GetVariable.
Thus your script might look like this (in VBscript):
if (CInt (world.GetVariable ("kelp")) and 32) > 0 then
world.Send "heal"
end if
world.SetVariable "kelp", CInt (GetVariable ("kelp")) + 32
world.DoAfter 20, "heal"
The "CInt" converts a variable to an integer, otherwise the maths will be strange. eg. if kelp was 50 then kelp + 32 would be 5032.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Gore
(207 posts) Bio
|
| Date
| Reply #2 on Thu 08 Jan 2004 03:54 AM (UTC) |
| Message
| ================================================
if (CInt (world.GetVariable ("kelp")) and 32) > 0 then world.Send "heal"
end if
world.SetVariable "kelp", CInt (GetVariable ("kelp")) + 32
world.DoAfter 20, "heal"
================================================
Nice man, thanks. But, heal is an alias that I have in zmud. I'm guessing I'd have to make it a subroutine with VBScript, but can you call another subroutine from a subroutine?
Also, does world.DoAfter 20, "heal" send heal to the mud, or does it call the alias heal?
And does world.DoAfter 20 wait 20 milliseconds? | | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #3 on Thu 08 Jan 2004 04:53 AM (UTC) |
| Message
| Yes, you can call other subs from a single one.
doafter sends to the mud. If you want to do it otherwise then you can use script commands to create a timer or the like that calls the actual sub.
Timers, DoAfter, etc. however all work by seconds, not milliseconds. This has annoyed a few people trying to do conversions, but..
Probably everything zmud scripts do can be duplicated in VBScript or though one of the built in commands for Mushclient, but not always in the exact same way. For instance #CW creates some complications, since there is no direct command to change the color of words or lines, but you can have a trigger that captures the line and colors it at the same time, or you can use Colourtell and Colournote to print things to the window in color. The result is the same, but the method is less direct.
In your case you actually use #wa 200 in zmud. There is an equivalent command in VBScript, but the script doesn't let the program continue to do other things while this happens. It would freeze everything for 200 milliseconds. DoAfter actually creates a temporary, self deleting, timer that sends the command. Because timers are part of the client, not the script, they can delay things without stopping everything else. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #4 on Thu 08 Jan 2004 05:24 AM (UTC) |
| Message
| I didn't know "heal" was an alias, however you can evaluate aliases in a script by doing:
world.Execute "heal"
That sends "heal" to the command evaluator, which will detect it is an alias, if it is.
To answer questions about what things like DoAfter do, and what the time interval is, see the online documentation:
http://www.gammon.com.au/scripts/doc.php
It can also be downloaded as a Windows help file, for offline browsing.
To look up a particular function, such as Execute, you can do this:
http://www.gammon.com.au/scripts/doc.php?function=Execute
(substitute any script function name for "Execute" in the URL). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Thu 08 Jan 2004 05:29 AM (UTC) |
| Message
| |
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.
26,985 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top