Lua in Visual Basic.net

2019-09-08 15:00发布

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条回答
Juvenile、少年°
2楼-- · 2019-09-08 15:51

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

Public Sub DisplayText()
    MsgBox("Works")
End Sub
查看更多
登录 后发表回答