Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: raylu on March 23, 2007, 01:24 AM

Title: Scripting Module
Post by: raylu on March 23, 2007, 01:24 AM
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:
Public Function banAccess(Username As String, rUser As String) As Boolean
banAccess = validAccess(Username, rUser)
End Function


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


If I have this in my script,
Sub Event_UserEmote(Username, Flags, Message)
addchat banaccess(username, "joe")
End Sub

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

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


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


Finally, I can load the object without adding the members
.AddObject "ssc", ScriptSupportClass, False
and use
Sub Event_UserEmote(Username, Flags, Message)
ssc.addchat ssc.banaccess("raylu@useast", "joe")
End Sub

while maintaining the variable types in the SSC.

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

EDIT:
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

I tried this in another sub where the variable types were declared
Function Script_ParseCommand(ByVal Cmd As String, ByVal Rest As String, ByVal Username As String, ByVal Access As Integer, InBot As Boolean) As String
so this seems to make no difference.
Title: Re: Scripting Module
Post by: brew on March 23, 2007, 03:20 PM
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.
Title: Re: Scripting Module
Post by: raylu on March 23, 2007, 04:00 PM
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...
Title: Re: Scripting Module
Post by: brew on March 23, 2007, 06:24 PM
[quote[Sub Event_UserEmote(Username, Flags, Message)
addchat banaccess(username, "joe")
End Sub

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] 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....
Title: Re: Scripting Module
Post by: raylu on March 24, 2007, 01:10 AM
None of the variables are initialized, are they?
Title: Re: Scripting Module
Post by: brew on March 24, 2007, 03:14 PM
Quote from: raylu on March 24, 2007, 01:10 AM
None of the variables are initialized, are they?
I don't think you can in vbscript.
Title: Re: Scripting Module
Post by: rabbit on March 25, 2007, 06:38 AM
Quote from: brew on March 23, 2007, 06:24 PM
Maybe it's initalized to a null string

Quote from: brew on March 24, 2007, 03:14 PM
Quote from: raylu on March 24, 2007, 01:10 AM
None of the variables are initialized, are they?
I don't think you can in vbscript.

Make up your damn mind.  Also, stop posting.
Title: Re: Scripting Module
Post by: raylu on April 24, 2007, 02:46 PM
I've confirmed now that it has to do with variables. Putting quoted strings in works fine.
Title: Re: Scripting Module
Post by: Chriso on June 04, 2007, 07:49 PM
If thats Grok's AddChat subroutine it should have a color before output.

e.g. AddChat vbGreen, banaccess(username, "joe")
Title: Re: Scripting Module
Post by: brew on June 04, 2007, 08:01 PM
Quote from: raylu on March 23, 2007, 04:00 PM
My AddChat can take only one.