本文整理汇总了C#中LuaInterface.Lua类的典型用法代码示例。如果您正苦于以下问题:C# Lua类的具体用法?C# Lua怎么用?C# Lua使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lua类属于LuaInterface命名空间,在下文中一共展示了Lua类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main2
static void Main2()
{
Lua L = new Lua();
// L.DoString("UnityEngine = luanet.UnityEngine");
// L.DoString("print(UnityEngine)");
// L.DoString("cubetype = UnityEngine.PrimitiveType.Cube");
// L.DoString("print(cubetype)");
// L.DoString("gotype = UnityEngine.GameObject");
// L.DoString("print(gotype)");
// L.DoString("CP = gotype.CreatePrimitive");
// L.DoString("print(CP)");
// L.DoString("cube2 = UnityEngine.GameObject.CP2()");
// L.DoString("print(cube2)");
// L.DoString("cube = CP(cubetype)");
// L.DoString("cube = luanet.UnityEngine.GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube)");
L.DoString("luanet.import_type(UnityEngine.GameObject)()");
L.DoString("luanet.UnityEngine.GameObject.CP2()");
while (true)
{
L.DoString("t = UnityEngine.Time.realtimeSinceStartup");
L.DoString("q = UnityEngine.Quaternion.AngleAxis(t*50, UnityEngine.Vector3.up)");
L.DoString("cube.transform.rotation = q");
System.Threading.Thread.Sleep(1);
}
}
示例2: loadGameData
public void loadGameData(ref Lua lua, string gameDataFilePath)
{
//string lineRead;
//char[] tokenizer = {':', '\"', '\'' };
//StreamReader SRead = new StreamReader(gameDataFilePath, System.Text.Encoding.UTF8);
//while ((lineRead = SRead.ReadLine()) != null)
//{
// readLinetoData(ref lua, lineRead, tokenizer);
//}
//SRead.Close();
try
{
XmlDocument xmldata = new XmlDocument();
xmldata.Load(gameDataFilePath);
XmlElement root = xmldata.DocumentElement;
XmlNodeList nodes = root.ChildNodes;
foreach (XmlNode node in nodes)
{
lua[node.Name] = node.InnerText;
}
}
catch(IOException e)
{
Console.WriteLine(e);
}
Console.WriteLine("Data Successfully Loaded!");
}
示例3: ConfigureLua
private static Lua ConfigureLua(PacketReader PacketReader, StreamWriter outputWriter)
{
Lua LuaInterpreter = new Lua();
LuaInterpreter.RegisterFunction("readByte", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadByte" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readShort", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadShort" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readInt", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadInt" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readLong", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadLong" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readString", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadString" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readSlot", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadSlot" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readMob", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadMobMetadata" && m.GetParameters().Length == 0
).First());
LuaInterpreter.RegisterFunction("readBytes", PacketReader, typeof(PacketReader).GetMethod("ReadBytes"));
LuaInterpreter.RegisterFunction("readBoolean", PacketReader, typeof(PacketReader).GetMethods().Where(
m => m.Name == "ReadBoolean" && m.GetParameters().Length == 0
).First());
return LuaInterpreter;
}
示例4: LuaWinform
public LuaWinform(Lua ownerThread)
{
InitializeComponent();
OwnerThread = ownerThread;
StartPosition = FormStartPosition.CenterParent;
Closing += (o, e) => CloseThis();
}
示例5: Main
static void Main(string[] args)
{
using (var lua = new Lua())
{
lua.DoFile("Apollo.lua");
var luaUnit = @"C:/git/luaunit";
var addonDir = "TrackMaster";
var addonPath = Path.Combine(Environment.GetEnvironmentVariable("appdata"), @"NCSOFT\Wildstar\Addons\" + addonDir + @"\");
lua.DoString(string.Format("package.path = package.path .. ';{0}/?.lua;{1}/?.lua'", luaUnit, addonPath.Replace('\\', '/')));
var toc = XDocument.Load(Path.Combine(addonPath, "toc.xml"));
foreach (var script in toc.Element("Addon").Elements("Script"))
{
lua.DoFile(Path.Combine(addonPath, script.Attribute("Name").Value));
}
foreach (var testFiles in Directory.GetFiles(Path.Combine(addonPath, "Tests")))
{
Console.WriteLine("Loading File: " + testFiles);
lua.DoFile(testFiles);
}
try
{
lua.DoString("require('luaunit'):run()");
}
catch (LuaException ex)
{
Console.WriteLine("Execution Error: " + ex.ToString());
}
//Console.ReadLine();
}
}
示例6: Register
public void Register(Lua lua)
{
lua.RegisterFunction("game.getWidth", this, this.GetType().GetMethod("GetWindowWidth"));
lua.RegisterFunction("game.getHeight", this, this.GetType().GetMethod("GetWindowHeight"));
lua.RegisterFunction("game.getCenter", this, this.GetType().GetMethod("GetWindowCenter"));
lua.RegisterFunction("gui.registerMenu", this, this.GetType().GetMethod("RegisterMenu"));
}
示例7: OnActivate
public void OnActivate()
{
// Create the lua state
luastate = new Lua();
// Setup hooks
dctHooks = new Dictionary<string, List<LuaFunction>>();
// Bind functions
BindFunction("print", "print");
luastate.NewTable("hook");
BindFunction("hook.Add", "hook_Add");
luastate.NewTable("library");
BindFunction("library.AddWeapon", "library_AddWeapon");
BindFunction("library.AddSystem", "library_AddSystem");
BindFunction("library.AddRace", "library_AddRace");
BindFunction("library.AddShipGenerator", "library_AddShipGenerator");
BindFunction("library.AddSectorMapGenerator", "library_AddSectorMapGenerator");
BindFunction("library.GetWeapon", "library_GetWeapon");
BindFunction("library.GetSystem", "library_GetSystem");
BindFunction("library.GetRace", "library_GetRace");
BindFunction("library.GetShip", "library_GetShipGenerator");
BindFunction("library.GetSectorMapGenerator", "library_GetSectorMapGenerator");
BindFunction("library.CreateAnimation", "library_CreateAnimation");
luastate.NewTable("ships");
BindFunction("ships.NewDoor", "ships_NewDoor"); // Is there any way to call the constructor directly from lua code?
// Load lua files
if (!Directory.Exists("lua")) Directory.CreateDirectory("lua");
foreach (string name in Directory.GetFiles("lua"))
luastate.DoFile("lua/" + name);
}
示例8: ObjectTranslator
public ObjectTranslator(Lua interpreter,IntPtr luaState)
{
this.interpreter=interpreter;
typeChecker=new CheckType(this);
metaFunctions=new MetaFunctions(this);
objects=new ArrayList();
assemblies=new ArrayList();
importTypeFunction=new LuaCSFunction(this.importType);
importType__indexFunction=new LuaCSFunction(this.importType__index);
loadAssemblyFunction=new LuaCSFunction(this.loadAssembly);
loadAssemblyFromFunction=new LuaCSFunction(this.loadAssemblyFrom);
registerTableFunction=new LuaCSFunction(this.registerTable);
unregisterTableFunction=new LuaCSFunction(this.unregisterTable);
getMethodSigFunction=new LuaCSFunction(this.getMethodSignature);
getConstructorSigFunction=new LuaCSFunction(this.getConstructorSignature);
createLuaObjectList(luaState);
createIndexingMetaFunction(luaState);
createBaseClassMetatable(luaState);
createClassMetatable(luaState);
createFunctionMetatable(luaState);
setGlobalFunctions(luaState);
LuaDLL.lua_dostring(luaState, "load_assembly('mscorlib')");
}
示例9: SetupScope
internal void SetupScope(Lua lua, Quest q)
{
foreach(ConstructorInfo constructor in registeredTriggers)
{
lua.RegisterFunction(constructor.DeclaringType.Name, q, constructor);
}
}
示例10: Init
public void Init(string strAPIInfoFile)
{
m_strCode = "";
m_strAPIInfoFile = strAPIInfoFile;
m_lua = new Lua();
m_lua.DoFile(m_strAPIInfoFile);
m_luatable = m_lua.GetTable("APIInfo");
m_nClassCount = m_luatable.Keys.Count;
m_strClass = new string[m_nClassCount];
m_strClassInCode = new string[m_nClassCount];
m_strIniFileName = Application.StartupPath + "\\Plugins\\LuaCheck\\API.temp.lua";
m_lua1 = new Lua();
m_lua1.DoFile(m_strIniFileName);
int n = 0;
foreach (string str in m_luatable.Keys)
{
m_strClass[n] = (string)(((LuaTable)m_luatable[str])["Name"]);
n++;
}
//object ob;
//foreach (ob in m_luatable)
//{
// strClass[] = ((LuaTable)ob)["Name"];
//}
//object ob = m_luatable["1"];
//object ob1 = ((LuaTable)ob)["Name"];
}
示例11: ReleaseLua
public static void ReleaseLua(Lua lua)
{
lock (m_queue)
{
m_queue.Enqueue(lua);
Console.WriteLine("lua queue count:{0}", m_queue.Count);
}
}
示例12: lau
public lau(XDevkit.IXboxConsole Newxbc)
{
xbc = Newxbc;
pLuaVM = new Lua();
pLuaFuncs = new Hashtable();
pLuaPackages = new Hashtable();
registerLuaFunctions(null, this, null);
}
示例13: MemoryLuaLibrary
public MemoryLuaLibrary(Lua lua)
: base(lua)
{
if (MemoryDomainCore != null)
{
_currentMemoryDomain = MemoryDomainCore.MainMemory;
}
}
示例14: CreateSandbox
public static LuaSandbox CreateSandbox(Lua thread, string initialDirectory)
{
var sandbox = new LuaSandbox();
SandboxForThread.Add(thread, sandbox);
sandbox.SetSandboxCurrentDirectory(initialDirectory);
sandbox.SetLogger(DefaultLogger);
return sandbox;
}
示例15: LuaJIT
public LuaJIT()
{
//this.instance = new lua_StatePtr();
//this.ud = new size_t_p(0);
//this.instance = Luajit.lua_newstate(normal_lua_Alloc, ud);
this.lua_instance = new Lua();
//lua_instance.
}