3

I'm trying to load a Lua script into my project at runtime. However, whenever I try to do so, I receive the following error when loading the file:

Items\food.lua:1: unexpected symbol near '・

The file itself is simple enough, but I can't see the cause of this:

config = {
    itemtype = 2,
    name = "Food",
    basevalue = 1,
    inventorytexture = 0,
    red = 255,
    green = 255,
    blue = 255,
    inventorywidth = 1,
    inventoryheight = 1
}

Here is the code that I am using to run this in C#, in case this has anything to do with it:

// 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
}

I have tried changing the settings for the file itself, however none of these appear to help. Here are the settings that I have for this file:

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
Brian
  • 5,069
  • 7
  • 37
  • 47
Lyise
  • 1,110
  • 2
  • 12
  • 20
  • 3
    Looks like it could be a byte order mark. See here: http://stackoverflow.com/questions/295472/how-do-i-remove-the-bom-character-from-my-xml-file EDIT: More info: http://stackoverflow.com/questions/291455/xml-data-at-root-level-is-invalid I've dealt with it in some XML files before, so I wouldn't be surprised if this is the same issue. – Chris Sinclair Feb 01 '13 at 15:45
  • @ChrisSinclair It looks like this was the case - I've deleted the file and recreated it in Notepad and the issue was resolved. I created the first version of it in Visual Studio and it appears that Visual Studio left this at the start. If you want to put this as an answer I'll accept it there. – Lyise Feb 01 '13 at 15:51
  • Glad I could help. I remember the first time I encountered those it was pretty difficult to figure out just what the heck was going on. – Chris Sinclair Feb 01 '13 at 16:07

1 Answers1

2

Looks like it could be a byte order mark. See: How do I remove the BOM character from my xml file and XML - Data At Root Level is Invalid

I've dealt with it in some XML files before, so I wouldn't be surprised if this is the same issue. As pointed out in some of the linked questions, there are utilities available to remove/avoid them easily as part of your workflow.

Community
  • 1
  • 1
Chris Sinclair
  • 22,858
  • 3
  • 52
  • 93
  • Thanks a lot for this - I have Notepad++ at the ready for if I create a file through Visual Studio and this happens again. – Lyise Feb 01 '13 at 16:08