[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Bitwise scriptiong...
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Bitwise scriptiong...

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Gore   (207 posts)  [Biography] bio
Date Thu 08 Jan 2004 02:27 AM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (19,363 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Thu 08 Jan 2004 03:26 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Gore   (207 posts)  [Biography] bio
Date Reply #2 on Thu 08 Jan 2004 03:54 AM (UTC)  quote  ]
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?
[Go to top] top

Posted by Shadowfyr   USA  (1,775 posts)  [Biography] bio
Date Reply #3 on Thu 08 Jan 2004 04:53 AM (UTC)  quote  ]
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.

main {
__if (Schrodinger_Cat is Alive or version >= "XP"){
____if version = "Vista" then Performance /= Number_of_Cores;
____call Functional_Code();}
__else
____call Crash_Windows();}
[Go to top] top

Posted by Nick Gammon   Australia  (19,363 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Thu 08 Jan 2004 05:24 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (19,363 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 08 Jan 2004 05:29 AM (UTC)  quote  ]
Message
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

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


6,762 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]