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