LenchScripterMod
LenchScripterMod copied to clipboard
How to control my mod
I write a MOD for the SuspensionBlock. MOD add a slider to SuspensionBlock,Now I want control slider value use ScriptMod. What should I do?
You can link LenchScripterMod.dll
to your mod, and then create a class named SuspensionBlockHandler
that extends Lench.Scripter.Block
, like this:
namespace MyMod
{
public class SuspensionBlockHandler : Lench.Scripter.Block
{
private readonly SuspensionBlock _sb;
public SuspensionBlockHandler(BlockBehaviour bb) : base(bb)
{
_sb = bb.GetComponent<SuspensionBlock>();
}
public void DoSomething()
{
_sb.CallSomeMethodFromYourBlockScript();
}
}
}
Then on mod load, call
Lench.Scripter.MapTypeToID(myBlockId, typeof(SuspensionBlockHandler));
where myBlockId
is the integer ID of your block. This will tell the scripter mod to create block handlers of your type for blocks with given ID number.
Users will then be able to access your methods in Python.
b = Besiege.GetBlock("SUSPENSION BLOCK 1")
b.DoSomething()
Linking the scripter mod library will unfortunately cause your mod to stop working when scripter mod is not present. That's why I suggest creating a scripter and scripterless version of mod, or creating a scripter plugin that does just this.