Koulis2000 / MCScripts

1 stars 0 forks source link

Command queueing system does not use janus.load() and janus.save() #11

Open Bjonnfesk opened 11 months ago

Bjonnfesk commented 11 months ago

When Lens is queuing commands for Dossier, and Dossier is reporting the results of these commands, neither of the programs use janus.load() and janus.save() to load and save data. This results in extremely excessive code duplication. One wonders how this happened when one explicitly talked about this on Discord the night before this code was written:

you can literally just construct a lua table any way you want in your program, and use janus.save() to save it and janus.load() to load it, and you don't have to parse anything or do any manual data conversion.

Instances which should use janus.load() and janus.save():

Janus-Lens

https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-lens.lua#L195 https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-lens.lua#L226 https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-lens.lua#L240 https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-lens.lua#L247 https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-lens.lua#L261

A dubious one, because it needs to append (it should probably handle this by constructing a table from the current command queue file, appending the new command to this table, then saving the resulting table):

https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-lens.lua#L178

Janus-Dossier

https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-dossier.lua#L290 https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-dossier.lua#L333

A dubious one, because it needs to append (it should probably handle this by constructing a table from the current command queue file, appending the new command to this table, then saving the resulting table):

https://github.com/Koulis2000/MCScripts/blob/922ebb0bc358e513cec3a0154ca0b357a3f3a8a8/CCTweaked/janus-dossier.lua#L349

Koulis2000 commented 11 months ago

All opening/saving of commandQueue.tmp and commandResponses.tmp is now handled using janus.load() and janus.save(). Not closing this issue yet, awaiting your review.