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