• Welcome to Valhalla Legends Archive.
 

Scripting Module

Started by raylu, March 23, 2007, 01:24 AM

Previous topic - Next topic

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:
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.
Pie?

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.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

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...
Pie?

brew

#3
[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....
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

raylu

None of the variables are initialized, are they?
Pie?

brew

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.
<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P

rabbit

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.
Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

raylu

I've confirmed now that it has to do with variables. Putting quoted strings in works fine.
Pie?

Chriso

If thats Grok's AddChat subroutine it should have a color before output.

e.g. AddChat vbGreen, banaccess(username, "joe")

brew

<3 Zorm
Quote[01:08:05 AM] <@Zorm> haha, me get pussy? don't kid yourself quik
Scio te esse, sed quid sumne? :P