Gammon Forum
Entire forum
MUSHclient
VBscript
Code Breaker
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Pages: 1
2
Posted by
| Vaejor
(120 posts) bio
|
Date
| Reply #15 on Fri 12 Jul 2002 01:41 PM (UTC) |
Message
|
Quote: Do...While loops are usually a no-no in MUSHclient scripts. They stall the client until the loop is complete. (Nothing else is processed). You must use triggers to repeat actions.
The do..while loop in question would never parse more than 11 loops if done correctly. It is only verifying that the number is within the valid range and that it doesn't contain any 0s in it. The most loops it would run through would be for something like 300 -> 311. As only 11 loops with that much calculation going on would take microseconds to execute, it is inconsequential to process for one iteration. If you noticed the quote on the top of the posting, the primary action is called via the alias and trigger previous specified in an earlier post, as you mention. | top |
|
Posted by
| Shadowfyr
USA (1,786 posts) bio
|
Date
| Reply #16 on Fri 12 Jul 2002 09:47 PM (UTC) |
Message
| Ok.. I am slightly confused. Save for adding a few things to my example to test for odd cases like:
SCrack <code> <once> (i.e. a second alias with SCrack * *)
then adding a a bit of code to take <code> and break it into the bits and set a flag to force it to exit after one try (simply don't activate the trigger), I don't see why you need a loop. If designed right the values should never become larger/smaller than allowed.
Modified version>
Alias: SCrack
Script: Crackit
Label: CrackStart
Alias: SCrack *
Script: Crackit
Label: CrackStart2
Alias: SCrack * *
Script: Crackit
Label: CrackStart3
Trigger: THE SAFE IS LOCKED
Script: Crackit
Label: Cracktrig
Sub Crackit (Name, Output, Wildcards)
int diala
int dialb
int dialc
if instr(Name, "CrackStart") then
if len(wildcards(1)) then
diala = mid(wildcards(1),1,1)
dialb = mid(wildcards(1),2,1)
dialc = mid(wildcards(1),3,1)
else
diala = 1
dialb = 1
dialc = 1
end if
world.send "turn dial 1 to " & diala
world.send "turn dial 2 to " & dialb
world.send "turn dial 3 to " & dialc
world.send "open safe"
if lcase(wildcards(2)) <> "once" then
world.enabletrigger "Cracktrig", True
end if
else
diala = Cint(world.getvariable ("diala"))
dialb = Cint(world.getvariable ("dialb"))
dialc = Cint(world.getvariable ("dialc"))
dialc = dialc + 1
if dialc > 9 then
dialc = 1
dialb = dialb + 1
if dialb > 9 then
dialb = 1
diala = diala + 1
world.send "turn dial 1 to " & diala
world.send "turn dial 2 to " & dialb
world.send "turn dial 3 to " & dialc
world.send "open safe"
else
world.send "turn dial 2 to " & dialb
world.send "turn dial 3 to " & dialc
world.send "open safe"
end if
else
world.send "turn dial 3 to " & dialc
world.send "open safe"
end if
end if
world.setvariable "diala",diala
world.setvariable "diala",dialb
world.setvariable "diala",dialc
end sub
So you can use
'SCrack' to do all from 111.
'SCrack 123' to start at 123.
or 'SCrack 123 once' to try only the one number.
Why complicate things with a loop that does nothing but test for valid tries? | top |
|
Posted by
| Nick Gammon
Australia (22,986 posts) bio
Forum Administrator |
Date
| Reply #17 on Fri 12 Jul 2002 10:09 PM (UTC) |
Message
|
Quote:
He says in the first message that the safe does not use 0's, so a line like that one will not work. Instead, must do what I show in my script above.
It "works" up to a point. <grin>
A couple of extra lines would work around that extra problem, eg.
code = cint (code) + 1
if code mod 10 = 0 then code = code + 1
' and similar for the other 2 digits
... however he then said
Quote:
Problem is that I realized the Safe does use zeros..
So, your lengthy examples are not necessary. You just need:
code = cint (code) + 1
if code > 999 then code = 111
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Magnum
Canada (580 posts) bio
|
Date
| Reply #18 on Fri 12 Jul 2002 11:39 PM (UTC) |
Message
| Heh Heh... :)
Well, Uh, Don't like to boast, but I thought my code was pretty sweet. Quite a bit of functionality while only using two aliases... :)
...of Course, it's up to him which script he would like to use. :)
If someone did want to use my script, they could simply modify the = "111" to instead = "000", and where I dictate A = 1, B = 1 and C = 1, change those 1's to 0's.
Good luck with whichover code is implemented. :) |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | 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.
61,325 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.