1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

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

Discussion in 'Modding API' started by MrChoke, Jun 13, 2019.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. MrChoke

    MrChoke Trainee Engineer

    Messages:
    16
    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

    Malware Master Engineer

    Messages:
    9,867
    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

    MrChoke Trainee Engineer

    Messages:
    16
    Thanks! It works great.
     
Thread Status:
This last post in this thread was made more than 31 days old.