From 4d88df351f9381206199750ca29fa74652596202 Mon Sep 17 00:00:00 2001 From: Wirlaburla Date: Tue, 30 Jul 2024 17:17:05 -0400 Subject: [PATCH] fscript guide --- Using-FScript.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 Using-FScript.md diff --git a/Using-FScript.md b/Using-FScript.md new file mode 100644 index 0000000..c92bc72 --- /dev/null +++ b/Using-FScript.md @@ -0,0 +1,74 @@ +FScript is Firestar's processing script that handles dynamic file changes and updates without replacing files or breaking compatibility. + +**A couple notes:** +- Commands are case-insensitive +- After defining a target/context, further operations can be wrapped into a single context block. +- You can escape new-lines and tabulators with `\n` and `\t` respectively. + +### Syntax +The basic single-line syntax. +``` +command context operation1 arguments +command context operation2 arguments +``` + +Multiple lines under the same 'context' can be combined in a context block. +``` +command context { + operation1 arguments + operation2 arguments +} +``` + +### Commands + +`FSCRIPT [version]` +Defines the version of FScript. This is for future backwards compatibility. + +`FILE [context:relative-path]` +Opens a file under the relative-path. In the case of Firestar, this is under the temporary deployment path. + + `DELETE` + Deletes the file. + + `[XSTR|STR] [append|delete|replace] [find] ` + Finds, appends to, or replaces text in a file. `offset` determines the found index to start with, and `limit` determines the maximum to find. STR is case-sensitive while XSTR is not. + + `BINEDIT [offset] [byte]` + Edits the file binary. `offset` is the integer offset to start editing at. `byte` is the hexadecimal representation of your data. + + `XML [create|delete] [context:selector]` + Creates or deletes an XML element in the file. See [XML Selector](#user-content-xml-selector) for selector help. + + `XML [modify] [context:selector] SET [value|attribute] [text1] ` + Modifies an attribute or inner text of an element. See [XML Selector](#user-content-xml-selector) for selector help. + + `XML [merge] [file]` + Merges the data from another XML into the file. + + `PATCH [file]` + Runs a unified patch on the file. + +### XML Selector +The XML selector is a simple string separated by periods. The following document will be used as an example. +```xml + + + + + + + +``` +The second `` element can be obtained with the following selectors: +``` +root.parent.child[1] +``` +``` +root.parent.child#B +``` +``` +root.parent.child$Sol +``` + +The `#` character is used to refer to an elements `id` attribute. The `$` character is used to refer to an elements `name` attribute. These characters can not be used at the same time, and FScript will fail if the elements cannot be found. \ No newline at end of file