Ship current speed

It seems like the outdated speedGaugeElement was commented out of parseUserInterface.

I made this function to evaluate my ship speed before deploying sentry drones.
If it evaluates at 99999 it means something is wrong and you shouldn’t use it to make your decision.

shipCurrentSpeed : BotDecisionContext -> Int
shipCurrentSpeed context =
    case context.readingFromGameClient.shipUI of
        Nothing ->
            99999

        Just shipUISpeed ->
            case
                shipUISpeed.uiNode
                    |> EveOnline.ParseUserInterface.listDescendantsWithDisplayRegion
                    |> List.filter (.uiNode >> EveOnline.ParseUserInterface.getNameFromDictEntries >> Maybe.map (String.toLower >> String.contains "speedlabel") >> Maybe.withDefault False)
                    |> List.head
            of
                Nothing ->
                    99999

                Just speedGauge ->
                    case
                        speedGauge.uiNode
                            |> getAllContainedDisplayTexts
                            |> List.head
                    of
                        Nothing ->
                            99999

                        Just speedGaugeText ->
                            let
                                speed =
                                    Regex.find speedInRegex speedGaugeText

                                speedInRegex =
                                    Maybe.withDefault Regex.never <|
                                        Regex.fromString "^[^.]+"

                                speedFinalNumber =
                                    String.join "" (speed |> List.map .match)
                            in
                            speedFinalNumber |> String.toInt |> Maybe.withDefault 99999
1 Like

Another use with ship current speed that I found is if you store your ship speed in botmemory and the bot realize it is not going faster when it should be it is able to detect when it is stuck somewhere. This lets the bot issue a different command(keep at range for exemple) to unstuck itself from where it is (for me it sometimes happen around asteroids or inside missions compound.

1 Like

Thank you for sharing! I am surprised to see the approach to use the value 99999 to signal that particular case.

Also, very nice to have that guide on how to get your ship unstuck. I think we did not have a post spelling this out explicitly anywhere. So this approach will probably save some ships out there.

Maybe Int type returning Nothing would be prettier but I dont like working with Maybe