Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Is there a way to whitelist some classes for local use?

Discussion in 'Modding API' started by MrChoke, Jun 13, 2019 at 02:55.

  1. MrChoke Trainee Engineer

    Messages:
    6
    I wanted to write my own AI and use it with the autopilot. It is not possible because a couple small simple struct-like classes are prohibited.

    I had heard there is a plugin, DLL or something I can use to bypass some of these classes being prohibited. Does anybody know where I can get this?
     
  2. Malware Master Engineer

    Messages:
    9,428
    You can make a plugin to do so, quite easily. Here's (part) of a plugin I use to (among other things) enable debugger methods in the programmable block. The principles are the same for the modding API.

    Code:
    	public class Plugin : IPlugin
    	{
    		public void Dispose()
    		{
    		}
    
    		public void Init(object gameInstance)
    		{
    			MySandboxGame.Log.WriteLine("###PLUGIN: Programmable Block DebugPlugin Enabled");
    
    			// Enable the use of the Debugger type
    			using (var batch = MyScriptCompiler.Static.Whitelist.OpenBatch())
    			{
    				batch.AllowTypes(MyWhitelistTarget.Both, typeof(Debugger));
    			}
    
    			// Add "using" statements to the programmable block Program template
    			MyScriptCompiler.Static.AddImplicitIngameNamespacesFromTypes(typeof(Debugger));
    		}
    
    		public void Update()
    		{
    		}
    	}
    
    This is a normal .NET Framework project. Reference the game assemblies. Then you can load the plugin by adding `-plugin pathToDll.dll` to your Steam shortcut.
     
  3. MrChoke Trainee Engineer

    Messages:
    6
    Thanks! It works great.