Visual Basic.net中的Lua [英] Lua in Visual Basic.net
本文介绍了Visual Basic.net中的Lua的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图获得一个VB.net应用程序,以便能够在外部文件中执行lua脚本,并且也能够向lua添加一些功能,为此,我需要以下代码:
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
但是它在注册功能上出错,提示对象引用未设置为对象的实例".您知道使用lua的示例VB.net项目吗?还是知道如何解决这个问题?
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?
推荐答案
您正在注册一个函数,但您忘记编写它.将此粘贴到您的表单代码中:
You are registering a function but you forgot to write it. Paste this into your form code:
Public Sub DisplayText()
MsgBox("Works")
End Sub
这篇关于Visual Basic.net中的Lua的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文