Skip to content

Latest commit

History

71 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

This is a fork of LuaNXML with LuaCATS annotations, new features, and a few bugfixes.

LuaNXML

LuaNXML is a Lua port of NXML.

NXML is a pseudo-XML parser that can read and write the oddly formatted and often invalid XML files from Noita. NXML (the C#/.NET version linked before) is itself a port of the XML parser from Poro, which is used by the custom Falling Everything engine on which Noita runs.

In short, LuaNXML is an XML parser that is 100% equivalent to Noita's parser. As opposed to something like xml2lua, LuaNXML is just as non-conformant to the XML specification as Noita itself. It can also produce semantically equivalent output in the form of a string.

Installing

Run

git submodule add https://github.com/NathanSnail/luanxml lib/nxml

in your repo to add NXML.

Example

The code below enables all mods in the mod_config.xml file by setting the enabled attribute on all children to true. Boolean values are automatically converted to Noita XML style "1" or "0" values when :set is used.

---@typenxmllocalnxml=require("nxml")
---@parampathstring---@returnstringlocalfunctionread(path)
localf=io.open(path, "r")
localcontent=f:read("*a")
f:close()
returncontentend---@parampathstring---@paramcontentstringlocalfunctionwrite(path, content)
localf=io.open(path, "w")
f:write(content)
f:close()
endforcontentinnxml.edit_file("save00/mod_config.xml", read, write) doforelemincontent:each_child() doelem:set("enabled", true)
endend

API

The api of NXML is entirely documented within the code via LuaCATS so your editor should provide autocomplete and type checking for all of NXMLs features.

About

Noita-compatible non-conformant XML parser written in Lua

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages