Re: NewCA.lua
Posted: October 14th, 2019, 12:35 am
Thank you for your responses Andrew.
After my previous post I did have an idea about how NewCA.lua could support editing function overrides without making everything global. The mechanism would be to have an EditFunctionCaller. When the User CA wants to edit the pattern it calls the EditFunctionCaller, passing it a reference to EditPattern (the editing function it wants to call). When EditPattern completes it returns a value(s) indicating whether the state changed (and an Undo checkpoint should be stored) and whether the pattern changed. EditFunctionCaller then updates the private state which needs to be changed. Of course, functions that modify the PastePattern would need a different caller, and some other custom CA might need to modify other parts of the local state. So you may prefer to go with the more flexible but slightly dangerous option in the new version of NewCA.lua. (Probably you've thought about this but I thought it's worthwhile having a discussion about it.)
OK, I'll work with this version for a while and see how it goes. I might try to allow PCA.lua to continue working with the current version as well (without the additional functionality) so that it's easy for other's to use it with current Golly 3.3.Andrew wrote: October 12th, 2019, 7:22 pm * The biggest change is that *all* of the variables declared at the top are now global, so your RandomFill function can simply set dirty = true after calling RememberCurrentState(), and you now have access to pastecells, pasteht, pastewd, etc so you can redefine FlipPaste and RotatePaste to do whatever you like. This is a somewhat dangerous change so I've added a note of caution at the end of the "Script functions" section.
After my previous post I did have an idea about how NewCA.lua could support editing function overrides without making everything global. The mechanism would be to have an EditFunctionCaller. When the User CA wants to edit the pattern it calls the EditFunctionCaller, passing it a reference to EditPattern (the editing function it wants to call). When EditPattern completes it returns a value(s) indicating whether the state changed (and an Undo checkpoint should be stored) and whether the pattern changed. EditFunctionCaller then updates the private state which needs to be changed. Of course, functions that modify the PastePattern would need a different caller, and some other custom CA might need to modify other parts of the local state. So you may prefer to go with the more flexible but slightly dangerous option in the new version of NewCA.lua. (Probably you've thought about this but I thought it's worthwhile having a discussion about it.)
That seems reasonable. I've changed my startup scripts to do that instead.Unfortunately I can't find any way to avoid that. The best solution would be to just have g.setoption("showfiles",1) in your startup script but don't call g.setdir. That way NewCA.lua won't change the state of your files panel when it exits.The mechanism to change and show the Files directory via the startup script is nice, but when the user CA is quit and the original Files directory is restored the open/close state of all the subfolders is lost.