Register forum user name Search FAQ

Gammon Forum

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 ➜ My Scipt

My Scipt

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by WRTIII   Canada  (76 posts)  Bio
Date Sun 12 Jan 2003 01:14 PM (UTC)

Amended on Sun 12 Jan 2003 01:17 PM (UTC) by WRTIII

Message
Sub Crackit (Timer)

If Isempty(world.getvariable ("CODE")) Then
world.setvariable "CODE", "000"
End if

Dim CODE, A, B, C, D, E, F
CODE = world.getvariable ("CODE")
D = world.getvariable ("D")
E = world.getvariable ("E")
F = world.getvariable ("F")

If CODE < 10 Then
B = 0
C = 0
End If

If CODE < 100 and CODE > 9 then
C = 0
End If

A = mid (CODE, 1, 1)
B = mid (CODE, 2, 1)
C = mid (CODE, 3, 1)

If D <> A Then
world.send "TURN 1 TO " & A
End If
If E <> B Then
world.send "TURN 2 TO " & B
End if
If F <> C Then
world.send "TURN 3 TO " & C
End If
world.send "open safe"

D = mid (CODE, 1, 1)
E = mid (CODE, 2, 1)
F = mid (CODE, 3, 1)
C = C + 1

If C = 10 then
C = 0
B = B + 1
End If

If B = 10 then
B = 0
A = A + 1
End If

CODE = A & B & C

If CODE = 1000 Then
CODE = "000"
End If

world.setvariable "CODE", CODE
world.setvariable "D", D
world.setvariable "E", E
world.setvariable "F", F

End Sub

Sub crackit_on (aliasname, trig_line, arrWildCards)
World.EnableTimer "Crackit", TRUE
End Sub

Sub Crackit_off (aliasname, trig_line, arrWildCards)
World.EnableTimer "Crackit", FALSE
End Sub


Sub Crackitman (Timername, name, safe)

If Isempty(world.getvariable ("CODE")) Then
world.setvariable "CODE", "000"
End if

Dim CODE, A, B, C, D, E, F
CODE = world.getvariable ("CODE")
D = world.getvariable ("D")
E = world.getvariable ("E")
F = world.getvariable ("F")

If CODE < 10 Then
B = 0
C = 0
End If

If CODE < 100 and CODE > 9 then
C = 0
End If

A = mid (CODE, 1, 1)
B = mid (CODE, 2, 1)
C = mid (CODE, 3, 1)

If D <> A Then
world.send "TURN 1 TO " & A
End If
If E <> B Then
world.send "TURN 2 TO " & B
End if
If F <> C Then
world.send "TURN 3 TO " & C
End If
world.send "open safe"

D = mid (CODE, 1, 1)
E = mid (CODE, 2, 1)
F = mid (CODE, 3, 1)
C = C + 1

If C = 10 then
C = 0
B = B + 1
End If

If B = 10 then
B = 0
A = A + 1
End If

CODE = A & B & C

If CODE = 1000 Then
CODE = "000"
End If

world.setvariable "CODE", CODE
world.setvariable "D", D
world.setvariable "E", E
world.setvariable "F", F

End Sub

I have a timer named crackit that calls on subrounge Crackit
I have an alias that calls on crackitman
an alias for crackit_on
and one for crackit_off


Everything works great and I have not found any bugs in it at all.

Pretty much though I now begin to wonder.. Is all the code necesarry?, can it be shorten?, could it be neater? etc.

All things I remember my teacher telling us to ask ourselfs back in school I've gone over it and that's the best I can get but I am still learning VBScript and tend to forget alot of things if I am not constantly using them So if anyone can offer abit of time, assistane and advice I would be grateful.

Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 12 Jan 2003 11:00 PM (UTC)
Message
You seem to be doing a whole lot of separate posts about this safe cracker. Can you please keep them to the same thread (ie. reply to the existing one rather than starting new ones) because that way everyone can see the previous comments. Starting new threads like this defeats the purpose of having forum subjects.


Anyway, your code looks a lot more complicated than it needs to be. Why not just have a single number, from 0 to 999?

eg.

dim code

code = code + 1


Then to pull out the 3 digits just turn it into a string then.

eg.

dim strcode

strcode = cstr (code)

'
' allow for code being less than 3 digits
'
while len (strcode) < 3
strcode = "0" & strcode
wend


a = mid (strcode, 1, 1)
b = mid (strcode, 2, 1)
c = mid (strcode, 3, 1)

Something like that.


- 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.


10,995 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.