I’m trying to figure out how to get a total item count from the orehold to make a decision.
Here is the starting function.
[...]
Just itemInInventory ->
describeBranch "I see at least one item in the ore hold. Move this to the item hangar."
(endDecisionPath
(actWithoutFurtherReadings
( "Drag and drop."
, EffectOnWindow.effectsForDragAndDrop
{ startLocation = itemInInventory.totalDisplayRegion |> centerFromDisplayRegion
, endLocation = itemHangar.totalDisplayRegion |> centerFromDisplayRegion
, mouseButton = MouseButtonLeft
}
)
)
)
Here is what I am trying to achieve.
[...]
Just itemInInventory ->
if itemCountInSelectedContainer > 5 then
describeBranch "At least 5 items in the ore holder. Stack them."
(useContextMenuCascade
( "Ore hold", itemInInventory )
(useMenuEntryWithTextContaining "Select All"
(useMenuEntryWithTextContaining "Stack all" menuCascadeCompleted)
)
context.readingFromGameClient
)
else
describeBranch "I see at least one item in the ore hold. Move this to the item hangar."
(endDecisionPath
(actWithoutFurtherReadings
( "Drag and drop."
, EffectOnWindow.effectsForDragAndDrop
{ startLocation = itemInInventory.totalDisplayRegion |> centerFromDisplayRegion
, endLocation = itemHangar.totalDisplayRegion |> centerFromDisplayRegion
, mouseButton = MouseButtonLeft
}
)
)
)
I’m not sure how to extract the itemCount in Int from this function in ParseUserInterface.elm
How did I find the functions linked above? When you test the mining bot example bot, you can see it uses a drag&drop action to move items from the selected container to the item hangar.
This means it somehow reads the location of an item in the selected container.
That bot also displays this text when it performs this action:
“I see at least one item in the ore hold. Move this to the item hangar.”
You can use that text to find the action in the program code. In that part of the function to select the next action, you see the usage of selectedContainerFirstItemFromInventoryWindow to get the item in the inventory.
TYPE MISMATCH - This function cannot handle the argument sent through the (|>) pipe:
373| if (itemCountInSelectedContainerFromInventoryWindow |> Maybe.withDefault 0) > 5 then
#^^^^^^^^^^^^^^^^^^^#
The argument is:
#EveOnline.ParseUserInterface.InventoryWindow -> Maybe.Maybe Int#
But (|>) is piping it to a function that expects:
#Maybe.Maybe number#Elm
Going by that error message, the types don’t match exactly, but almost.
What we need to know here is that Int is a number. This means that Maybe.Maybe Int satisfies the constraint of Maybe.Maybe number.
Knowing the relationship between Int and number, we can understand we only need to get rid of the EveOnline.ParseUserInterface.InventoryWindow -> part in the front.
The arrow tells us it is a function argument. To get rid of a function argument, we apply the function to an argument.
The types should match as soon as you add a value of type EveOnline.ParseUserInterface.InventoryWindow.
dockedWithOreHoldSelected : BotDecisionContext -> EveOnline.ParseUserInterface.InventoryWindow -> DecisionPathNode
dockedWithOreHoldSelected context inventoryWindowWithOreHoldSelected =
case inventoryWindowWithOreHoldSelected |> itemHangarFromInventoryWindow of
Nothing ->
describeBranch "I do not see the item hangar in the inventory." askForHelpToGetUnstuck
Just itemHangar ->
case inventoryWindowWithOreHoldSelected |> selectedContainerFirstItemFromInventoryWindow of
Nothing ->
describeBranch "I see no item in the ore hold. Check if we should undock."
(continueIfShouldHide
{ ifShouldHide =
describeBranch "Stay docked." waitForProgressInGame
}
context
|> Maybe.withDefault (undockUsingStationWindow context)
)
Just itemInInventory ->
if (itemCountInSelectedContainerFromInventoryWindow inventoryWindowWithOreHoldSelected |> Maybe.withDefault 0) > 5 then
describeBranch "At least 5 items in the ore holder. Stack them."
(useContextMenuCascade
( "Ore hold", itemInInventory )
(useMenuEntryWithTextContaining "Stack all" menuCascadeCompleted)
context.readingFromGameClient
)
else
describeBranch "I see at least one item in the ore hold. Move this to the item hangar."
(endDecisionPath
(actWithoutFurtherReadings
( "Drag and drop."
, EffectOnWindow.effectsForDragAndDrop
{ startLocation = itemInInventory.totalDisplayRegion |> centerFromDisplayRegion
, endLocation = itemHangar.totalDisplayRegion |> centerFromDisplayRegion
, mouseButton = MouseButtonLeft
}
)
)
)