Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve disable/enable command flow #13

Open
oliviercreurer opened this issue Jan 12, 2021 · 0 comments
Open

Improve disable/enable command flow #13

oliviercreurer opened this issue Jan 12, 2021 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@oliviercreurer
Copy link
Owner

oliviercreurer commented Jan 12, 2021

At the moment, there is both a UX issue and a nasty bug in the flow to enable (and re-enable) commands from the config page:

  1. UX issue: When disabling an individual command, the entire command list is cleared and re-written. This is to prevent a full-blown crash in the case of the command sequence position landing on a no-longer-enabled command. Instead, it would be better to re-write the algorithm such that only disabled commands are replaced instead of the whole act table.
  2. Bug: ☝️ The full-blown crash mentioned above.

Ideas:

  • Assign each command (in the parent table) an ID that can be referenced + compared to when building and modifying the act table on the fly?

Solution (for now):

All commands (+ related properties) are stored in a parent table, commands:

commands = {}
commands[1] = {
   action = clk_min,
   is_enabled = true,
   label = "[",
   description = "Slowest clock speed"
   id = 1
} -- ... and so on -- there are 19 commands total

When a user loads the script, a session-specific table, user_commands, is created to store their command preferences:

function user_commands()
local config = {}
for i=1,#commands do
if commands[i].is_enabled == true then
table.insert(config, commands[i].id)
end
return config
end

When a user is on the config page, they can disable/enable any command. Doing so toggles its is_enabled value. Every time this action is taken, the user_commands() function is called to update the list of enabled commands.

Later, we can use user_commands (since it returns a custom table) to randomize only enabled commands:

function random(table)
  for i=1,5 do
    print(table[math.random(#table)])
  end
end

random(user_commands())
@oliviercreurer oliviercreurer added bug Something isn't working enhancement New feature or request labels Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant