Valhalla Legends Forums Archive | Visual Basic Programming | Scripting Module

AuthorMessageTime
raylu
I'm not sure if this goes here or in the VB dev forum, but anyway...

I'm trying to make FooLOps' scripting system compatible with SB's.

In my script support class (SSC), I have the following:
[code]Public Function banAccess(Username As String, rUser As String) As Boolean
banAccess = validAccess(Username, rUser)
End Function[/code]

In the scripting module, I have:
[code]Public ScriptSupportClass As New ScriptClass
[...]
.AddObject "ssc", ScriptSupportClass, True[/code]

If I have this in my script,
[code]Sub Event_UserEmote(Username, Flags, Message)
addchat banaccess(username, "joe")
End Sub[/code]
it errors with
[quote][01:20:39]<raylu@USEast >
[01:20:39]Error running VBScript file (test.txt:OnUserEmote) #13 Type mismatch: 'banaccess'
[01:20:39] Line: 20 Column: 0[/quote]

There are three options for fixing this error, apparently:
In the script file, I can change the argument to a string literal
[code]Sub Event_UserEmote(Username, Flags, Message)
addchat banaccess("raylu@useast", "joe")
End Sub[/code]

Or, I can remove the variable types in the SSC
[code]Public Function banAccess(Username, rUser) As Boolean
banAccess = validAccess(Username, rUser)
End Function[/code]

Finally, I can load the object without adding the members
[code].AddObject "ssc", ScriptSupportClass, False[/code]
and use
[code]Sub Event_UserEmote(Username, Flags, Message)
ssc.addchat ssc.banaccess("raylu@useast", "joe")
End Sub[/code]
while maintaining the variable types in the SSC.

My question is WTF?!?!?!?!?!

EDIT:
[code]Sub Script_UserEmote(Username, Flags, Message)
If Not VBScripting Then Exit Sub
Dim M As MSScriptControlCtl.Module
On Error Resume Next

'iterate through modules collection,excecuting each one
For Each M In frmMain.ScriptControl.Modules
If M.Name <> "Global" Then
    M.Run "Event_UserEmote", Username, Flags, Message
    If err Then
        If err.Number <> 438 Then
            With frmMain.ScriptControl.Error
                frmMain.AddChat "Error running VBScript file (" & M.Name & ":OnUserEmote) #" & .Number & " " & .Description, Orange
                frmMain.AddChat vbTab & "Line: " & .line & " Column: " & .Column, Orange
                'frmMain.AddChat ">>>Text: " & .Text, Orange
            End With
        End If
    End If
End If
Next
End Sub[/code]
I tried this in another sub where the variable types were declared
[code]Function Script_ParseCommand(ByVal Cmd As String, ByVal Rest As String, ByVal Username As String, ByVal Access As Integer, InBot As Boolean) As String[/code]
so this seems to make no difference.
March 23, 2007, 6:24 AM
BreW
Uhh.... Maybe try doing CStr() to your "Addchat banAccess()"??? Did you check to make sure addchat only takes one argument? If I'm not mistaken, the generic addchat sub should also take into account the color.
March 23, 2007, 8:20 PM
raylu
My AddChat can take only one. Like I said, it works with the other solutions and, in all of those, AddChat still has only 1 argument.

Where should I put CStr? There are 3 levels of code here...
March 23, 2007, 9:00 PM
BreW
[quote[[code]Sub Event_UserEmote(Username, Flags, Message)
addchat banaccess(username, "joe")
End Sub[/code]
it errors with
[quote][01:20:39]<raylu@USEast >
[01:20:39]Error running VBScript file (test.txt:OnUserEmote) #13 Type mismatch: 'banaccess'
[01:20:39] Line: 20 Column: 0[/quote][/quote] is what i was talking about with the CStr(). Even though that's probably really not the problem at all....
I really don't know what to tell you but..... be sure to messagebox your variables. Just for the hell of it. Maybe it's initalized to a null string, or something, who knows....
March 23, 2007, 11:24 PM
raylu
None of the variables are initialized, are they?
March 24, 2007, 6:10 AM
BreW
[quote author=raylu link=topic=16528.msg167191#msg167191 date=1174716614]
None of the variables are initialized, are they?
[/quote]
I don't think you can in vbscript.
March 24, 2007, 8:14 PM
rabbit
[quote author=brew link=topic=16528.msg167140#msg167140 date=1174692268]
Maybe it's initalized to a null string
[/quote]

[quote author=brew link=topic=16528.msg167214#msg167214 date=1174767291]
[quote author=raylu link=topic=16528.msg167191#msg167191 date=1174716614]
None of the variables are initialized, are they?
[/quote]
I don't think you can in vbscript.
[/quote]

Make up your damn mind.  Also, stop posting.
March 25, 2007, 11:38 AM
raylu
I've confirmed now that it has to do with variables. Putting quoted strings in works fine.
April 24, 2007, 7:46 PM
DDA-TriCk-E
If thats Grok's AddChat subroutine it should have a color before output.

e.g. AddChat vbGreen, banaccess(username, "joe")
June 5, 2007, 12:49 AM
BreW
[quote author=raylu link=topic=16528.msg167131#msg167131 date=1174683625]
My AddChat can take only one.
[/quote]
June 5, 2007, 1:01 AM

Search