Scripting - felipemanga/FemtoIDE GitHub Wiki

Summary

The FemtoIDE can execute javascript files that are in the project folder. To do this, simply open the file you want to run and press Ctrl+Enter. This can be used for processing/generating files the IDE does not know about, such as converting TMX files into custom C++ code. It is available in all project types.

Scripting API

All of the Nodejs APIs are available, but to facilitate common operations, the following functions have been made:

  • XML(xml:String) -> XMLDocument: Parses the the incoming String and returns a standard XMLDocument.

  • read(fileName:String) -> String: Reads and returns the contents of file fileName. Throws on failure. Path is relative to the currently open project's root.

  • write(fileName:String, text:String): Writes the UTF-8 string in text into fileName, overwriting it if it exists. Throws on failure. Not for binary files.

  • log(...args): Prints its arguments in the console.

  • dir(folderName) -> String[]: Returns an array with the names of the files inside folderName. Path is relative to the project's root. Returns null on error.

  • You can also use "APP.command()"