My discussion about taking my mods "to the next level"

Discussion in 'Mod Discussions' started by killerkiwijuice, March 11, 2015.

  1. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    <intro>
    As most of you know i'm still trying to learn stuff in my free time and have already made lots of threads about modding the simple parts about PA like Dox4Lyf, effects, etc. Those kinds of things.

    I'm 84% 100% done with the JS course on codecademy and basically done with HTML/CSS. I touched with a few libraries like JQuery but don't yet know why i'd want to use them.
    </intro>

    So now i'm going to ask for help to make a mod that will only go on PAMM if needed by popular demand because I have no idea how to make this kind of mod and will be based on other's knowledge.

    First, I'd like to know how to make a button that selects the commander (I know it can be a hotkey, but this is just to learn) I fugured this is very basic.

    Thanks for reading and helping :p
    Last edited: April 5, 2015
    wondible likes this.
  2. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Take a look at live_game_players. Clicking on your own icon selects your commander. media/ui/main/shared/js/api/ is also a good place to look for what is available. I think the commander HP mod has a select commander feature as well.
    killerkiwijuice likes this.
  3. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    I found this in select.js:
    Code:
            commander: function () { return engine.call("select.commander"); },
    Do you happen to know if that's the correct line? I don't know how to put it into a button yet so i can't test it.
  4. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    That is what the players panel calls. It uses a ko click handler.

    Code:
                                <div class="btn_player btn_player_known btn_std_ix" data-placement="bottom" data-bind="tooltip: model.playerToolTip($data), click: function () { api.select.commander(); api.camera.track(true); }">
    
    killerkiwijuice likes this.
  5. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    When faced with such a question usually before you make a button you can just start a game, spawn your commander and run the command in the console, so in this case engine.call("select.commander");
    killerkiwijuice likes this.
  6. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Oh, i didn't know that. Thanks ;p
  7. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    most modding work I do works by just directly modifing the PA files directly or testing things in the console. Only once I know what I want put it into a mod.
  8. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Another question: I already know how to shadow things, and that's the only way I know how to get new content into the game because, well, it shadows another file.

    If I create a new file, which i see in some mods, how do i get the game to load it?
  9. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    You use the "scenes" property in the modinfo.json files. Look at what the other mods have. Also, if you look in the corresponding .js files in /media/ui, you'll see that many of them have "loadmods". That's where those files are inserted. This works for css too.

    (By the way, the "scenes" property is a PAMM thing, not an Uber thing, but it makes multiple mods play nice together)
    killerkiwijuice likes this.
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    The system that loads mods by scene is from Uber. PAMM only takes of the hassle to write your own json file with the right paths in them to enable mods.
  11. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Most of programming is copying stuff and modifying it. Thats why I pointed you at the players panel and the commander HP mod. You can figure out a lot by looking at how the game does things and how similar mods work.

    Copying may diminish a little with experience, or maybe you just start copying from yourself more. ;^) In any case it goes double for starting out - change small things, and you can increase your ambition as you get the hang of it. Your stated goal is a pretty good place to start (depending on where you want to put the button)
    killerkiwijuice likes this.
  12. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Where did you find that line, or did you just think of it? I'm trying to look for something in live_game_players.js because i know the button to select the commander is in the live_game_players.html.
  13. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    That line is from some html file, probably the one you mentioned.
    killerkiwijuice likes this.
  14. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    Yes, but the loadmods from Uber gets its info from ui_mods_list.js, which is shadowed by PAMM. What gets placed in that ui_mods_list.js is determined by PAMM, which gets its information from the "scenes" property in the modinfo.json's of the mods. That's what I meant with the scenes property being a PAMM thing.
  15. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    It was line 39 of live_game_players.html in 79020.

    To find it you of course need to know that feature is in that file. I often search for suspected strings (select, commander, etc) or try to figure out where the feature I'm looking for should appear in the html. If you don't know the file, searching in all files is my favorite crutch - "find in files" is a muscle-memory keyboard shortcut in any editor I use regularly.
  16. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Yep, i kinda derped tbh. Used ctrl-f and found it instantly.

    I tried to do something with that line, again i didn't really know what to do with it to get in it game but I attached the folder here since it's where i get stuck and don't know how else to fix it.

    I'd really appreciate it if someone could see what I did wrong or didn't do at all ;__; (I also have to do schoolwork now)

    PS. I tried making the commander icon the thing that you click.

    Attached Files:

  17. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    "depending on where you want to put the button"

    Congratulations, you've chosen challenge mode ;^)

    If you are adding new files as opposed to shadowing something, you need to use the javascript based hookup through Uber's mod system. The mod loading system only supports only supports css and javascript - if you want to use html, you need to do manual panel hookup, inline strings, or ajax load it, all of which require javascript.

    It looks like you are trying to use floating framework. It's docs say you need to call a few javascript functions to get things going - one to create a floating frame, and another to give it html content you've gotten by one of the above methods. There are special cases for live_game.
  18. killerkiwijuice

    killerkiwijuice Post Master General

    Messages:
    3,879
    Likes Received:
    3,597
    Ah, well that makes more sense. While looking at the commander HP mod inside the .js file i can see a "$" symbol, i've seen that thing A LOT with mostly everything so far. From here, it looks to me like it allows the use of HTML inside a JS file? Looks like it's kinda important lol. (is that $ called ajax? If so i think I know where they got the commander name from :p)

    And also, I didn't intend to use floating framework, but that would be cool to use xD I think I should learn to actually make a basic button before granting it freedom.
  19. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    $ is the shorthand to use jQuery
  20. wondible

    wondible Post Master General

    Messages:
    3,315
    Likes Received:
    2,089
    Yeah, try adding one-more-button somewhere that already has buttons and work your way up.

    $ is a function, which is almost always the pervasive library jQuery - PA uses it so in this context it really is always. jQuery is something of a swiss army knife; the two main things you see passed to it are CSS-like selectors which makes it find things in the page, and bits of HTML that it turns into objects, usually to be inserted into the page. The result is a called a "wrapped set", an array-like object with lots of functions you can call to do things the elements inside of it.

    Among it's many features are a few functions that preform 'AJAX', which roughly means making HTTP requests via javascript.
    killerkiwijuice likes this.

Share This Page