Milestones

by Wiwiweb

Keep track of your progress in a fun way by finding out how fast you created key items. Look back on your factory's history, compare with your friends, or challenge yourself. Supports any list of items and comes with presets for popular big mods. Can be added to existing games.

Utilities
a month ago
1.1 - 2.0
291K

g [Won't do (yet)] Exporting uses wrong syntax

10 months ago
(updated 10 months ago)

To reproduce: Export settings, copy paste into a lua code checker, immediate errors. Ignoring the errors and attempting to add the preset via custom mod crashes on load.

The issue seems to be exporting puts double quotes around everything, and the colons instead of equal signs? For example what should look like:
[
{type="group", name="foobar"},
{type="item", name="foo", quantity=[number], next="x[number]", quality="bar"}
]
Instead is printed like:
[
{"type":"group", "name":"foobar"},
{"type":"item", "name":"foo", "quantity":1, "next":"x[number]", "quality":"bar"}
]

Took me far longer than I'd like to admit to sort out what was incorrect with the preset I was trying to import. It likely wouldn't be a huge fix, but would save the clueless end user a lot of time fixing their code.

(clueless referring to me, probably should actually learn lua syntax at some point)

10 months ago

Thanks for the report!
The export/import function uses JSON rather than Lua. I can see the confusion. I'll think about whether it's possible to change it.

10 months ago

Oh! Well in that case, it may not be an issue at all. It would be nice for it to be standardized to reduce confusion, but if it's working as intended then no worries.

8 months ago

My 2¢.
Don't change it to lua syntax. JSON syntax has a world of tools for processing the information while lua is "spotty" at best.
It also seems better to have JSON in and JSON out (the log file) than lua in and JSON out.

8 months ago

There is a strong argument to supporting Lua output in the export function: That's the format you need to use as a mod developer if you want to add a preset to Milestones. So I could see that it might be convenient to create your preset in the UI and then use the export function to copy paste it into your mod.

And to be honest the reason the import/export function uses JSON is because the factorio modding API comes with table_to_json and json_to_table utility functions so I didn't have to do anything.

I won't change anything for now but if another mod developer ends up being confused by this I might consider adding a checkbox that lets you export to Lua format.

8 months ago

That was interesting but I wonder why they needed to read prototype data during the data stage using the JSON format instead of data.raw 😅

For my purposes of just outputting Lua code, I think I could get away with just using serpent.block.

New response