コード例 #1
0
        public void LoadScripts()
        {
            // Load scripts from script folder
            // HACK: This needs to load files on the fly instead of loading precompiled files by the content manager.
            // http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2 maybe?

            /*var scripts = GameServices.GetService<ContentManager>().LoadContent<string>("scripts");
             * foreach (var script in scripts)
             * {
             *      try
             *      {
             *              lua.DoString(script.Value);
             *      }
             *      catch (LuaInterface.LuaException e)
             *      {
             *              Console.WriteLine("Lua error: " + e.Message);
             *      }
             *
             * }*/

            foreach (var fileName in filesToRun)
            {
                lua.DoFile(GameServices.GetService <ContentManager>().RootDirectory + "/" + fileName);
            }
        }
コード例 #2
0
 public ViewModel(System.Windows.Threading.Dispatcher d)
 {
     dispatcher   = d;
     ClickCommand = new CommonCommand(OnClick);
     lua          = new LuaInterface.Lua();
     lua.DoFile("aaa.lua");
     lua["this"] = this;
 }
コード例 #3
0
        public Main()
        {
            Lua = new LuaInterface.Lua();

            Lua.DoFile(AppDomain.CurrentDomain.BaseDirectory + "Lua\\TrigEditPlus\\constparser.lua");
            Lua.DoFile(AppDomain.CurrentDomain.BaseDirectory + "Lua\\TrigEditPlus\\condition.lua");
            Lua.DoFile(AppDomain.CurrentDomain.BaseDirectory + "Lua\\TrigEditPlus\\action.lua");
            Lua.DoFile(AppDomain.CurrentDomain.BaseDirectory + "Lua\\TrigEditPlus\\briefing.lua");
            Lua.DoFile(AppDomain.CurrentDomain.BaseDirectory + "Lua\\TrigEditPlus\\tool.lua");


            Lua.RegisterFunction("msgbox", this, this.GetType().GetMethod("MsgBox"));



            Lua.RegisterFunction("Trigger", this, this.GetType().GetMethod("Triggerinterpreter"));
            Lua.RegisterFunction("ParseString", this, this.GetType().GetMethod("ParseString"));
            Lua.RegisterFunction("ParseLocation", this, this.GetType().GetMethod("ParseLocation"));
            Lua.RegisterFunction("ParseUPRP", this, this.GetType().GetMethod("ParseUPRP"));
            Lua.RegisterFunction("ParseUnit", this, this.GetType().GetMethod("ParseUnit"));
            Lua.RegisterFunction("ParseSwitchName", this, this.GetType().GetMethod("ParseSwitchName"));
        }
コード例 #4
0
        /// <summary>
        /// Инициализировать информацию об IO-Link устройствах.
        /// </summary>
        private void InitIOLinkSizesForDevices()
        {
            IOLinkSizes = new Dictionary <string, IODevice.IOLinkSize>();
            var          lua         = new LuaInterface.Lua();
            const string devicesFile = "sys_iolink_devices.lua";
            var          fullPath    = Path.Combine(
                ProjectManager.GetInstance().SystemFilesPath, devicesFile);

            if (File.Exists(fullPath))
            {
                object[] result = lua.DoFile(fullPath);
                if (result == null)
                {
                    return;
                }

                var dataTables = result[0] as LuaInterface.LuaTable;
                foreach (var table in dataTables.Values)
                {
                    var    tableData   = table as LuaInterface.LuaTable;
                    string articleName = (string)tableData["articleName"];
                    // Читаем float т.к могут быть 0.5 размер (в словах)
                    float sizeIn  = (float)((double)tableData["sizeIn"]);
                    float sizeOut = (float)((double)tableData["sizeOut"]);

                    if (IOLinkSizes.ContainsKey(articleName) == false)
                    {
                        // Для расчета IO-Link округляем до целого, кроме 0
                        // Для настройки - оставляем как есть
                        int intSizeIn = Convert.ToInt32(
                            Math.Round(sizeIn, MidpointRounding.AwayFromZero));
                        int intSizeOut = Convert.ToInt32(
                            Math.Round(sizeOut, MidpointRounding.AwayFromZero));
                        var properties = new IODevice.IOLinkSize
                        {
                            SizeIn          = intSizeIn,
                            SizeOut         = intSizeOut,
                            SizeInFromFile  = sizeIn,
                            SizeOutFromFile = sizeOut
                        };
                        IOLinkSizes.Add(articleName, properties);
                    }
                }
            }
            else
            {
                string template = EasyEPlanner.Properties.Resources
                                  .ResourceManager.GetString("IOLinkDevicesFilePattern");
                File.WriteAllText(fullPath, template);
            }
        }
コード例 #5
0
 public Test()
 {
     //dynamic = new DynamicProgramming();
     //mikelChar = new CharacterNPC("Settings/Mikel.xml");
     //Init();
     //Go();
     lua = new LuaInterface.Lua();
     AI.Scripting.ScriptFunctions methods = new WiccanRede.AI.Scripting.ScriptFunctions(new NPC(mikelChar, new Microsoft.DirectX.Vector3(), null, null));
     RegisterNewMethod(methods);
     lua.DoFile(skript1);
     lua.GetFunction("Update").Call();
     //RunLua();
     //ai = new AICore(grid);
     string str = Console.ReadLine();
 }
