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

Account for function calls in sleep_frames #66

Open
ElectricityMachine opened this issue Apr 18, 2024 · 0 comments
Open

Account for function calls in sleep_frames #66

ElectricityMachine opened this issue Apr 18, 2024 · 0 comments
Labels
feature request New feature or request
Milestone

Comments

@ElectricityMachine
Copy link
Owner

Potentially low IQ suggestion, just put it here to help me remember for the future.

To account for slower functions blocking script actions, a minor optimization could be implemented that counts the execution time of function calls in addition to frames when calling sleep_frames. For example:

SCR-SGPlus/script.py

Lines 123 to 133 in 928f0d9

def click_signal(sig: str) -> None:
logging.debug("called")
coord = mouse.get_position()
mouse.click("left")
sleep_frames(3)
result, image = scan_for_dialog("signal", coord[0], coord[1])
if result:
logging.debug("scan_for_dialog returned true")
sleep_frames(3)
press_and_release(sig)
press_and_release("backspace")

In this function, we click the left mouse, then scan for the dialogbox, and if found, sleep another 3 frames before changing the signal and pressing backspace. Instead, we could sleep for the execution time, in frames, of scan_for_dialog + some const.

Say that scan_for_dialog takes 0.5 frames, and we want to wait 3 frames in total (current method's intentions). We end up waiting for 3.5 frames instead of just 3, because we do not take execution time into account. If this feature is implemented, we would only need to artificially wait for 2.5 frames (3 - function time) to meet our 3 frame threshold. This would lead to more uniform timing across different systems and function calls, and could help lay the groundwork for #45. Might also depend on #56, in case this method is less reliable and needs broader testing.

@ElectricityMachine ElectricityMachine added the feature request New feature or request label Apr 18, 2024
@ElectricityMachine ElectricityMachine added this to the 0.6.0 milestone Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant