p5rpc.flowscriptframework.interfaces
1.0.1
dotnet add package p5rpc.flowscriptframework.interfaces --version 1.0.1
NuGet\Install-Package p5rpc.flowscriptframework.interfaces -Version 1.0.1
<PackageReference Include="p5rpc.flowscriptframework.interfaces" Version="1.0.1" />
<PackageVersion Include="p5rpc.flowscriptframework.interfaces" Version="1.0.1" />
<PackageReference Include="p5rpc.flowscriptframework.interfaces" />
paket add p5rpc.flowscriptframework.interfaces --version 1.0.1
#r "nuget: p5rpc.flowscriptframework.interfaces, 1.0.1"
#:package p5rpc.flowscriptframework.interfaces@1.0.1
#addin nuget:?package=p5rpc.flowscriptframework.interfaces&version=1.0.1
#tool nuget:?package=p5rpc.flowscriptframework.interfaces&version=1.0.1
Flowscript Framework
Flowscript Framework is a Reloaded-II mod that allows modders to easily add new flowscript functions without having to replace existing ones.
Usage
Download the p5rpc.flowscriptframework.interfaces package from nuget, Then add this code to your mods mod.cs file:
var flowFrameworkontroller = _modLoader.GetController<IFlowFramework>();
if (flowFrameworkontroller == null || !flowFrameworkontroller.TryGetTarget(out var flowFramework))
{
throw new Exception("Failed to get IFlowFramework Controller");
}
The IFlowFramework interface provides two methods Register and GetFlowApi, an enum FlowStatus, and another interface IFlowApi
Register
The Register method is what lets you add new (or replace) flowscript functions. Here is an example of how it should be used:
flowFramework.Register("CUSTOM_FUNCTION", 2, () =>
{
// Code goes here
return FlowStatus.SUCCESS;
});
The first two args are the function name and arg counts respectively, and the third is an anonymous function containing your functions code. The function will return an Id thats generated by the framework to be used in your custom Functions.json. The Register method allows for an optional fourth argument to provide your own id, but this should only be used to replace existing script functions, not for creating new ones.
Finding Your Custom Flow Functions ID
After registering your custom function, launch the game and check the log for a line that looks something like Registered Function <CUSTOM_FUNCTION> with 2 args at index 0x9F14. In this instance, 0x9F14 is your Id.
Check the BF Emulator Docs for more details on how to create a custom Functions.json.
NOTE: the Id you get depends on the name of the function. If you decide to change the name of your function, be sure to get the new Id.
IFlowApi
The IFlowApi interface gives you access to all of the necessary functions to retrieve arguments and set return values. You can gain access to the api with the following line:
var flowApi = flowFramework.GetFlowApi();
The API provides functions to retrieve int, float and string args, and set the return value as either an int or float. Here is an example of how it may be used.
flowFramework.Register("SQUARE_NUMBER", 1, () =>
{
var flowApi = flowFramework.GetFlowApi();
var num = flowApi.GetIntArg(0);
flowApi.SetReturnValue(num * num);
return FlowStatus.SUCCESS;
});
FlowStatus
The FlowStatus enum tells the game whether or not the function has completed execution. FlowStatus.SUCCESS indicates that the function has finished execution, and allows the game to continue executing the current script, while FlowStatus.FAILURE will cause the game to run the function again instead of moving on.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.