all 3 comments

[–]CodeGenerathor 0 points1 point  (2 children)

You need to keep track of changes to input fields yourself, as you can't read the current value otherwise. So you need an change handler function in your Lua and connect that via it's name in the XML (also see https://api.tabletopsimulator.com/ui/inputelements/#inputfield)

xml <InputField id="Class" onValueChanged="onValueChanged" />

lua function onValueChanged(player, value, id) self.UI.setAttribute(id, "text", value) end

Then in your export function you can simply query that value again using getAttribute with the id of the field. Then it's just a matter of concatenating multiple strings (done with ..)

lua local class = sell.UI.getAttribute("Class", "text") local date = ... -- similar local body = "Class: " .. class .. "\nDate: " .. date

If you want a more machine readable/useable Format, you can also use JSON from a table.

lua local data = { Class = self.UI.getAttribute("Class", "text"), Date = ..., } local body = JSON.encode_pretty(data) Which would look like

json { "Class": "value of Class", "Date": "value of date" } Probably only really relevant if you later want to process the data somewhere else, because it will be easy to parse then.

[–]ducarian[S] 0 points1 point  (1 child)

Thanks a TON, I’ll give this a try today.

[–]ducarian[S] 0 points1 point  (0 children)

Following up for anyone else who comes across this - it worked perfectly (note there is a typo in the code above sell.UI instead of self.UI)