Profile image

Cannon Casing Generator Script v. 1.0

67.1k SnoWFLakE0s  4.6 years ago

Hey folks! A while ago I made this thing, and while it's a very effective method to simulate casing ejection, it requires one-by-one setting of detachers to ammo("Weapon") = x, so it required stupid amounts of tedious work to get it to work for larger ammo counts.

But fear not! I tried to learn Python in twenty minutes (it's very similar to FT, the cross-over was very easy) and succeeded in creating a script to automatically generate an aircraft file that contains the casing ejection system for you. It's less intuitive on mobile platforms though, I'll try to find some way to do it for you guys.

This is done in Python 3!

This is the link to the Repl online IDE.. The script generates an aircraft file in the following format.

Once in the Repl, you will see my horrible code in the following format:

Simply click on the green "Run" button on the top bar, and the right-side console will print out some prompts for you to answer. Simply answer the prompts, and choose whether or not you want the file outputted in the external file in the sidebar. If you do not want to download the script (normally you shouldn't) receive the file in the command line, copy and paste it to a XML file and put it into your AircraftDesigns folder.

This is tedious, so I recommend downloading the script. To do this, click this link (download link). Run the script locally through the command line via python /directory/to/downloaded/script.py, answer the prompts through the console, and your aircraft file should be generated. Simply put it in your AircraftDesigns directory, load the craft (named Cannon Casing Script) drag it by the base fuselage and save as a subassembly.

Currently the script offers exactly what the diagram details and a single color setting for the entire system. The color simply determines whatever color slot that the aircraft will be painted in.

If moderators would like this removed, I will gladly do so. Otherwise, have fun with this, it should be very useful for a lot of builds.

  • Log in to leave a comment
  • Profile image
    67.1k SnoWFLakE0s

    I guess it's open source? Feel free to modify as you see fit.

    Pinned 4.6 years ago
  • Profile image
    69.4k Chancey21

    I tried to contact you on discord but it failed @SnoWFLakE0s

    4.6 years ago
  • Profile image
    18.2k exosuit

    @WalrusAircraft that is very nice to hear, glad your health is getting better. Can't wait for the plane
    .
    long live Awwam

    4.6 years ago
  • Profile image

    @exosuit - Hello, Walrus Sr. here. I never left, and I’m constantly amazed how much the game has progressed from simple early days. When I joined, there were probably only 150 players in the game. I think Boxglow was the first or second player in fact. I’m mostly busy these days. I work in cloud development so I’ve been especially busy in recent weeks since our software is used to keep the world running (banks, hospitals, etc..). It has been difficult for my teams, especially those in India who are truly locked down. My son and I will try to release a simple airplane soon.

    +1 4.6 years ago
  • Profile image
    18.2k exosuit

    @WalrusAircraft YOU'RE ALIVE!

    4.6 years ago
  • Profile image
    67.1k SnoWFLakE0s

    @WalrusAircraft
    .
    Again, I played with Python for a grand total of about 5 hours till this point... I don't think I'll be able to do any CAD-file to SP conversion scripts in the near future, but I'll think of it as a potential project to work towards.
    Thanks for the compliments.

    4.6 years ago
  • Profile image

    @SnoWFLakE0s - Thank you. I might upload a version to show you the issues, but I'll continue to play around with drag to see if I can replicate it. I noticed you changed that and the 3 axis angles on the detacher, however my attempts were not getting it right. On the topic of your code, it brought a smile to my face. I really enjoyed your Python code. I suppose it is possible to make something similar to what Sleddriver made (incremental sizing on fuselage parts) for smooth creations. It would be neat to replicate that, but in a way to bring it to the SP masses. Have you considered a way to take the xyz points from a 3D object (like from Solidworks or even Excel)? I think XYZ-2-WF offers a free utility for converting raw three-dimensional numeric data files.

    4.6 years ago
  • Profile image
    67.1k SnoWFLakE0s

    @WalrusAircraft
    .
    A bit of extra drag and angled detachers. I opted not to add extra for the sake of people making things with this system. The more crucial part is the angle of the detacher. Play around with how the detacher is oriented until you get some desired result... On the original I just made some randomized changes to the detacher angles to make tumbling occur.

    4.6 years ago
  • Profile image

    This is excellent. One question... How did you get the shell tumbling to work on the original gun? I tried replicating it, but no dice. Even when I copy the shells and detacher as sub assemblies, matching all settings, it still does not work.

    4.6 years ago
  • Profile image
    67.1k SnoWFLakE0s

    @DarDragon
    .
    Executable code. Who knows, I could've put in a virus in there if I had malicious intent.

    +1 4.6 years ago
  • Profile image
    16.5k DarDragon

    Why would the moderators what this to be removed?

    4.6 years ago
  • Profile image

    Cool!

    4.6 years ago
  • Profile image
    162k spefyjerbf

    Awesome! Nice work.

    4.6 years ago
  • Profile image
    67.1k SnoWFLakE0s

    @spefyjerbf
    .
    Yep, I wanted try doing option #2, but that made the XML file sort of inaccessible... Although either way unless you've downloaded the script you have to copy and paste.
    For the XML file output, I redirected the console output stream to an external file write:
    .

    producefile = input("Output file to command line? (Type 1 for Yes, 0 otherwise) \n")
    if producefile == 1:
    print("Check the side bar for the Subassembly XML file.")
    import sys
    sys.stdout = open("CannonSubAssembly.xml", "w")

    .
    Like so.

    4.6 years ago
  • Profile image
    162k spefyjerbf

    Very nice. If you want to hide your code, and link players directly to the program execution, then run your repl in a new tab, and use that URL for the link. Also note that people must have python installed to run a python program (when downloaded). Anyway, nice work! It makes the XML file to copy/paste?

    4.6 years ago