Visual Studio Template 1.2 [spaar`s Mod Loader] [Mod Development]

Discussion in 'Besiege: Modding' started by spaar, Sep 23, 2015.

  1. spaar

    spaar Member

    Hey,

    I made a Visual Studio extension that adds templates for Besiege mods to make getting started on a new mod a bit easier.

    Features
    • Support for spaar's Mod Loader 1.x.x
    • Post-build commands to install the mod into your Besiege installation automatically
    • Press the Start button in Visual Studio to start Besiege with your mod ready to go
    • Three templates, depending on what you need.

    Included templates
    • Complete Besiege Mod: This contains a Mod class that included all the optional fields you can specify in order to give the mod loader more information about your mod.
    • Minimal Besiege Mod: This contains a Mod class that just overrides the fields that are absolutely necessary and leaves everything else at its default. Usually this will be enough to get you going.
    • Block Mod: Template for creating block mods. It can also package up your resources nicely for releasing a block mod, read the comments in Mod.cs for details.

    Installation
    Download the VSIX file. Double-click it and an installer should open, follow it's instructions to install the extension. The extension should be compatible with Visual Studio 2013 through 2017, if there are problems on any of those, don't hesitate to ask for help.
    Next, VS needs to be able to find your Besiege installation for the template to work. You need to set the BESIEGE_LOCATION environment variable to the path to your Besiege installation, including a bacskslash at the end. (See this tutorial on how to set environment varibales if you don't know how)

    Creating a Mod
    Open up the New Project wizard in Visual Studio. On the left, you should see a new category, Besiege, beneath the Visual C# category. In it, the two templates above should be available. Select one and otherwise create a new project the way you always would.
    You should end up with a project that automatically has references to a few Assemblies that are needed and contains a Mod.cs file which contains a valid Mod class so that your mod can immediately be loaded by the mod loader.
    The last step is to fill in all the information that is currently just filled with placeholder values, like the Name, the DisplayName, the Version and so on.
    For the block template you'll need to fill in some additional values, as well as provide a model and a texture for your block. For more info, see the Mod.cd file.

    If you run into any problems, ask here and I'll help you as best as I can.

    Happy modding!
     
    Last edited: Apr 17, 2017
  2. CheezyPig

    CheezyPig New Member

    Spaar, where is the link for creating basic mods in the readme? It says (INSERT LINK HERE)
     
  3. CheezyPig

    CheezyPig New Member

    Which version of visual studio?
     
  4. spaar

    spaar Member

    Oh, sorry, I complete forgot to put that in there. The link is in my signatue here on forum, just click on "tutorial".

    Visual Studio 2013 or 2015 Community Edition and up. If you don't have a Visual Studio yet, I'd recommend 2015 Community.
     
  5. Mortecha

    Mortecha New Member

    I am having trouble running the .vsxi. I am using Visual Studio 2013 Community and the following is the result.

    Do you know a way to get this to work?



    [​IMG]


    Attached Files
     
  6. spaar

    spaar Member

    Hm, weird. Can you try the version attached to this post?

    Attached Files
    ModTemplate.vsix
     
  7. Mortecha

    Mortecha New Member

    Just tried it and it works! Thanks for the speedy reply:)
     
  8. spaar

    spaar Member

    Okay, great! By default the template apparently only worked with .NET 4.5 since that's what I used to create it, I just added 4.6 as compatible version too.
     
  9. spaar

    spaar Member

    Just released an update to the template! The templates now include references to Assembly-UnityScript-firstpass, Assembly-CSharp and Assembly-CSharp-firstpass in addition to Assembly-UnityScript since you're much more likely to need them when developing mods after the v0.25 update (especially CSharp-firstpass).
     
  10. SovietKetchup

    SovietKetchup New Member

    I've been trying to make a mod (so far just print to console, nothing too exciting yet) but I seem to be having issues with the code.

    Here is what I have
    Code:
    using System;
    using spaar.ModLoader;
    using UnityEngine;
    
    namespace tutorial {
    
      // If you need documentation about any of these values or the mod loader
      // in general, take a look at https://spaar.github.io/besiege-modloader.
    
      public class YourMod : Mod {
        public override string Name { get; } = "MyMod";
        public override string DisplayName { get; } = "MyMod";
        public override string Author { get; } = "K3TCHUP";
        public override Version Version { get; } = new Version(1, 0, 0);
    
        public override void OnLoad() {
          temp = new GameObject();
          temp.AddComponent<YourClass>();
          GameObject.DontDestroyOnLoad(temp);
        }
    
        public override void OnUnload() {
          GameObject.Destroy(temp);
        }
    
        public class YourClass : MonoBehavior {
            public void Update() {
                Debug.Log("Your test Debug.");
            }
        }
      }
    }
    
    I'm following this tutorial.

    I'm however getting errors when trying to run it.
     
  11. spaar

    spaar Member

    It's hard to help you without knowing what errors you are getting. Could you post them here?
    The only thing I see that might be causing an issue is that "YourClass" is inside the "YourMod" class. Try moving it out of there and see if it works then.
     
  12. SovietKetchup

    SovietKetchup New Member

    The error messages are at this post, comment #16.

    Thanks for the help with that, I didn't spot it (clearly), along with that and ITR's help with my err's in spelling "MonoBehaviour", that fixes the errors related to 'MonoBehaviour' and the variable 'temp'. However the first set of errors

    Code:
    Invalid token '=' in class, struct, or interface member declaration
    still remain.

    Currently following ITR's advice to update the VS2015, though I have a fairly slow connection so it may take a while.
     
  13. spaar

    spaar Member

    Yeah, that's syntax that's only available in VS2015+. You can rewrite those lines to something like 'public override string Name { get { return "MyMod"; } };' (or something close to that anyway) to make it work in VS2013.
     
  14. SovietKetchup

    SovietKetchup New Member

    Updated to VS2015 now and all is working as it should, thank you very much! Luckily I made a backup of my besiege directory just before the v0.4 update, so I can continue working through the tutorial before the modloader is updated.
     
  15. spaar

    spaar Member

    I released a new version of this that adds support for Visual Studio 2017 and also adds a new template for Block mods.
     
  16. Ok23

    Ok23 New Member

    VSIX don't install, some text in log in russian

    25.07.2017 3:08:09 - PKGDEF Information: Looking for master PkgDef file, Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\master.pkgdef

    25.07.2017 3:08:09 - PKGDEF Information: Creating PkgDefCacheNonVolatile
    25.07.2017 3:08:09 - PKGDEF Information: Double-checking master pkgdef file
    25.07.2017 3:08:09 - PKGDEF Information: PkgDefManagement initialized
    25.07.2017 3:08:09 - PKGDEF Information: RootFolder, Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\

    25.07.2017 3:08:09 - PKGDEF Information: ShellFolder, Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\

    25.07.2017 3:08:09 - PKGDEF Information: PkgDefSearchPath, Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.admin.pkgdef

    25.07.2017 3:08:09 - PKGDEF Information: ImageManifestSearchPath, Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions;C:\Users\Ireal\AppData\Local\Microsoft\VisualStudio\15.0_837b03d4\Extensions

    25.07.2017 3:08:09 - PKGDEF Information: ApplicationExtensionsFolder, Path: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions

    25.07.2017 3:08:09 - PKGDEF Information: "ZeroImpact" = dword:0, "MergeRegistry" = dword:3
    25.07.2017 3:08:09 - PKGDEF Information: Could not find ConfigurationChanged timestamp., PKGDEF: 80070002
    25.07.2017 3:08:09 - PKGDEF Information: PkgDefCache flags, PKGDEF: 7001
    25.07.2017 3:08:09 - PKGDEF Information: Could not find ConfigurationChanged timestamp., PKGDEF: 80070002
    25.07.2017 3:08:09 - PKGDEF Information: PkgDef cache is current.
    25.07.2017 3:08:09 - PKGDEF Information: PkgDefManagement startup complete
    25.07.2017 3:08:10 - Расширение с идентификатором "ModTemplate.spaar.34651cf7-c1d5-474c-8074-b2f87eed3d26" не установлено в Visual Studio Community 2017.
    25.07.2017 3:08:10 - Найден установленный продукт - Visual Studio Build Tools 2017 (2)
    25.07.2017 3:08:10 - System.IO.FileNotFoundException: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\
    в System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
    в VSIXInstaller.SupportedVSSKU.get_VersionWithBuildRevisionInfo()
    в VSIXInstaller.App.IsValidSKUForExtension(SupportedVSSKU supportedSKU, IExtension extension, List`1 validSKUs)
    в VSIXInstaller.App.ShouldAddSkuToValidSkuList(SupportedVSSKU sku, IInstallableExtension extension, List`1 validSKUs)
    в VSIXInstaller.App.GetInstallableData(String vsixPath, Boolean isRepairSupported, IEnumerable`1& skuData)
    в VSIXInstaller.App.Initialize(Boolean isRepairSupported)
    в VSIXInstaller.App.Initialize()
    в System.Threading.Tasks.Task`1.InnerInvoke()
    в System.Threading.Tasks.Task.Execute()​
     
    Last edited: Jul 25, 2017
  17. spaar

    spaar Member

    I can't read Russian but it looks as if there is some file/folder it doesn't find in your Visual Studio installation. Maybe check that it's installed correctly? If you need more help, somebody needs to give me a translation for the Russian part of it.
     
  18. Ok23

    Ok23 New Member

    Text in russian dont important
     
  19. spaar

    spaar Member

    Well, I don't know what would cause it then and I don't really see how the add-on could be responsible for it. A quick google reveals things like this, so maybe try the suggestions there or google the error message yourself. I'm not really able to provide support for general Visual Studio problems unfortunately.
     
  20. vynycry

    vynycry New Member

    hey spaar,
    I can not install in visual studio ultimate 2013
     

Share This Page