So, the idea of adding macros to cdda popped in: What's happening in YOUR randomly generated apocalypse? Part 2!.
I really like this idea and started planning out how to implement a macro (engine?/ editor?/menu?.. i’ll go with menu for now) but, I have never worked with cdda’s inputs before…
First a quick summary of my plan:
- The macro-menu and a small-ish number of macro “slots” will be added to the keybinding menu.
- More macros will be activatible from the macro-menu in the same manner as the inventory (select or invlet)
- From the macro-menu you have the basic options: execute, rename, delete, etc.
- Ideally you should be able to edit the macros but that’s gonna have to wait till version 2.0 as there is a big ui/ action representation issue here.
- To create a new macro, you select “create new” give it a name hit start. From here you can use the macro-menu’s bound key to switch between the game where, your actions will get recorded or, the macro-menu where you can save/discard the macro or, select some player actions/ predefined scripts to que. (so you don’t need to craft 500 batches of ammo for your followers or, redo your “park and unload” macro because you changed death-mobiles)
Now the issues:
What would be the best thing to actually record?
actions? I know how to capture/que activities and handle multiple types in a que but cdda uses its own window/ input system so i’m not entirely sure… I think actions would be safer but I believe they use coordinates making it difficult to reuse them. input_events also run into problems if you change the key bindings.
What’s the best way to handle macro failures? I was thinking that if it detects somethings wrong, the macro should abort and the player should get a popup…
The macros should be interruptible. In order to catch errors and what not, rather than adding the macro’s action queue to the player’s, it would be much better to just add a whole bunch of calls to the macro which would then call the appropriate action. How would one go about making the macro detect a key press since it’s last call?