本文整理汇总了C#中LuaInterface.Lua类的典型用法代码示例。如果您正苦于以下问题:C# Lua类的具体用法?C# Lua怎么用?C# Lua使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Lua类属于LuaInterface命名空间,在下文中一共展示了Lua类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:niuniuzhu,项目名称:kopiluainterface,代码行数:26,代码来源:StressTest.cs
示例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!");
}
开发者ID:BaalDL,项目名称:CruiserConsole,代码行数:30,代码来源:DataLoader.cs
示例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;
}
开发者ID:TheScience,项目名称:SMProxy,代码行数:32,代码来源:Program_Lua.cs
示例4: LuaWinform
public LuaWinform(Lua ownerThread)
{
InitializeComponent();
OwnerThread = ownerThread;
StartPosition = FormStartPosition.CenterParent;
Closing += (o, e) => CloseThis();
}
开发者ID:SaxxonPike,项目名称:BizHawk,代码行数:7,代码来源:LuaWinform.cs
示例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();
}
}
开发者ID:nilfisk,项目名称:WildstarUT,代码行数:33,代码来源:Program.cs
示例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"));
}
开发者ID:Skippeh,项目名称:Pokemon-RPG,代码行数:7,代码来源:GuiMethods.cs
示例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);
}
开发者ID:danielrh,项目名称:ftl-overdrive,代码行数:35,代码来源:ModdingAPI.cs
示例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')");
}
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:26,代码来源:ObjectTranslator.cs
示例9: SetupScope
internal void SetupScope(Lua lua, Quest q)
{
foreach(ConstructorInfo constructor in registeredTriggers)
{
lua.RegisterFunction(constructor.DeclaringType.Name, q, constructor);
}
}
开发者ID:Ijwu,项目名称:TShock-Quest-System,代码行数:7,代码来源:TriggerRegistry.cs
示例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"];
}
开发者ID:viticm,项目名称:pap2,代码行数:29,代码来源:CodeBuilder.cs
示例11: ReleaseLua
public static void ReleaseLua(Lua lua)
{
lock (m_queue)
{
m_queue.Enqueue(lua);
Console.WriteLine("lua queue count:{0}", m_queue.Count);
}
}
开发者ID:vancourt,项目名称:BaseGunnyII,代码行数:8,代码来源:LuaMgr.cs
示例12: lau
public lau(XDevkit.IXboxConsole Newxbc)
{
xbc = Newxbc;
pLuaVM = new Lua();
pLuaFuncs = new Hashtable();
pLuaPackages = new Hashtable();
registerLuaFunctions(null, this, null);
}
开发者ID:TheMuffinGroup,项目名称:BobsPoopTools,代码行数:8,代码来源:lau.cs
示例13: MemoryLuaLibrary
public MemoryLuaLibrary(Lua lua)
: base(lua)
{
if (MemoryDomainCore != null)
{
_currentMemoryDomain = MemoryDomainCore.MainMemory;
}
}
开发者ID:henke37,项目名称:BizHawk,代码行数:8,代码来源:EmuLuaLibrary.Memory.cs
示例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;
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例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.
}
开发者ID:Evangileon,项目名称:LuaInterface,代码行数:8,代码来源:LuaJIT.cs
示例16: LuaEngine
public LuaEngine(IEnumerable<IGlobalProvider> globalProviders, IScriptParser scriptParser, IPluginInvoker pluginInvoker)
{
this.globalProviders = globalProviders;
this.scriptParser = scriptParser;
this.pluginInvoker = pluginInvoker;
luaWorker = new BackgroundWorker();
lua = new Lua();
}
开发者ID:Xtreamer,项目名称:FreePie-DiyHt,代码行数:8,代码来源:LuaEngine.cs
示例17: CallExitEvent
public void CallExitEvent(Lua thread)
{
var exitCallbacks = _luaFunctions.Where(x => x.Lua == thread && x.Event == "OnExit");
foreach (var exitCallback in exitCallbacks)
{
exitCallback.Call();
}
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:8,代码来源:EmuLuaLibrary.Events.cs
示例18: Main
static void Main(string[] args)
{
Lua lua = new Lua();
lua["x"] = 3;
lua.DoString("y=x");
Console.WriteLine("y={0}", lua["y"]);
{
lua.DoString("luanet.load_assembly('SimpleTest')");
lua.DoString("Foo = luanet.import_type('SimpleTest.Foo')");
lua.DoString("method = luanet.get_method_bysig(Foo, 'OutMethod', 'SimpleTest.Foo', 'out SimpleTest.Bar')");
Console.WriteLine(lua["method"]);
}
{
object[] retVals = lua.DoString("return 1,'hello'");
Console.WriteLine("{0},{1}", retVals[0], retVals[1]);
}
{
KopiLua.Lua.lua_pushcfunction(lua.luaState, Func);
KopiLua.Lua.lua_setglobal(lua.luaState, "func");
Console.WriteLine("registered 'func'");
double result = (double)lua.DoString("return func(1,2,3)")[0];
Console.WriteLine("{0}", result);
}
{
Bar bar = new Bar();
bar.x = 2;
lua["bar"] = bar;
Console.WriteLine("'bar' registered");
object o = lua["bar"];
Console.WriteLine("'bar' read back as {0}", o);
Console.WriteLine(o == bar ? "same" : "different");
Console.WriteLine("LuaInterface says bar.x = {0}", lua["bar.x"]);
double result = (double)lua.DoString("return bar.x")[0];
Console.WriteLine("lua says bar.x = {0}", result);
lua.DoString("bar.x = 4");
Console.WriteLine("now bar.x = {0}", bar.x);
}
{
Foo foo = new Foo();
lua.RegisterFunction("multiply", foo, foo.GetType().GetMethod("multiply"));
Console.WriteLine("registered 'multiply'");
double result = (double)lua.DoString("return multiply(3)")[0];
Console.WriteLine("{0}", result);
}
Console.WriteLine("Finished, press Enter to quit");
Console.ReadLine();
}
开发者ID:huxia,项目名称:kopiluainterface,代码行数:58,代码来源:Program.cs
示例19: LuaManager
public LuaManager()
: base(ROClient.Singleton)
{
_luaparser = new LuaInterface.Lua();
LoadAccessory();
LoadRobe();
LoadNpcIdentity();
}
开发者ID:GodLesZ,项目名称:FimbulwinterClient,代码行数:9,代码来源:LuaManager.cs
示例20: Register
public void Register(Lua lua)
{
lua.RegisterFunction("game.exit", this, this.GetType().GetMethod("Exit"));
lua.RegisterFunction("game.setState", this, this.GetType().GetMethod("SetState"));
lua.RegisterFunction("game.addState", this, this.GetType().GetMethod("AddState"));
lua.RegisterFunction("game.getXnaGame", this, this.GetType().GetMethod("GetXnaGame"));
lua.RegisterFunction("game.getGraphicsDevice", this, this.GetType().GetMethod("GetGraphicsDevice"));
lua.RegisterFunction("game.startGame", this, GetType().GetMethod("StartGame"));
}
开发者ID:Skippeh,项目名称:Pokemon-RPG,代码行数:9,代码来源:GameMethods.cs
注:本文中的LuaInterface.Lua类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论