[Question] Adding in custom units.

Discussion in 'Mod Discussions' started by squishypon3, June 2, 2014.

  1. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Hello, I was planning on adding in a unit but couldn't get it to appear in the factory.

    I edited the unitlist.json and added the factorybuild term in the unit type segment but it still doesn't appear, any ideas?
  2. shiwanabe

    shiwanabe Member

    Messages:
    82
    Likes Received:
    32
    Every factory and fabricator has more than one type that it checks for and setting one unit type will override any others that would've been inherited.

    That should cover all of it, as i'm sure you've gotten through all the other parts of making sure the unit is complete.
  3. zx0

    zx0 Well-Known Member

    Messages:
    295
    Likes Received:
    319
    I think it's you need to add it to \ui\main\shared\js\build.js as well.
  4. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Oh, thanks! I'll give it a try.

    Edit:

    Hm.. Still doesn't seem to show up, I gave the .json directory to it but no dice. :/

    halp.PNG

    Edit2: It may be because I put that in as a mod. I went to my server mod folder and then my mod's folder then created a separated area: ui/main/shared/build.js
    Last edited: June 2, 2014
  5. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    Can you show the unit .json please? In order for a custom unit to be buildable it needs:
    • A json file with "unit_types" properly set.
    • An entry in the unit_list.json, pointing to the shadowed .json file
    • An entry in the build.js, pointing to the shadowed .json file
    Optional:
    • Thumbnail in ui/main/game/live_game/img/build_bar/units

    In the build.js, 15 is not a valid number. In inputmap.js, only hot keys 0-14 are defined per build group.

    Wrong path for the custom build.js btw, it's supposed to be ui/main/shared/js/build.js, not ui/main/shared/build.js.
  6. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Oh, alright, thank you very much!

    I had seen the numbers and assumed they were some sort of identifier (odd how it starts at five) and also, whoops on the .js part..
  7. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Here, you may be able to find out how to do it... If you've got the time I'd apreciate it, it's really late and I'm pretty tired... Also- I can't figure it, if you can, I'd love to hear what I did wrong. :D

    Attached Files:

  8. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    At least one error:
    You have the hotkey "5" assigned twice now. It's therefor colliding with Adv. vehicle fabber.

    Oh, and you renamed the folder and unit to "tank_hover", but left the old "hover_tank" in the build.js

    Unfortunately I can't test it right now, graphics card is broken and had to be shipped in :(
  9. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    So what do I change the binding to? Is it possible to make it four? I haven't seen any unit in the build.js with 4 as it's hotkey, they all start with 5.
  10. exterminans

    exterminans Post Master General

    Messages:
    1,881
    Likes Received:
    986
    All values from 0-14 are valid, non most be used twice in the same category. Decide for yourself what you are going to place where.
  11. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    I just decided to bump the fabricator back to hotkey 4 so it would fit.
  12. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Still doesn't seem to show... I'm confused. :(

    Edit: Also, how do you give it an icon in the files? I can add a .png but how do I actually fit that to the unit?

    Attached Files:

    Last edited: June 3, 2014
  13. zx0

    zx0 Well-Known Member

    Messages:
    295
    Likes Received:
    319
    What unit are you currently trying to add, tank_hover? Then you .json is broken. json.png You forgot to put (") after UNITTYPE_Basic.
  14. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Aha! Thank you so much that must be it! Hopefully... It's great having more than one person helping to find bugs in the code. ;)
  15. swizzlewizzle

    swizzlewizzle Active Member

    Messages:
    216
    Likes Received:
    56
    How are we supposed to debug things like this? Is there a console log of some sort that we can use to easily step through the load process? What about during the game?
  16. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    I use the instant sandbox mod to make a quick sandbox match, and then just swapped the base_commander.json with the avatar_commander.json by renaming it and placing it in the base_commander file. This means you can build everything, almost instantly. I'll mock up a quick version for you if you'd like.
  17. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    are you using notepad+? It should notify you of quotes that are missing a close via color.

    if not, use it, lest you run into daylong problems just because code syntax.
  18. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    I was using notepad++ and it doesn't seem to show me, though I hadn't actually set it to java script which may be why.
  19. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    I find it suprising it doesn't warn you of quotes considering any code can be botched with unclosed quotes.
    squishypon3 likes this.
  20. squishypon3

    squishypon3 Post Master General

    Messages:
    7,971
    Likes Received:
    4,357
    Aha, just as I thought, setting the language to java showed me errors. (Thank god as I was trying to add in another unit but couldn't figure out what was going on, similar problem- only... an extra quote. ;) )
    thetrophysystem likes this.

Share This Page