コード例 #6
0
 public void LoadScript(string path)
 {
     lua.DoFile(path);
 }
コード例 #7
0
ファイル: BotPropDlg.cs プロジェクト: lythm/orb3d
        private void OKButton_Click(object sender, EventArgs e)
        {
            if (BotDesc.Running)
            {
                if (MessageBox.Show("To apply the modification, bots must be restarted.", "warning", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
            }

            DialogResult = DialogResult.OK;

            BotDesc.Name = (string)FPropTable["Name"];

            BotDesc.BotCommands.Clear();

            if (BotDesc.Name.Length == 0)
            {
                BotDesc.Name = "No Name";
            }

            BotDesc.Silenced = (bool)FPropTable["Silence Mode"];
            BotDesc.Count = (int)FPropTable["Count"];

            try
            {
                IPAddress ip_addr = (IPAddress)FPropTable["HostAddress"];
                BotDesc.Host = new IPEndPoint(ip_addr, (int)FPropTable["HostPort"]);

                LuaInterface.Lua lua = new LuaInterface.Lua();

                lua.DoFile(BotDesc.Script);

                LuaInterface.LuaTable bot_cmds = lua.GetTable("BotCommandList");

                if (bot_cmds != null)
                {
                    foreach (object cmd_name in bot_cmds.Keys)
                    {
                        BotEngine.BotCommand cmd = new BotStudio.BotEngine.BotCommand(BotDesc, (string)cmd_name);

                        BotDesc.BotCommands.Add(cmd);

                        LuaInterface.LuaTable param_table = (LuaInterface.LuaTable)bot_cmds[(string)cmd_name];
                        if (param_table == null)
                        {
                            continue;
                        }

                        foreach (object param in param_table.Values)
                        {
                            cmd.Parameters.Add(new BotEngine.BotCommand.Parameter((string)param, ""));
                        }
                    }
                }
            }
            catch(Exception ip_e)
            {
                MessageBox.Show(ip_e.Message);
                AppContext.WriteLog(ip_e.Message);
                DialogResult = DialogResult.None;
                return;
            }
        }
コード例 #8
0
        /// <summary>
        /// Инициализировать модули информацию о модулях ввода-вывода.
        /// </summary>
        private void InitIOModulesInfo()
        {
            var          lua          = new LuaInterface.Lua();
            const string fileName     = "sys_io.lua";
            const string templateName = "sysIOLuaFilePattern";
            string       pathToFile   = Path.Combine(
                ProjectManager.GetInstance().SystemFilesPath, fileName);

            if (File.Exists(pathToFile))
            {
                object[] result = lua.DoFile(pathToFile);
                if (result == null)
                {
                    return;
                }

                var dataTables = result[0] as LuaInterface.LuaTable;
                foreach (var table in dataTables.Values)
                {
                    var tableData = table as LuaInterface.LuaTable;

                    int    number                 = Convert.ToInt32((double)tableData["n"]);
                    string name                   = (string)tableData["name"];
                    string description            = (string)tableData["description"];
                    int    addressSpaceTypeNumber = Convert.ToInt32(
                        (double)tableData["addressSpaceType"]);
                    string typeName  = (string)tableData["typeName"];
                    string groupName = (string)tableData["groupName"];

                    var channelClamps      = new List <int>();
                    var channelAddressesIn = new List <int>();
                    var channelAddrOut     = new List <int>();

                    var channelClampsTable = tableData[
                        "channelClamps"] as LuaInterface.LuaTable;
                    var channelAddressesInTable = tableData[
                        "channelAddressesIn"] as LuaInterface.LuaTable;
                    var channelAddressesOutTable = tableData[
                        "channelAddressesOut"] as LuaInterface.LuaTable;
                    foreach (var num in channelClampsTable.Values)
                    {
                        channelClamps.Add(Convert.ToInt32((double)num));
                    }
                    foreach (var num in channelAddressesInTable.Values)
                    {
                        channelAddressesIn.Add(Convert.ToInt32((double)num));
                    }
                    foreach (var num in channelAddressesOutTable.Values)
                    {
                        channelAddrOut.Add(Convert.ToInt32((double)num));
                    }

                    int    DOcnt = Convert.ToInt32((double)tableData["DO_count"]);
                    int    DIcnt = Convert.ToInt32((double)tableData["DI_count"]);
                    int    AOcnt = Convert.ToInt32((double)tableData["AO_count"]);
                    int    AIcnt = Convert.ToInt32((double)tableData["AI_count"]);
                    string color = (string)tableData["Color"];

                    IOModuleInfo.AddModuleInfo(number, name, description,
                                               addressSpaceTypeNumber, typeName, groupName,
                                               channelClamps.ToArray(), channelAddressesIn.ToArray(),
                                               channelAddrOut.ToArray(), DOcnt, DIcnt, AOcnt, AIcnt,
                                               color);
                }
            }
            else
            {
                string template = EasyEPlanner.Properties.Resources
                                  .ResourceManager.GetString(templateName);
                File.WriteAllText(pathToFile, template);
                MessageBox.Show("Файл с описанием модулей ввода-вывода" +
                                " не найден. Будет создан пустой файл (без описания).",
                                "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }