How could I create a function that would add a delay?

I bet it would involve using in-game time but I’m not sure how to go about it. I am trying to make my current script as efficient as possible and some commands require additional delay( botStepDelayMilliseconds is too low for some).

How could I implement a function that essentially wait for a designed amount of time? (EDIT: maybe I could double/triple the botstepsdelay instead? Using delayInMilliSeconds as a multiplier)

What I have in mind is

botStepDelayMultiplier : BotDecisionContext -> Int -> Maybe DecisionPathNode
botStepDelayMultiplier context delayMultiplier
         currentTime =
         currentTimeSnapshot =
         delayedTime =
               currentTimeSnapshot + (delayMultiplier * context.eventContext.appSettings.botStepDelayMilliseconds)
    if currentTime < delayedTime then
        Just waitForProgressInGame

Would something like this be possible?

All these functions are meta programming. I dont have any of them but they would essentially do what their name says.

I would use like such to double or triple the botsteps delay in front of some commands.

botStepDelayMultiplier context 2
        |> Maybe.withDefault

EDIT: I guess with the flow the only thing I could do is multiply the botstepdelay for some commands.
How could I codify such a function?

I see two ways to customize the delays:

  1. As you mentioned, use multiply the default base delay time.
  2. Setting the delay in milliseconds.

Let’s look at both in more detail.

Multiplying the default base delay time

To complete the implementation you already started, we can copy from existing implementations.
I did a quick search and found two implementations of this approach.

This one is in a mining bot for the game EVE Online: bots/BotEngineApp.elm at 6da8babc2cff0a8e7c76b92b9c6723390347ec4e · Viir/bots · GitHub

The second example is better. It also has a detailed discussion of the design and breaks the programming down into steps: Adding a delay to undock

Setting the delay in milliseconds

When your target time is less than two steps away, use this approach for more fine-grained control of the delay. To implement this in your app, you only need to apply EveOnline.AppFrameworkSeparatingMemory.setMillisecondsToNextReadingFromGameBase on the decision value that you return from your policy function:

In other words, the type of the values you use this function on is the same as for the more often used describeBranch.

Here is an example code using it in an EVE Online bot:

    (describeBranch "Click on the module."
        (EveOnline.AppFrameworkSeparatingMemory.setMillisecondsToNextReadingFromGameBase 3333
                (inactiveModule.uiNode |> clickOnUIElement MouseButtonLeft)

This might force me to update my scripts to the latest version.

Thanks for the tips.

Updated my mining bot to the latest version. Took an hour or so. Should be faster for my other scripts.

The flow seems to be much faster. Probably because there is no default botstepdelay. Makes sense that we can customize it with setMillisecondsToNextReadingFromGameBase.

1 Like

Upgraded all of my scripts and setMillisecondsToNextReadingFromGameBase works well for what I need.