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.
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.
================================================
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?
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.
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).
If you want to do an alias after a pause, you can use DoAfterSpecial:
http://www.gammon.com.au/scripts/doc.php?function=DoAfterSpecial
Use option 10 - parse as command. eg. to do a heal after a second you could do this:
DoAfterSpecial 1, "heal", 10