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
➜ I don't get this...
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| WRTIII
Canada (76 posts) Bio
|
| Date
| Sat 11 Jan 2003 08:52 AM (UTC) |
| Message
| What am I doing wrong?
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.
| | Top |
|
| Posted by
| Simon
Sweden (39 posts) Bio
|
| Date
| Reply #1 on Sat 11 Jan 2003 12:07 PM (UTC) |
| Message
| 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 |
- "Where do you live, Simon?"
- "I live in the sick and wounded, doc."
Session 9 | | Top |
|
| Posted by
| WRTIII
Canada (76 posts) Bio
|
| Date
| Reply #2 on Sat 11 Jan 2003 12:49 PM (UTC) |
| Message
| oops well the only lines I missed at the top were.
Sub Crackit (Timername)
if Isempty(world.getvariable ("CODE")) then
But that sub works it's just the matter of turning the timer on and off that I can't get to work. | | Top |
|
| Posted by
| Rhinoa
United Kingdom (37 posts) Bio
|
| Date
| Reply #3 on Sat 11 Jan 2003 12:49 PM (UTC) Amended on Mon 09 Jun 2003 04:46 PM (UTC) by Rhinoa
|
| Message
| You'll need to make two aliases for that. One calling Crackit_on, the other calling Crackit_off.
Alias: CRACKITON
Ignore Case
Label: CRACKITON
Script: Crackit_on
Alias: CRACKITOFF
Ignore Case
Label: CRACKITOFF
Script: Crackit_off
Or, your could make a trigger that'd call the Crackit_off script when the safe is opened. ie.
Trigger: The safe opened
Label: CRACKITOFF
Script: Crackit_off
That way, you could leave it going and watch tv or something while it's cracking the safe, instead of sitting watching for it to open.
~Rhinoa~ | | Top |
|
| Posted by
| WRTIII
Canada (76 posts) Bio
|
| Date
| Reply #4 on Sat 11 Jan 2003 01:11 PM (UTC) |
| Message
| 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 | | Top |
|
| Posted by
| Rhinoa
United Kingdom (37 posts) Bio
|
| Date
| Reply #5 on Sat 11 Jan 2003 01:19 PM (UTC) |
| Message
| 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
That's how it should be. :)
~Rhinoa~ | | Top |
|
| Posted by
| WRTIII
Canada (76 posts) Bio
|
| Date
| Reply #6 on Sat 11 Jan 2003 01:30 PM (UTC) |
| Message
| 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 | | Top |
|
| Posted by
| WRTIII
Canada (76 posts) Bio
|
| Date
| Reply #7 on Sat 11 Jan 2003 01:43 PM (UTC) |
| Message
| 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 | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #8 on Sat 11 Jan 2003 10:18 PM (UTC) Amended on Sat 11 Jan 2003 10:20 PM (UTC) by Nick Gammon
|
| Message
| 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.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Flannel
USA (1,230 posts) Bio
|
| Date
| Reply #9 on Fri 17 Jan 2003 09:32 PM (UTC) |
| Message
| 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. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | | 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.
30,669 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top