My Scipt

Posted by WRTIII on Sun 12 Jan 2003 01:14 PM — 2 posts, 12,062 views.

Canada #0
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.

Amended on Sun 12 Jan 2003 01:17 PM by WRTIII
Australia Forum Administrator #1
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.