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 ➜ Tips and tricks ➜ Getting the prompt problems...

Getting the prompt problems...

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


Posted by Reject0   USA  (7 posts)  Bio
Date Tue 19 Aug 2003 10:15 PM (UTC)
Message
First off I'm pretty new to scripting, but I've been trying to make a roller for a mud that uses a style like this....

15str 15int 17wis 15dex 18con 14chr Accept these stats?

I used the script Mr. Gammon posted for getting the last line in the buffer, and I can add the values together and see if they are bigger than 85 (for testing purposes) by using a timer to check it.

The first problem I had, which I've worked around in a long sort of way was that after the value was met, the timer kept checking over and over again

I solved that problem by only running the timer once and if the totaled value of the stats is less than the 85, using the exact same script Mr. Gammon posted, but in a different sub. When it calls the new sub I get this error:

Out of memory: 'world.GetLinesInBufferCount'

and this message:

Function/Sub: checkprompt called by timer
Reason: processing timer "lblcheckline"

Here is a copy of the script I'm using:

Option Explicit
Dim OpenVar, CharName, CharPass, CharRace, CharClass, HomeTown, CharEthos, CharAlign, CharGender, CharWeapon, SetChar, total, stre, intl, wis, dex, con, chari
Dim PromptNum

Sub CheckPrompt (sName)
Dim regEx, Matches, Match, sLine, iNumber, stre, intl, wis, dex, con, chari
iNumber = world.GetLinesInBufferCount
if world.GetLineInfo (iNumber, 3) then exit sub
if world.GetLineInfo (iNumber, 4) then exit sub
if world.GetLineInfo (iNumber, 5) then exit sub
sLine = world.GetLineInfo (iNumber, 1)
Set regEx = New RegExp
regEx.Pattern = "^(.*?)str (.*?)int (.*?)wis (.*?)dex (.*?)con (.*?)chr (.*?)$"

Set Matches = regEx.Execute (sLine)

if Matches.Count = 0 then exit sub
Set Match = Matches.Item (0)
Set regEx = Nothing
Set Matches = Nothing
stre = CInt (Match.SubMatches (0))
intl = CInt (Match.SubMatches (1))
wis = CInt (Match.SubMatches (2))
dex = CInt (Match.SubMatches (3))
con = CInt (Match.SubMatches (4))

Set Match = Nothing
Total = stre + intl + wis + dex + con
CheckRoll

end sub

Sub CheckRoll()
Dim AcceptRoll
World.EnableTimer "lblcheckline", FALSE
If Total >= 88 Then
AcceptRoll = MsgBox ("Accept Stats? Str: " & stre & " Int: " & intl & " Wis: " & wis & " Dex: " & dex & " Con: " & con & " ?", 4, "Accept Stats?")
ElseIf Total < 87 Then
CheckPromptTwo
World.send("n")
End If
End Sub

Sub CheckPromptTwo()
Dim regEx, Matches, Match, sLine, iNumber, stre, intl, wis, dex, con, chari
iNumber = world.GetLinesInBufferCount
if world.GetLineInfo (iNumber, 3) then exit sub
if world.GetLineInfo (iNumber, 4) then exit sub
if world.GetLineInfo (iNumber, 5) then exit sub
sLine = world.GetLineInfo (iNumber, 1)

Set regEx = New RegExp
regEx.Pattern = "^(.*?)str (.*?)int (.*?)wis (.*?)dex (.*?)con (.*?)chr (.*?)$"
Set Matches = regEx.Execute (sLine)
if Matches.Count = 0 then exit sub
Set Match = Matches.Item (0)
Set regEx = Nothing
Set Matches = Nothing
stre = CInt (Match.SubMatches (0))
intl = CInt (Match.SubMatches (1))
wis = CInt (Match.SubMatches (2))
dex = CInt (Match.SubMatches (3))
con = CInt (Match.SubMatches (4))
Set Match = Nothing
Total = stre + intl + wis + dex + con
CheckRoll
end sub


If anyone can understand what I mean by the post, or if the way I've worded is too messed up ask for clarification please and I will do the best I can

Extra note I am new to this and I'm sure there is an easier way to do what I'm trying to do, but I'm going with what I know :)

Thanks very much in advance!


Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 19 Aug 2003 11:14 PM (UTC)
Message
It looks a bit complicated. Why not just have a single timer, which, when it gets the desired value, disables itself?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Reject0   USA  (7 posts)  Bio
Date Reply #2 on Wed 20 Aug 2003 01:02 PM (UTC)
Message
That's brilliant!! I'll try it and see what happens.

Thanks very much!
Top

Posted by Reject0   USA  (7 posts)  Bio
Date Reply #3 on Wed 20 Aug 2003 01:35 PM (UTC)
Message
I've tried it and see what happens and it works beautifully! *scratches his head* wish i woulda thought of the disable the timer when yes thing...

I have one more question...


AcceptRoll = MsgBox ("Accept Stats? Str " & stre & " Int " & intl & " Wis " & wis & " Dex " & dex & " Con " & con & " ? Total " & TotalRoll & "", 4, "Accept Stats?")

I want the stats listed in the MsgBox, I get the total to show as a number, but the rest just show like this

Accept Stats? Str Int Wis....
without the number

Any thoughts on getting the number to display in the message box?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 20 Aug 2003 08:45 PM (UTC)
Message
What you have above are scoping problems. You declare the variables "stre" etc. twice - once at global scope, outside a sub, and once inside. The ones inside will take precedence. If you have more than one sub, like you had above, then you are setting one "stre" (the local one) but displaying a different "stre" - the global one (or, perhaps, another, but different, local one).

Make sure you only have one declaration, or do the whole thing in one sub.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Reject0   USA  (7 posts)  Bio
Date Reply #5 on Thu 21 Aug 2003 05:28 AM (UTC)
Message
You were absolutely correct, as soon as I removed the local variables and only declared the global ones, it worked. I've gotten everything else working perfectly (almost but I think I can figure out the rest)

I must say thank you very much for your prompt replies to my questions. I like to do alot of stuff myself but when a person gets stumped (as I easily do) it's nice to have a place to ask where your question get answered quickly.

Thank you very much

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.


16,799 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.