Lua in Visual Basic.net

3.7k Views Asked by At

I'm trying to just get a VB.net app to be able to execute a lua script in a external file, and be able to add some functions to lua too, To do this I have this code:

Imports LuaInterface
Public Class Form1
Public luascripting As New Lua()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
luascripting.RegisterFunction("DisplayText", Me, Me.GetType().GetMethod("DisplayText"))
luascripting.DoFile("script.lua")
End Sub
End Class

But it errors on the register function, saying "Object reference not set to an instance of an object." Do you know of a example VB.net project that uses lua? Or know how to fix this?

1

There are 1 best solutions below

2
On BEST ANSWER

You are registering a function but you forgot to write it. Paste this into your form code:

Public Sub DisplayText()
    MsgBox("Works")
End Sub