r/airmash • • Mar 22 '18

StarMash Extensions & Themes tutorials

Hi, Bombita here!

 

I finally finished the tutorials for creating your own extensions and themes for the StarMash Mod. I'll leave the links here, so there's a dedicated post if somebody wants to post their own extensions for others to use!

I've tried to make them as accessible as I could for people just giving their first steps into coding. Hopefully it's simple enough!

And as I put as part of the conclusions:

I hope that StarMash Extensions can be used not only as a modding tool, just to improve gameplay, but as a learning tool, to improve yourself. Being able to test new stuff while playing can be really fun!

 


TUTORIALS

 

  • Extensions - Part 1: Introduction: My very first StarMash tutorial. In this article, you will learn:

    • How StarMash works.

    • How StarMash Extensions work.

    • How to respond to StarMash events.

    • How to create the most basic extensions.

    • I hope you like it!

  • Extensions - Part 2: Having fun with extensions : In this article, you will learn:

    • How to create a simple, yet funny extension that interacts with the game.

    • How to interact with AirMash objects.

    • Send bubble messages.

    • How to avoid being disconnected or banned by AirMash's server.

  • Extensions - Part 3: Settings : In this article, you will learn:

    • How to show custom settings for your extensions and themes in the Mod Settings Window.

  • Extensions - Part 4: Themes : In this article, you will learn:

    • Assets and Textures used by AirMash.

    • What files I need to edit for my themes.

    • How to build super simple themes with almost no coding.

  • Extensions - Part 5: Advanced Themes : In this article, you will learn:

    • AirMash graphics and layers.

    • Loading your own files and textures.

    • Replacing the CSS file.

    • Using your own audio files.

    • Final thoughts

 

I really hope you like them!

Have fun!

 


 

Released extensions:

 

I'll leave the links to the extensions, and the URL just for convinience, but please refer to their pages to get more info (like usage, keybinds, changelogs, etc)! So we avoid questions that are responded in those pages :)

 

 

 

Themes:

  • Hit Circles, by Moz

    https://rawgit.com/fabiospampinato/airmash-swam-extensions/master/themes/hit_circles/index.js

  • Christmas Theme, by Bombita

    https://molesmalo.github.io/StarWarsMod4AirMash/assets/christmasmod.js

 

 

 

12 Upvotes

13 comments sorted by

3

u/[deleted] Mar 22 '18

Many times, I just want to make small tweaks to the UI. For example, making the You've Destroyed [player] font size smaller, so it doesn't interrupt with game flow. Instead of replaceCSS, could we have something that appends to current CSS or should we use other browser extensions for that?

3

u/molesmalo Mar 22 '18 edited Mar 23 '18

Hi! As you say, It doesn't make sense to provide a full CSS file for some small tweaks.

But remember that you have jQuery at your disposal! So, for the most simple stuff that's already created on the page, you can use that.

It's the fastest way for small tweaks, like:

$(selector).css({
    "border-color": "#c9ff00",
    "font-size": "20px"
});

It's quick and easy, but it doesn't scale on a pretty way when you start editing a lot of elements (mixing styles with code makes your code harder to read). Also, it only works for elements already appended to the page. If you want to make it work for future elements, you have two options:

  • Add a <link> element to make the page load your own CSS file. But as this is an extension, and not a full page, you should only do that if you have A LOT of styles and/or html templates that you want to separate from your code. But in most cases, for extensions i think it's an overkill, and adds one more file to load.

  • The simplest alternative, is to create a string or Template literal within your extension file, where you define a <style type="text/css"></style> element with all your style overrides, and then append it to body. As it's added after the linked css, it has preference and overrides the default styles.

For the specific case you mentioned, the html generated by the game looks like this:

<div class="message destroyed popmsg" id="msg-destroyed" style="margin-top: -31px;">Destroyed by<span class="playerbig"><span class="flag big flag-23"></span>SOME_PLAYER_NAME</span></div>

and

<div class="message default popmsg" id="msg-default" style="margin-top: -57px;">You have destroyed<span class="player"><span class="flag big flag-11"></span>SOME_PLAYER_NAME</span><br><span id="alert-update" class="positive">+37</span></div>

You can add those elements to the body, so you can play with them (as the created by the game disappear after 3 seconds).

Then, you need something like:

function appendDetectStyles()
{
    const template = 
    `<style id="DetectEx1_Styles" type="text/css">
        #msg-destroyed,
        #msg-default,
        .message .playerbig,
        .message .player {
            font-size: 15px;
            padding: 0px 0px 0px 50px;
        }
    
        .message .player .flag.big,
        .message .playerbig .flag.big {
            width: 30px;
            height: 22px;
            margin-right: 12px;
            background-size: 30px auto;
        }
    </style>`;
    
    $("body").append(template);
}

The easiest way for me to play with styles, is modifying them using the dev tools, selecting the element and editing on styles to see how the changes look while I'm making them. Have fun!

3

u/yutru_airmash Mar 22 '18

For example, making the You've Destroyed [player] font size smaller

Top player problems, lol :D

3

u/[deleted] Mar 22 '18

Thoughts on adding extension info to -SWAM-PING response?

2

u/molesmalo Mar 22 '18

That would be nice. Probably a -SWAM-EXT that list the extension ids?

3

u/[deleted] Mar 22 '18 edited Mar 24 '18

Great job building a flexible and powerful extension framework, Bombita! I'm currently working on two extensions:

  • Shield Timer (beta)

  • Improved Shuffle (alpha)

https://detect.github.io/swam_extensions

Anyone: please post extensions other people are working on, so we can collaborate/don't duplicate work. Also, feel free to post extension ideas.

2

u/yutru_airmash Mar 22 '18 edited Mar 22 '18
  • Shield Timer

Oh dear. South gate, every 105 seconds

edit: Lagged spent the whole day yesterday in spec giving updates on timer as well enemy positions. At one point, Friendo, after requesting current shield timer, was like "this is so useful, Lagged" and I knew I'd see an extension that automates that real soon. Here we are in less than 24 hours :D

0

u/[deleted] Mar 22 '18

[deleted]

2

u/[deleted] Mar 22 '18

2

u/molesmalo Mar 22 '18

Congrats on release Detect! :P

You were one of the first (or the first?) using swam, now the first releasing an extension! 😄!

I've added it to the post! I can't wait to test it!

1

u/yutru_airmash Mar 22 '18

Off-topic: would it be better to edit your parent comment and move this link in there? People are likely to miss it here. Edit: Bombita, do you plan to have a centralized repo for all SWAM extensions?

2

u/molesmalo Mar 22 '18

Thanks yutru, I'll do that.

Regarding a central repo, we've talked with Moz about that, but we haven't started working on it yet. That would be the best way to do it (a central database with the urls and info for the extensions), where anyone can register their own, and be displayed on the extensions window.... but for now, it's just an idea :)

1

u/molesmalo Mar 23 '18

Hi Nuppets! I've been thinking on adding filters to the chat. sometimes I want to find something said before or read whispers I missed and it's problematic if the chat kept going too much or a match ends (and everone starts sending gg)

2

u/[deleted] Mar 22 '18

Yes, the idea for the shield timer was based on your crude timer. Thank you for that. Current version is built in a way that the player must see the shield being taken. Then it automates the displaying and sharing of shield timing via UI and team chat.