2 Using FScript
Downforce Agent edited this page 2024-08-02 16:47:41 -04:00
This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This is a 1.3+ feature.
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] <replace> <offset> <limit> 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 for selector help.

XML [modify] [context:selector] SET [value|attribute] [text1] <text2> Modifies an attribute or inner text of an element. See 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.

<root>
    <parent>
        <child id="A" name="Downtown"/>
        <child id="B" name="Sol"/>
        <child id="C" name="Ubermall"/>
    </parent>
</root>

The second <child> 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.