// Management · RimWorld Mod
Powder's Script Tool
This mod provides a method for defining script logic via XML files.
This mod provides a method for defining script logic via XML files. You can now place certain logic within your mod into XML files for easier adjustment and compatibility with other mods.
Basic Structure
Script Def
- ScriptDef: Defines a sequence of scripts to be executed in order. The output of each script can serve as input for the next script.
- ConditionDef: Defines reusable conditional logic.
- SingleScriptDef: Defines a single script.
Script Types
- Delegate Wrapper: Wraps C#'s three delegate types to implement required interfaces.
- PST.Action: Implementing the Script interface, performs an operation without returning a value (or returns VoidType).
< Class="PST.Action"/> - PST.Func: Implementing the Script interface, performs an operation, and returns a value for subsequent script usage.
< Class="PST.Func"/> - PST.Predicate: Implementing both the Script and Condition interfaces, returning a Boolean value for conditional evaluation.
< Class="PST.Predicate"/>
• ConditionEntry: Implementing the Condition interface, combines multiple conditions (supported logics: And, Or, Nor, Xor)
< Class="PST.ConditionEntry" Type="">
>
• IfEntry: Implementing the Script interface, conditional branching execution structure
< Class="PST.IfEntry">
>
• Slot Class: Wraps the script definition (Def) to implement interfaces.
- PST.ScriptDef-->PST.ScriptSlot(Implementing the Script interface)
< Class="PST.ScriptSlot">MyScriptDefName> - PST.ConditionDef-->PST.ConditionSlot(Implementing the Condition interface)
< Class="PST.ConditionSlot">MyConditionDefName> - PST.SingleScriptDef-->PST.SingleScriptSlot(Implementing the Script interface)
< Class="PST.SingleScriptSlot">MySingleScriptDefName>
Example
- Create a simple script chain
MySimpleScript
- MyNamespace.MyClass.MyMethod
- MyNamespace.MyClass.AnotherMethod
- Using Conditional Execution
MyConditionalScript
MyNamespace.MyClass.CheckCondition
- MyNamespace.MyClass.DoSomething
- Combining Multiple Conditions
MyComplexCondition
- MyNamespace.MyClass.CheckFirstCondition
- MyNamespace.MyClass.CheckSecondCondition
- Referencing Defined Conditions or Scripts in Other Scripts
MyScriptUsingReference
MyComplexCondition
- MySimpleScript
Important Notes
Although nodes are not named in the examples, we kindly request that each Archotech assign a unique name to their nodes to facilitate patching operations.
ScriptDef employs chained processing, where the return value of the preceding script is automatically passed as input to the next script.
All referenced methods must be static and possess the correct signature (typically accepting an object parameter).