Mod request - Chat Notification

Discussion in 'Mod Discussions' started by lulamae, December 10, 2017.

  1. lulamae

    lulamae Planetary Moderator

    Messages:
    799
    Likes Received:
    307
    Anyone up to building an mod that would produce an audio notification when someone posted in the in game chat?

    I can get tunnel vision when playing and a notification would be a big help.
  2. lulamae

    lulamae Planetary Moderator

    Messages:
    799
    Likes Received:
    307
    I miss more than just urgent game-related messages from my team mates though. If I had half a clue about programming, I'd do it myself. But I don't, so I have to ask.
  3. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    So kind of like this? Severely untested of course, just to get an idea. It's supposed to play a sound when a chat message is added. I haven't actually tested to see if it works on receiving chat, but it works on sending. :)

    Attached Files:

  4. lulamae

    lulamae Planetary Moderator

    Messages:
    799
    Likes Received:
    307
    Thanks! I looked at the .js files to try to get an idea of what is going on. I also looked at the .js files for "Who Deleted That" and "Sound Effects for Chat Message" since they both interacted to chat. But to no avail - I just couldn't grasp what was going on.

    What little programming experience I have is from cobbling together Visual Basic macros for MS Excel at work.

    At any rate, I bought 'Beginning Programming with Java For Dummies ' today to see if it would help me make sense of what's going on.
  5. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    Yeah, it's a bit tricky. PA uses a JavaScript library called Knockout which has the nice feature that it automatically reacts to changes of what is called observables. The chat messages are stored in the observableArray "chatLog" and by calling "subscribe" on it, I can get notified of changes and execute a function (see here). In that function I call api.audio.playSound, which is a function defined by PA and also used for the UI sounds. The only way to figure out all of that is to look at the JavaScript files to come with PA and there are quite a lot of those.

    I think those other two mods are server mods if I remember correctly.

    By the way, Java is not the same as JavaScript. They're quite different languages.
    lulamae likes this.
  6. lulamae

    lulamae Planetary Moderator

    Messages:
    799
    Likes Received:
    307
    I owe you a drink.
    DeathByDenim likes this.
  7. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    Heh, I never really understood why they are named so similarly. It's really confusing!

    Anyway, I'll get this mod in a publishable state. And I'll probably make an example mod out of it too while I'm at it.
  8. NikolaMX

    NikolaMX Active Member

    Messages:
    141
    Likes Received:
    141
    @flubbateios made a mod for that, he could give u some feedback on how to get yours going
  9. lulamae

    lulamae Planetary Moderator

    Messages:
    799
    Likes Received:
    307
    I took a look at his "Sound Effects for Chat Messages" mod and I think I got a general sense of what was going on but I need to learn some JavaScript before I can discuss it with a degree of intelligence. Searching for the right 'Dummies' book on that now.
  10. flubbateios

    flubbateios Active Member

    Messages:
    103
    Likes Received:
    240
    My mod is really badly programmed :(

    It also plays sounds through the coherent ui. they seem to be much quieter than sounds played through the engine with audio.playSound
  11. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    As far as I know audio.playSound only plays sounds that already come with PA. It's not possible to load other sounds like your mod does. At least, I think it can't. I haven't actually tested it.
  12. flubbateios

    flubbateios Active Member

    Messages:
    103
    Likes Received:
    240
    Yeah, that's the reason that I can't use playSound. Surely there's an in-game noise that could be used as a notification sound though.
  13. n00n

    n00n Active Member

    Messages:
    345
    Likes Received:
    210
    I'd pick:
    Code:
    api.audio.playSound('/SE/UI/UI_camera_anchor_saved');
    @lulamae Let us know if you need more help. ;)
    Last edited: December 30, 2017
    lulamae likes this.
  14. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    lulamae likes this.
  15. lulamae

    lulamae Planetary Moderator

    Messages:
    799
    Likes Received:
    307
    Wow!
    I just took a quick look and you put a lot of work into that. I'm still in the early stages of the JavaScript books I bought but I'll be spending some quality time on your page.

    Thanks!

Share This Page