my modified section of code below. trying to print out the list of pilots in local. but i can’t seem to figure out how to deal with lists correctly, and the maybe object type is also not helping. Any help would be appreciated. my thoughts were to get the list pilots then pull out each name and concat them to one string. but I get errors related to trying to disect the list.
chatWindowReport =
“I see "
++ (localChatWindow.visibleUsers |> List.length |> String.fromInt)
++ " users in the local chat. "
++ (subsetOfUsersWithBadStanding |> List.length |> String.fromInt)
++ " with bad standing.”
++ ( stringLocalUsersFromList localChatWindow.visibleUsers)
alarmRequests =
if 1 < (subsetOfUsersWithBadStanding |> List.length) then
[ EveOnline.BotFramework.EffectConsoleBeepSequence
[ { frequency = 700, durationInMs = 1000 }
, { frequency = 0, durationInMs = 1000 }
, { frequency = 700, durationInMs = 5000 }
]
]
else
[]
in
( alarmRequests, chatWindowReport )
stringLocalUsersFromList : List EveOnline.MemoryReading.ChatUserEntry -> String
stringLocalUsersFromList users =
List.map getUserName
|> String.concat
|> Maybe.withDefault "bad list"
getUserName : EveOnline.MemoryReading.ChatUserEntry -> String
getUserName user =
case user of
Nothing -> "sorry no users"
Just val -> user.name
Starting from that version, I add the code to print the list of pilots.
I divide the implementation into multiple commits, to make it easier to follow.
The first change only copies the code you posted:
The next commit fixes the new functions:
To pull out the name of the ChatUserEntry, I add .name in the getUserName function:
stringLocalUsersFromList : List EveOnline.MemoryReading.ChatUserEntry -> String
stringLocalUsersFromList users =
users
|> List.map getUserName
|> String.concat
getUserName : EveOnline.MemoryReading.ChatUserEntry -> String
getUserName user =
user.name
|> Maybe.withDefault "Failed to read this users name"
Since you were using a case syntax in your code: You could achieve the same functionality with this syntax:
getUserName : EveOnline.MemoryReading.ChatUserEntry -> String
getUserName user =
case user.name of
Nothing ->
"Failed to read this users name"
Just userName ->
userName
The next change integrates the string into the display:
I also added another change to make the list of pilots easier to read:
that works much better, thanks for the commit changes + notes.
separate note, do i have to do anything to make the beep warnings work?
I am getting the status text in the console, but no noises are being made in the game.
case parsedUserInterface |> localChatWindowFromUserInterface of
CanNotSeeIt →
( [ EveOnline.BotFramework.EffectConsoleBeepSequence
[ { frequency = 700, durationInMs = 100 }
, { frequency = 0, durationInMs = 100 }
, { frequency = 700, durationInMs = 100 }
, { frequency = 400, durationInMs = 100 }
]
]
, “I don’t see the local chat window.”
)