world.setvariable "CODE", "000"
end if
Dim CODE, A, B, C
CODE = world.getvariable ("CODE")
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)
world.send "TURN 1 TO " & A
world.send "TURN 2 TO " & B
world.send "TURN 3 TO " & C
world.send "open safe"
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
End Sub
Sub crackit_on
World.EnableTimer "Crackit", TRUE
End Sub
Sub Crackit_off
World.EnableTimer "Crackit", FALSE
End Sub
I have a timer label: Crackit
script: Crackit
set to every 5 seconds
I want to be able to type CRACKITON and turn it on
and type CRACKITOFF to turn it off...
I dunno I always have problems doing this crap if I constantly am working on things I do fine after awhile but it seems when I don't do any scripting for afew motnhs and come back to do something I cannot get anything to work.
well apparently you didn't paste the entire first sub, since you have an end if there without any if to start with, neither can we see any starting sub.
I'm not sure with vbscript etc but can you define (dim) variables in the middle of a function? donno try to move the dims to the top of the sub
Sub Crackit (Timername, name, safe)
if Isempty(world.getvariable ("CODE")) then
world.setvariable "CODE", "000"
end if
Dim CODE, A, B, C
CODE = world.getvariable ("CODE")
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)
world.send "TURN 1 TO " & A
world.send "TURN 2 TO " & B
world.send "TURN 3 TO " & C
world.send "open safe"
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
End Sub
Sub crackit_on
World.EnableTimer "Crackit", TRUE
End Sub
Sub Crackit_off
World.EnableTimer "Crackit", FALSE
End Sub
That is the code I am using I have the alias's as you said
one labeled crackiton calling script crackit_on and crackitoff calling on sub crackit_off
it returns to me the error,
Wrong Number of Arguments for script subrountine "crackit_on" when processing alias "crackiton"
We expected your subroutine to have 3 arguments
Forgot to mention that in my last post. *smacks self*
It's giving you that error because there are no arguments for your crackit_on and crackit_off subs.
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
Awsome that works great, You don't per chance know off hand an easy way to deal out a card hand of a regular card deck do ya, actually I would want to use multiple decks in some instances if not I can work on figureing it out myself but it seems like it might be something that is commonly used enough that somewhere the script might be around already
I want to setup my character as a dealer for the card game let it ride hehe
Yea that's my next project hehe I remember doing it back in school with Visual Basic
figure it's just a matter of making 52 objects and having it randomly choose and display the a selected number of them, while retaining which of them it has used until you select to SHUFFLE (clear the list of used)
Hmm oh well it's something for me to play with at least heeh
I think you would use an array of 52, and then randomly swap them.
eg.
dim cards (52)
cards (1) = "ace hearts"
cards (2) = "two hearts"
' and so on up to
cards (52) = "king spades"
Then to shuffle them make a loop that does something like this:
dim count, i, swap
for count = 1 to 52
i = rnd * 52 + 1 ' which one to swap with
swap = cards (count) ' get old one
cards (count) = cards (i) ' swap
cards (i) = swap ' put other one back
next
Basically you start with an unshuffled deck, and then go through each one and swap with another at random, thus shuffling them.
For the Cards, It would be easier to have your array be simple Numbers (1 to 52), Keep the size down, and then to deal, take the first number, and div by 13, take the ipart as the suit (0-3), and then the decimal, and multiply it by 13 to be the card value. This would also be easier to expand to multiple decks.
As for shuffling, you could either do the random thing, or split the deck into two groups, then splice them, simulating a real shuffle.