Eve Mining Bot - amendment to let it use mining drones (among other things)

I am trying to finesse the existing mining bot to handle running a Porpoise. The first thing I wanted to add was the ability for it to use mining drones. I thought that this would be very straightforward but it seems .. not.

I was thinking I could replace the code block between line 862 and 892 with code to send drones to the selected asteroid. Basically I should just be able to rip the code from 1680 to 1709 but change the context menu paramter from ‘Return’ to ‘Mine’.

However when I try to compile I get

This `case` expression produces:

    Maybe (Common.DecisionPath.DecisionPathNode EndDecisionPathStructure)

But all the previous branches result in:

    Common.DecisionPath.DecisionPathNode EndDecisionPathStructure

Clearly, my lack of Elm skill is hindering me here but I don’t see why this is occuring or how to go about fixing it.

Obviously this is just a hack as it will continually try to send the drones on every cycle but its good enough for now until I figure out how to set a state variable for “drones assigned” and have it reference that.


ie this code block

                                                            case
                                                                knownMiningModules
                                                                    |> List.filter (.isActive >> Maybe.withDefault False >> not)
                                                                    |> List.head
                                                            of
                                                                Nothing ->
                                                                    describeBranch
                                                                        (if knownMiningModules == [] then
                                                                            "Found no mining modules so far."

                                                                         else
                                                                            "All known mining modules found so far are active."
                                                                        )
                                                                        (case readShipUIModuleButtonTooltips context of
                                                                            Just readAction ->
                                                                                readAction

                                                                            Nothing ->
                                                                                case deactivateAfterburner context of
                                                                                    Just deactivateAfterburnerAction ->
                                                                                        describeBranch "Deactivate afterburner."
                                                                                            deactivateAfterburnerAction

                                                                                    Nothing ->
                                                                                        waitForProgressInGame
                                                                        )

                                                                Just inactiveModule ->
                                                                    describeBranch "I see an inactive mining module. Activate it."
                                                                        (clickModuleButtonButWaitIfClickedInPreviousStep context inactiveModule)

Replaced with

    case context.readingFromGameClient.dronesWindow of
        Nothing ->
            Nothing

        Just dronesWindow ->
            case dronesWindow.droneGroupInSpace of
                Nothing ->
                    Nothing

                Just droneGroupInLocalSpace ->
                    if
                        (droneGroupInLocalSpace.header.quantityFromTitle
                            |> Maybe.map .current
                            |> Maybe.withDefault 0
                        )
                            < 1
                    then
                        Nothing

                    else
                        Just
                            (describeBranch "I see there are drones in space. Set them mining."
                                (useContextMenuCascade
                                    ( "drones group", droneGroupInLocalSpace.header.uiNode )
                                    (useMenuEntryWithTextContaining "Mine" menuCascadeCompleted)
                                    context
                                )
                            )

Any insights or pointers gratefully received.