[REL] Building Writer

Discussion in 'Mod Discussions' started by trialq, January 19, 2014.

  1. trialq

    trialq Post Master General

    Messages:
    1,295
    Likes Received:
    917
    This is very wip, but I've started a mod where you can write text with buildings. Nowhere near done, but there's something to show so why not. Here's an example:
    smile_1.jpg

    smile_2.jpg

    You can use any building type to write with, although obviously the smaller the better (walls, point defenses). To create the above, I:
    • Selected a fabber
    • Selected wall from the menu
    • Moved the camera to where I wanted the writing (centered)
    • Pressed a hotkey
    To make smaller text, zoom the camera in before you hit the hotkey. It's rather hacky, but usable. Resolution may be an issue, as well as camera tilt (slight distortion), curvature of planet (particularly small planets, again slight distortion), and obstacles (like craters taking chunks out of the drawing). Here's what happens when you try and write too small:
    smile_3.jpg

    In the end the mod will probably have a ui textbox you can write a custom word in.
  2. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Does this work by giving a pattern of build commands when you press the hotkey?
  3. trialq

    trialq Post Master General

    Messages:
    1,295
    Likes Received:
    917
    Yes, currently I've written patterns for 6 letters. At the minute each letter is drawn as if on a 100x100 grid.
  4. stormingkiwi

    stormingkiwi Post Master General

    Messages:
    3,266
    Likes Received:
    1,355
    GLORIOUS! Simply glorious! I've been doing it really rudely so far. You sir are amazing.
  5. trialq

    trialq Post Master General

    Messages:
    1,295
    Likes Received:
    917
    Attached is an early draft. It's not finished so can't go on pamm yet (it's for those who want to try it early, I have somewhere to be so can't finish it tonight). But you can write whatever text you want (limited to a through z).


    • Needs floating framework
    • Make sure nothing is binded to q, as it is the hotkey used
    • You need to be careful how you deselect units after pressing the hotkey atm, right click then left (shift is never pressed, so shift keyup never done to end it)
    • It shadows inputmap.js to create hotkey, is there a better way?
    • May not play nice with other mods yet (i'm guessing maybe hotbuild because of above?), wip

    Each character is drawn using 100x100 pixels of screen coordinates, so a 720p resolution can draw 12 characters, a 1080p resolution can draw 19 characters, etc.

    Try it and let me know of any other problems and suggestions.

    Attached Files:

    Last edited: January 19, 2014
    elitedanzel and LavaSnake like this.
  6. elitedanzel

    elitedanzel Active Member

    Messages:
    151
    Likes Received:
    137
    Thinking of a practical use for this, could you automate turret+wall building so it will build a laser turret and perfectly surround it with walls?
  7. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
    Yes stop shadowing inputmap !

    Put this in a js that is referenced in global_mod_list

    Where WriteBuilding is the call to your write building function aka the function that needs to happen when pressing the key
    Code:
    action_sets.buildwriter = {};
    action_sets.buildwriter["Write Building"] = function(event) { WriteBuilding(); };
    
    default_keybinds.buildwriter = {};
    default_keybinds.buildwriter["Write Building"] = "q";
    
    
    in a js that is referenced in live_game put this as last.
    this will make sure your keybind is executed as last so in case of keyboardconflict's your function will win.
    To make really sure set in modinfo.json a higher priority then 100 (so it's higher then hotbuild2) and will be executed later.
    Code:
    var buildwriterapplyUIDisplaySettings = model.applyUIDisplaySettings;
        model.applyUIDisplaySettings = function () {
            apply_keybinds("buildwriter");
            buildwriterapplyUIDisplaySettings();
        };
    
    If you do this you will see a buildwriter title appear in settings > keyboard tab (at the end of the list)
    There everybody can change the key. And when it conflicts with another key it will tell.

    If you need some help let me know.
  8. trialq

    trialq Post Master General

    Messages:
    1,295
    Likes Received:
    917
    Thank you for the information, I will ask if I need help but it looks like you walked me through the whole process. I like to figure things out for myself, but sometimes it takes the longest time to figure out, and can result in some nasty hacks :p

    That is a logical evolution and should be possible, however I haven't figured out how to select which buildings to build yet. The generalisation of what you suggest is customisable build blueprints, ie the user can create a blueprint to build x y z at X Y Z. One day I may attempt such a mod, but it would be a much bigger undertaking than this one and would require better skill at javascript than I currently have. I wouldn't be surprised if someone beat me to it, it could be a very useful mod.

    Perfect is a subjective term, but I don't think it can be made so; 'pretty good' is about as good as it gets. A major point is that we're using screen coordinates, with drawbacks outlined in the OP. One of the main obstacles is accounting for user zoom. Too close and walls are missing, too far away and you have a laser tower in the center of a wall perimeter that takes up half the map.
  9. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I think I saw some ko observable for the zoom level somewhere. So it might be possible to calculate the screen coordinates from that.
    Sounds very interesting to do. Hmm

    EDIT:
    Yeah I saw a variable for the zoom level:
    [​IMG]

    However I think I have an idea.
    Last edited: January 20, 2014
    stormingkiwi likes this.
  10. trialq

    trialq Post Master General

    Messages:
    1,295
    Likes Received:
    917
    Updated to v1.1. Pending on pamm.
    • a-z implemented
    • 0-9 implemented
    • Some other characters: :\/#!^<>
    • Hotkey removed, instead there's a draw button next to where you enter the text. This makes more sense as you'd want to hit draw just after writing some text, and it's a seldom used function so shouldn't have a hotkey
    • Probably still some minor issues, but no messy shadowing so it should be fine on pamm. Plan to update to integrate better with ui, add characters etc

    Attached Files:

  11. elitedanzel

    elitedanzel Active Member

    Messages:
    151
    Likes Received:
    137
  12. keterei

    keterei Active Member

    Messages:
    258
    Likes Received:
    93
    Interesting. I'll be expecting power gen profanities in future games from now on.

    But in all seriousness, this mod looks like it has a lot of potential.
    stormingkiwi likes this.
  13. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    I was thinking the same. As a practical use sort of thing, do you think this could be used to make functional formations for things? Like partial patterns for base template, or spaced out curves for ideal turret line placement?
  14. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    proeleert is currently working on the imba walls mod, which gets you part way to that goal.
  15. thetrophysystem

    thetrophysystem Post Master General

    Messages:
    7,050
    Likes Received:
    2,874
    Thats is cool too then. I just figured, reprogramming the pattern in this game and a lot of hard-testing tweaking, you could probably space a pattern for a template base, for power gens, for turrets, for artillery, and spaced one template after another so they all the structural templates fit inside the empty space of one another.

    I will check that mod out.
  16. keterei

    keterei Active Member

    Messages:
    258
    Likes Received:
    93
    This got me to wonder if you would be able to make a mod that allowed us to free drag-draw buildings. So, you select a building, hold down the mouse button, and move the mouse around to draw in whatever direction your mouse moves instead of either just a line or a radius of buildings. Thoughts?
  17. trialq

    trialq Post Master General

    Messages:
    1,295
    Likes Received:
    917
    Should be pretty easy (maybe not by holding the mouse button, instead holding a hotkey), but isn't free draw already in Uber's pipeline??
  18. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Just because something is planned by Uber does not mean you could not do it before they do.
    Especially when it is easy to do ;)
  19. keterei

    keterei Active Member

    Messages:
    258
    Likes Received:
    93
    I haven't checked to see if Uber are planning that actually. Well, it would be cool to have but I'm fine with or without it. So it's up to you : )
  20. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    Hence the profile pic fixer mod. :D

Share This Page