MortenTobiasNielsen / Factorio-TAS-Generator

This is an attempt to create a helper tool for Tool Assisted Speedruns in Factorio. A guide of how to use the tool can be found here: https://www.youtube.com/watch?v=V9tuNoDqc0E&t
MIT License
13 stars 4 forks source link

Step Modifiers #258

Closed theis999 closed 1 year ago

theis999 commented 1 year ago

Step modifiers changes how a single step is interpreted

This is either in the Generator or in the TAS execution.

There are included 4 modifiers:

  1. No order
  2. Wait for
  3. Cancel
  4. Walk towards

Wait for and cancel others are fairly simple.

No order

Is only applied to a small subset of action types, it also isn't very performant. So ideally the user will apply it while developing and then change the order of their commands to match the execution.

It works by

Setting up a step block to execute, by iterating from the current step and forwards until it finds a step that isn't "no order" Then it runs through each step every tick. If a step is executed, it will then be removed from the step block When the step block is empty, it returns to normal operations.

Notes

Every executed step will print a debug message, so you can see the order they are executed in. If the execution of the step block exceeds 25 times the number of steps, it will fail. This might be low? To suppress warnings generated by steps that can't be executed, the warning function is overwritten while block is being executed.

Walk towards

Can be used to generate a walk step where the direction matters more than the destination. It means that the TAS will proceed with the next walk step once every step in between has been executed. This however does mean that the generator, loses the ability to know where the character is.

I have added the walk towards modifier on intermediate steps. As it made sense to me that for these steps the user doesn't care about the location of the character. This is however not backwards compatible, so it might not be a great idea?

MortenTobiasNielsen commented 1 year ago

The GUI isn't scaled correctly and can be a little difficult to see what modifiers are on a step. image

theis999 commented 1 year ago

I restyled it so it fits better. Added the usual double click functionality And added click handler similar to the painter to "no order" so it's possible to change multiple steps.

I don't know how to display the potentially very long modifier strings, other than this.

theis999 commented 1 year ago

I have made several changes based on the comments.

Everything but one issue should be resolved now. The last one being wait-for, where i have requested input.

theis999 commented 1 year ago

I corrected the typo and reversed the order of operators for tech was added to simplify the expression. I moved colouring related to walk to comment column.

Unfortunately I can't see the issue with the scrollbars. I was very careful with placing it pixel perfect. Maybe we have different monitor resolutions? anyway, as i can't see the issue you have and i want to use the full space. The easiest solution is for you to make the necessary adjustment.

No-order

It seems to me that the colouring of the no-order checkbox has you more confused. Which is a shame because it means that i have replaced one UI problem with another.

Anyway, it has 4 states.

  1. Disabled - The current step-type doesn't allow no-order
  2. Enabled (black) - The current step-type allows no-order
  3. Blue - You have selected multiple rows and the current step-type allows no-order
  4. Red - You have selected multiple rows and the current step-type doesn't allow no-order

In other words the colouring of the checkbox indicates whether the change will affect the step you currently designing in the top row, and has nothing to do with the selected steps in the step panel being able to be changed.

Whether the multiple steps selected can be changed is handled, when you try, using the warning box.

MortenTobiasNielsen commented 1 year ago

Yeah that is really confusing - borderline misleading. I do understand that it is pretty much impossible to convey all of the information necessary with just one checkbox and some colors, but it is almost better with no colors, in that case it at least doesn't give visual ques which can be interpreted wrong.

Maybe we can have a No Order and a No Order Row or something like that, so it is clear that one affects the row and the other the current step? I do find it a little more intuitive that it give the modifier to every step which can get it instead of giving me an error - but would that not make sense due to how the "mechanic" works?

theis999 commented 1 year ago

It sounds to me as if you see it as a button that looks like checkbox, while it is in fact a checkbox that also has a button like behavior. So when the checkbox changes color it indicates (1) that it has button-like behavior and (2) the color indicates whether it retains checkbox-like behavior, with red by no and blue being yes.

Maybe an more intuitive solution is to use a button for the button-type behavior. The button could be placed at the same location as the checkbox - toggling between visibility of the two control elements based on how many rows the user selects.

I would find it highly misleading if it just gave the modifier to any step that is able to have it. As it would create 2 step blocks even though the user selected a continues block of rows. It would be fine for something like Ctrl+click, but the current setup can't detect that.

MortenTobiasNielsen commented 1 year ago

Agreed - a button would be better. Sounds like a good idea to have it as a ctrl-click.

theis999 commented 1 year ago

I have swapped the logic to use a button instead of only relying on the checkbox. The button looks slightly weird, as i had make it slightly shorter than standard to fit in checkbox grid layout.

I added a right click handler that doesn't give warnings.