Home - Mthec/BMLBuilder GitHub Wiki
BMLBuilder is a set of helper classes for constructing BML messages for Wurm Unlimited. See ago's wiki page for a more in-depth view of BML as a language.
List of elements and their usage
Quick start:
// Start with a BMLBuilder object, use the id from the Question object.
String bml = new BMLBuilder(id)
.text("A line of text.")
.harray(b -> b.label("Enter 20 characters:").entry("bml-property-name", 20))
.checkbox("Checkbox Label", "bml-property-name")
.table(new String[] { "Table", "Column", "Titles" },
myData.getItems(),
(myObject, b) -> b.label(myObject.getName()).label(String.format("%.2f", myObject.getNumber()))
// Inline method for conditionals. Storing the BML object in a variable and using normal if also works.
.If(!meetsCondition,
b -> b.text("Not needed"),
b -> b.If(otherCondition,
b2 -> b2.text("Assigned"),
b2 -> b2.text("error() marks this text red").error())
)
.newLine()
.harray(
b -> b.button("Button Label").confirm("Are you sure? Shows a Yes/No confirm box when clicked.")
.spacer()
.button("bml-property-name", "Another Button Label")
// Build the String
.build();
// Send the BML
getResponder().getCommunicator().sendBml(300, 400, false, true, bml, 200, 200, 200, title);
For some more in depth example see my other projects: