コード例 #1
0
        public static void EnableMod(Mod mod)
        {
            //Find the entry point to the mod
            Uri entry;
            if(Watertight.GetGame().GetPlatform() == Platform.Server)
                entry = new Uri("script://" + mod.GetName() + "/" + mod.Descriptor.ServerMain);
            else
                entry = new Uri("script://" + mod.GetName() + "/" + mod.Descriptor.ClientMain);
            //Run the entry point
            LuaFile entrypoint = FileSystem.LoadResource<LuaFile>(entry);
            entrypoint.DoFile(LuaHelper.LuaVM);

            //Run all of the included scripts
            foreach(string include in mod.Descriptor.IncludeFiles)
            {
                Util.Msg("Including: " + include);
                Uri uri = new Uri(include);

                LuaFile includeFile = FileSystem.LoadResource<LuaFile>(uri);

                includeFile.DoFile(LuaHelper.LuaVM);
            }

            Console.WriteLine("Loaded mod: " + mod.Descriptor.Name + " Version: " + mod.Descriptor.Version);
            mod.Init();
        }
コード例 #2
0
        public static void RegisterMod(LuaTable table)
        {
            Mod mod = new Mod();

            ModDescriptor descriptor = ReadDescriptor(table);

            mod.Descriptor = descriptor;
            Console.WriteLine("Setting Mod: " + mod.GetName());
            loadedMods[mod.GetName().ToLower()] = mod;
        }