Modding Help Custom GUI example for 1.3?

Discussion in 'Starbound Modding' started by ncitizen, Sep 16, 2017.

  1. ncitizen

    ncitizen Intergalactic Tourist

    Greetings,

    I am currently trying to start semi-public starbound server. As result, I am looking for some easy (from player side) methods of grief protection. So far, my best bet seems to be in combination of craftable shield generators and password-locked access doors (to prevent unauthorized generator deactivation and to allow creation of safe storage rooms).

    Unfortunately, the only two mods for password locks, that I have found (wired padlocks [1] and door locks [2]) seem to be outdated. Having no previous experience with Lua or starbound modding, I have decided to try and revive one of them nevertheless.

    As far, as I've found out, the method they use for drawing -- ScriptConsole -- have been removed from 1.3. Is there any replacement table?

    Moreover, is there any documentation on game provided Lua API? The only thing I have found seems to be very fragmentary and outdated [3]. Is there some way to get API information from game itself (e.g. some "header" files in assets, defining exported methods)?

    In any way, can someone of you point me to, or post example of custom GUI for modded item, which works under 1.3?

    Much regards,

    [1]: https://community.playstarbound.com/resources/wired-padlocks.2517/
    [2]: https://community.playstarbound.com/resources/door-locks.4570/
    [3]: https://gist.github.com/jordoh/7864154
     
  2. bk3k

    bk3k Black Hole Surfer

    Did you look in the actual starbound folder for documentation?
    \Starbound\doc\lua\

    Besides that, unpack the assets and look in /interface/ to how different vanilla thing work.

    I've thought about adding keypad locked door support into Automatic Doors. And I was going to make an interface to change some settings too, but I keep forgetting I was going to do this.
     
  3. ncitizen

    ncitizen Intergalactic Tourist

    Thanks for reply!

    No, I haven't seen the documentation before. Although it's also very fragmentary: it features only list of calls, even without expected argument types <A lot of rambling about static vs dynamic typisation>.

    Yes, I'm going to look through game assets and other mods, looking for inspiration.

    Thanks again!
     
  4. slowcold

    slowcold Starship Captain

    Saw this - https://community.playstarbound.com/resources/backpacks.4958/ - when I were looking for a completely different mod (I saw a stand alone growing tray somewhere on here, damned if I can find it again!) and remembered your thread.

    Password protected storage, and it's current. Might be useful for what you need.
     
  5. ncitizen

    ncitizen Intergalactic Tourist

    Ok, I've looked through assets and tried to put something together. It actually tries to display gui on interaction, but then the game kicks me from "local server", writing the following to the log:

    Code:
    ...
    [21:41:02.821] [Info] UniverseServer: listening for incoming TCP connections on 0.0.0.0:21025
    [21:41:08.333] [Error] WorldServerThread exception caught handling incoming packets for client 1: (JsonException) Json::get(1) out of range
    [0] 7ff686f47153
    [1] 7ff686f45ede
    [2] 7ff686ee5ee3
    [3] 7ff6871e761e
    [4] 7ff687502d31
    [5] 7ff6875000fb
    [6] 7ff687514a3b
    [7] 7ff687514558
    [8] 7ff686f43c5e
    [9] 7ff9b56c8364 BaseThreadInitThunk
    [10] 7ff9b5ee5e91 RtlUserThreadStart
    [21:41:08.335] [Info] Client received world stop packet, leaving: Removed
    [21:41:08.575] [Info] UniverseServer: Client 'Samir' <1> (local) disconnected for reason: Incoming client packet has caused exception
    [21:41:08.576] [Info] UniverseServer: Stopping idle world ClientShipWorld:5936fea665c7cf35909311058d9b5145
    [21:41:08.716] [Error] You were disconnected from the server for the following reason:
    Incoming client packet has caused exception
    [21:41:08.864] [Info] UniverseServer: Stopping UniverseServer
    ...
    My .config:

    Code:
    {
      "titleFromEntity" : true,
      "paneLayout" : {
        "background" : {
          "type" : "background",
          "fileHeader" : "bg.png",
          "fileBody" : "bg.png",
          "fileFooter" : "bg.png"
        }
      }
    }
    I can post other files, if neccessary.
     
  6. slowcold

    slowcold Starship Captain

    Could you post the relevant object file and frames file please? Get exceptions for me (so far) have always been a screw up in one of those two. But I'm only at the simple learning stage myself.
     
  7. ncitizen

    ncitizen Intergalactic Tourist

    Here you go (files are shamlessly ripped from stock outpost panel, refactoring will follow)

    .object:


    Code:
    {
      "objectName" : "EGTkeypad",
      "colonyTags" : ["wired"],
      "rarity" : "Common",
      "description" : "Classic keypad for all your lair protection needs.",
      "shortdescription" : "Keypad Lock",
      "race" : "generic",
    
      "apexDescription" : "A keypad. Keeps people from nosing around.",
      "avianDescription" : "A keypad. Most Avian have little use for these.",
      "floranDescription" : "Floran type rude wordss on keypad. Nothing happenss...",
      "glitchDescription" : "Excited. A keypad, can I crack the code?",
      "humanDescription" : "A keypad! Can I crack the code?",
      "hylotlDescription" : "A keypad. Can be an effective locking device when used correctly.",
      "novakidDescription" : "Does this keypad do anything?",
    
      "category" : "wire",
      "price" : 90,
    
      "inventoryIcon" : "EGTkeypadIcon.png",
      "orientations" : [
        {
          "image" : "EGTkeypad.png:<color>.off",
          "imagePosition" : [-8, -8],
          "direction" : "left",
          "flipImages" : true,
    
          "spaceScan" : 0.1,
          "anchors" : [ "background" ]
        },
        {
          "image" : "EGTkeypad.png:<color>.off",
          "imagePosition" : [-8, -8],
          "direction" : "right",
    
          "spaceScan" : 0.1,
          "anchors" : [ "background" ]
        }
      ],
    
      "scripts" : [ "EGTkeypad.lua" ],
      "scriptDelta" : 5,
    
      "animation" : "EGTkeypad.animation",
    
      "animationParts" : {
        "switch" : "EGTkeypad.png"
      },
      "animationPosition" : [-8, -8],
    
      "interactData" : {
        "config" : "EGTkeypad.config"
      },
    
      "outputNodes" : [ [0, -1] ],
    
      "interval" : 13
    }


    .frames:


    Code:
    {
      "frameGrid" : {
        "size" : [16, 16],
        "dimensions" : [2, 1],
        "names" : [
          [ "default.on", "default.off" ]
        ]
      }
    }
     
  8. slowcold

    slowcold Starship Captain

    Thank you. :) It looks OK to me.

    Two questions - is EGTkeypad.png 32x16? and is the config file in the same directory as the object file? Your "interactData" says it is.

    Other than that, we've hit the end point of my minimal coding abilities.
     
  9. bk3k

    bk3k Black Hole Surfer

    Those sort of errors typically mean you're missing something. I don't know exactly what. I've done some GUI stuff but I don't know them top to bottom such as bare requirements to be a valid GUI.

    You might starting by tweaking an existing GUI and change one thing at a time. Fortunately the GUI you get by interacting(work stations etc) are one thing where file changes take instant effect. Well after closing and opening the GUI. IIRC it wasn't near that convenient when I made my Inventory and hotbar GUIs. Had to /reload all the time.
     
  10. ncitizen

    ncitizen Intergalactic Tourist

    slowcold, yes, assets are fine, i've taken both .frames/.animation and picts from stock outpostKeypad. I also have flat file structure, everything is located right in the mod directory.

    bk3k, well, it seems like my only option. Btw, thanks for hint on immediate effect and /reloading, I used to restart the whole thing, thinking that game reads assets only once:)
     
  11. v6ooo

    v6ooo Cosmic Narwhal

    Lets see if I can cover a bit of everything.

    scriptConsole/Canvas was merged into the already existing scriptPane so it's just one type now.

    Interface .config files that use "paneLayout", found in /interface/windowconfig, are hardcoded in Starbound.
    They are things like crafting windows, merchants, etc. You can't add new custom behavior or buttons, only change the look of existing ones.

    If you're going to make a completely new custom GUI, you should be making a scriptPane and the .config should use "gui" instead of "paneLayout"
    Check interface/scripted/ which are all non-hardcoded GUI that were made in later patches for the game.

    Some paths need to be relative and some need to be full. Background uses full paths e.g. "/interface/mygui/body.png"
     
    bk3k likes this.
  12. claudekennilol

    claudekennilol Cosmic Narwhal

    So you can't do something like adding a search filter to the player's inventory?
     
  13. ncitizen

    ncitizen Intergalactic Tourist

    v6ooo, thank you. Do you known where I can look for prototypes of canvas drawing functions of scriptPane? The game /doc/ doesn't mention anything them.

    ---

    Btw, to make this topic more useful for other people in future: Mannequins seem to be a good example of object with scripted custom GUI. You can find related files by searching in unpacked assets dir.
     

Share This Page