【发布时间】:2013-01-16 23:17:00
【问题描述】:
我正在尝试在运行时将Lua 脚本加载到我的项目中。但是,每当我尝试这样做时,在加载文件时都会收到以下错误:
Items\food.lua:1: unexpected symbol near '・
文件本身很简单,但我看不出这是什么原因:
config = {
itemtype = 2,
name = "Food",
basevalue = 1,
inventorytexture = 0,
red = 255,
green = 255,
blue = 255,
inventorywidth = 1,
inventoryheight = 1
}
这是我在C# 中用来运行它的代码,以防与它有关:
// In main initialisation
public void ItemSetup()
{
itemTemplates.Add(new ItemTemplate("Items\\food.lua"));
}
// constructor for ItemTemplate class
Lua LuaLoader = new Lua();
public ItemTemplate(string filename)
{
LuaLoader.DoFile(filename); // here is where the error comes up
}
我已尝试更改文件本身的设置,但这些似乎都没有帮助。以下是我对此文件的设置:
Build Action: None
Copy to Output Directory: Copy of newer
Custom Tool: <blank>
Custom Tool Namespace: <blank>
File Name: food.lua
Full Path: [...]\Items\food.lua
【问题讨论】:
-
看起来它可能是一个字节顺序标记。见这里:stackoverflow.com/questions/295472/… 编辑:更多信息:stackoverflow.com/questions/291455/… 我之前在一些 XML 文件中处理过它,所以如果这是同一个问题,我不会感到惊讶。
-
@ChrisSinclair 看起来情况就是这样——我已经删除了文件并在记事本中重新创建了它,问题就解决了。我在 Visual Studio 中创建了它的第一个版本,看起来 Visual Studio 一开始就离开了它。如果您想将此作为答案,我会在那里接受。
-
很高兴我能帮上忙。我记得我第一次遇到这些时,很难弄清楚到底发生了什么。
标签: c# lua luainterface