Ради вашего удобства наш сайт использует cookies! Узнать больше! Мы используем cookies

Powder's Script Tool

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 [b]Script Def[/b] [list] [*] ScriptDef: Defines a sequence of scripts to be executed in order. The output of each script can serve as input for the next script. <PST.ScriptDef> <scripts/><!-- A list of scripts, which can be things implementing the Script interface --> </PST.ScriptDef> [*] ConditionDef: Defines reusable conditional logic. <PST.ConditionDef> <entrie/><!-- A condition entry, which can be things implementing the Condition interface --> </PST.ConditionDef> [*] SingleScriptDef: Defines a single script. <PST.SingleScriptDef> <script/><!-- This is a script entry, can hold something that implements the Script interface --> </PST.SingleScriptDef> [/list] [b]Script Types[/b] [list] [*] Delegate Wrapper: Wraps C#'s three delegate types to implement required interfaces. [list] [*] PST.Action: Implementing the Script interface, performs an operation without returning a value (or returns VoidType). <[NodeName] Class="PST.Action"/> [*] PST.Func: Implementing the Script interface, performs an operation, and returns a value for subsequent script usage. <[NodeName] Class="PST.Func"/> [*] PST.Predicate: Implementing both the Script and Condition interfaces, returning a Boolean value for conditional evaluation. <[NodeName] Class="PST.Predicate"/> [/list] [*] ConditionEntry: Implementing the Condition interface, combines multiple conditions (supported logics: And, Or, Nor, Xor) <[NodeName] Class="PST.ConditionEntry" Type="[Logic]"><!--Logic can be And, Or, Nor, Xor--> <li/> <li/> </[NodeName]> [*] IfEntry: Implementing the Script interface, conditional branching execution structure <[NodeName] Class="PST.IfEntry"> <condition/> <thens> <li/> </thens> <elses> <li/> </elses> </[NodeName]> [*] Slot Class: Wraps the script definition (Def) to implement interfaces. [list] [*] PST.ScriptDef-->PST.ScriptSlot(Implementing the Script interface) <[NodeName] Class="PST.ScriptSlot">MyScriptDefName</[NodeName]> [*] PST.ConditionDef-->PST.ConditionSlot(Implementing the Condition interface) <[NodeName] Class="PST.ConditionSlot">MyConditionDefName</[NodeName]> [*] PST.SingleScriptDef-->PST.SingleScriptSlot(Implementing the Script interface) <[NodeName] Class="PST.SingleScriptSlot">MySingleScriptDefName</[NodeName]> [/list] [/list] Example [list] [*] Create a simple script chain <PST.ScriptDef> <defName>MySimpleScript</defName> <scripts> <li Class="PST.Action">MyNamespace.MyClass.MyMethod</li> <li Class="PST.Action">MyNamespace.MyClass.AnotherMethod</li> </scripts> </PST.ScriptDef> [*] Using Conditional Execution <PST.ScriptDef> <defName>MyConditionalScript</defName> <scripts> <li Class="PST.IfEntry"> <condition Class="PST.Predicate">MyNamespace.MyClass.CheckCondition</condition> <thens> <li Class="PST.Action">MyNamespace.MyClass.DoSomething</li> </thens> </li> </scripts> </PST.ScriptDef> [*] Combining Multiple Conditions <PST.ConditionDef> <defName>MyComplexCondition</defName> <entrie Class="PST.ConditionEntry" Type="And"> <li Class="PST.Predicate">MyNamespace.MyClass.CheckFirstCondition</li> <li Class="PST.Predicate">MyNamespace.MyClass.CheckSecondCondition</li> </entrie> </PST.ConditionDef> [*] Referencing Defined Conditions or Scripts in Other Scripts <PST.ScriptDef> <defName>MyScriptUsingReference</defName> <scripts> <li Class="PST.IfEntry"> <condition Class="PST.ConditionSlot">MyComplexCondition</condition> <thens> <li Class="PST.ScriptSlot">MySimpleScript</li> </thens> </li> </scripts> </PST.ScriptDef> [/list] 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). If you encounter any errors from this mod, please report them in the discussion forum. Thank you very much!