[WIP] Unit/Fab Counter

Discussion in 'Mod Discussions' started by neophyr3, March 29, 2014.

  1. neophyr3

    neophyr3 New Member

    Messages:
    28
    Likes Received:
    6
    So I was trying to get a mod that shows your army count and found that search doesn't lead you to any of them and it is not in PAMM. It's really easy to do, just needing armySize(), but it is a pain for those who don't know.

    I haven't done any Javascript (or programming in general) in over 5 years, so I'm somewhat confused how to go about this. I'm not sure how to deal with the code I had to add to live_game.js (to be able to display the number of fabbers you have). How do I do this in a separate file?

    The code I added to live_game.js was:
    model.fabberCount(payload.fabber_army_count);
    ----in "handlers.army = function (payload) {}"

    self.fabberCount = ko.observable(0.0);
    ----after self.armySize = ko.observable(0.0); (In function LiveGameViewModel())

    If this already exists in another mod, please just tell me.
    Last edited: March 29, 2014
  2. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Hmm actually, back in ancient alpha times I had a mod like that. Got lost somewhere. Dunno. PA Stats kinda replaced it. I am not quite sure if you ever get the fabber count as a player though.
    For how to do it, look at existing mods on github or some sticky threads here in this forums.

    Like i.e. this one: https://github.com/pamods/uimod-ecoeff2
    or in general: https://github.com/pamods
  3. neophyr3

    neophyr3 New Member

    Messages:
    28
    Likes Received:
    6
    Wait, PA stats gives you your unit count as you play? Didn't see that in the description of the mod.

    Also, the code I put in live_game.js lets you use fabberCount(), which lets you see your fabber count as a player. You can do the same thing with mobile and structures with a couple extra lines each.
  4. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Well no, not as you play, unless you watch your graph while playing which is kinda cheating if your opponent is using it as well (who would have time to watch the graph while playing anyway?!). But I only ever used that little army counter mod to know how much stuff I have at minute X or Y to analyze the game anyway. PA Stats kinda is the massively enhanced version of that.

    Guess those count methods are pretty new, probably added for the spectator features.
  5. neophyr3

    neophyr3 New Member

    Messages:
    28
    Likes Received:
    6
    Yeah, I'm basically just taking it from the spec features and enabling it for player use.

Share This Page