Modding Help Object with slots, fill slots with certain items, it then delivers/creates new items.

Discussion in 'Starbound Modding' started by FrAndromeda, Sep 20, 2016.

  1. FrAndromeda

    FrAndromeda Subatomic Cosmonaut

    Hello,

    I'm trying to create an object that:
    - Has a number of slots that only take certain items in certain amounts.
    - If these prerequisites are fulfilled, the objects creates a limited set of items (from a treasurepool) a at a limited set of time intervals and amounts. If not, the object doesn't do anything.
    - Has another number of slots where these items can be taken from.
    - You can walk away from the item and it will do it's thing (so it has some storage capabilities for the ingredients).
    - It may play an animation.

    I haven't been able to find an example in the original Starbound files, does anyone know of something that's similar to this? Perhaps a simplified version that I can study from? I think I remember a coffee maker from the outpost set doing something like this (two slots, only took coffee beans, result was coffee) but it doesn't seem to have a lua file to look at from what I can tell.

    Thanks in advance for any help!
     
  2. Mirau

    Mirau Pangalactic Porcupine

    I've tried to duplicate this with parameters for a small project I'm working on. This is what I've figured out so far:


    • "category" : "crafting",
    • "objectType" : "container",
    • "recipeGroup" : "FrAndromedaMod",
    • "slotCount" : 3,
    • "uiConfig" : "/interface/objectcrafting/FrAndromedaMod.config",



    • {
    • "input" : [
    • { "item" : "FirstRequiredItem", "count" : 1},
    • { "item" : "SecondRequiredItem", "count": 1}
    • ],
    • "output" : { "count": 1,"name": "NewlyCreatedItem"},
    • "groups" : [ "FrAndromedaMod" ],
    • "duration" : 2
    • }


    Check out ../interface/objectcrafting/refinery.config for a base to use as the uiConfig. It will determine how the container window UI looks - and the refinery.config has slots for only 2 items (the input and the output item) so you would just need to add a second input slot. Of course you would want to change the text to fit your mod as well. :)
     
    FrAndromeda likes this.
  3. FrAndromeda

    FrAndromeda Subatomic Cosmonaut

    That is some incredibly useful information, thank you, Mirau! I'll mess with this a bit and report back :)
     
    Mirau likes this.
  4. bk3k

    bk3k Oxygen Tank

    I think you're gonna need to learn some LUA. I'm not going to teach you LUA, but many tutorials exist. But tutorials never quite clicked in for me, so I found it more useful to read and manipulate actual code. Anyhow... from within the base starbound directory check out /doc/lua/world.md

    There is some documentation listing functions - many of which enable you to scan and manipulate the contents of containers. But it may be more useful to unpack the game's assets - into a different folder or you'll get errors - and check out these sort of functions in actual use. But there's so much to look through! So let me help you narrow it down.
    1. Download Notepad++ if you don't already have it.
    2. Play around with the settings to your liking. I recommend at the very least enabling bracket highlighting to help you keep track of what bracket matches what other bracket. Also the line numbers, etc.
    3. Open some file in it. Honestly it doesn't matter for what we're going to do.
    4. <CTRL> + <F> to open the search window(standard hotkeys for any program with search). Up top is a tab for Find in Files and that's exactly what we want.
    5. Change the directory to whatever directory you unpacked the game assets.
    6. In Find what we're going to search for world.containerItems - for example.
    7. Be patient until the search is complete. The search would indeed be faster if you can narrow it down. For example searching only within /objects/
    8. The results will be on a new pane towards the bottom of the screen. It will show you the text you are searching for on the line it is found. Double left clicking will open the file in question. So do that, and observe how the code is used in action.

    I find this to be more helpful in many cases than the documentation. Now the documentation is also helpful too, but seeing examples of the code being used is more useful. Especially once you see it being used in different ways from different scripts you start to see the range of use. Obviously it would be MORE useful to read the source code, but that isn't happening!
     
    The | Suit and FrAndromeda like this.
  5. FrAndromeda

    FrAndromeda Subatomic Cosmonaut

    Hi Scruffy, yes you're right, I need to look at more LUA documents.
    I've made some progress by looking at the refinery from in game, have made a copy of it, a simple recolor, and have changed the ui graphics and added some slots but of course it crashes if I use them so I need to look at it some more. But I've found LUA files in Frackin' universe (specifically the Hydrophonics tray) that gets very close to what I want to do, and I have taken a good look. It seems like I'm very close to being able to make something simple of my own. I have also looked at the LUA API documentation provided under 'docs' and it's getting clearer and clearer how LUA 'does it's thing'. Now I need better grasp of LUA itself so I understand how to do things properly.
    I feel much closer to being able to do something like this than I did last week. So thanks to both you and Mirau :) I will keep you up to date!
     
  6. bk3k

    bk3k Oxygen Tank

    At a point when I was looking into LUA, I was reading this thing that only taught me about LUA 5.1 and much of that is outdated. Starbound uses LUA 5.3. Also worth noting is that it isn't a pure LUA environment but LUA embedded in C++ and we have no access to the C++ code.

    http://www.lua.org/manual/5.3/manual.html#pdf-load

    But note that some things are disabled. load() isn't there. Most the os calls aren't there. I know this is to prevent malicious code and all that, but it will certainly require some creative solutions at times.
     
    FrAndromeda likes this.
  7. FrAndromeda

    FrAndromeda Subatomic Cosmonaut

    Thanks for the heads-up, bk3k, I'll keep that in mind! I'll check out that link a.s.a.p.

    Also, look at what I found... http://community.playstarbound.com/threads/some-lua-help-please-and-thank-you.93371/

    This could be super useful to get breeding done! I still have to find out whether this author ever published their stuff, and how, so that I don't make a super similar mod for nothing.

    Edit: They followed through and the mod is freakin' adorable! Chickensssss!
     
    Last edited: Sep 25, 2016

Share This Page