Modding Help quick question about lua `config` usage

Discussion in 'Starbound Modding' started by olsonpm, Dec 3, 2017.

  1. olsonpm

    olsonpm Void-Bound Voyager

    I'm a developer, extremely new to modding in general but have been impressed by the documentation thus far.

    One thing I can't seem to find is how `config.getParameter` knows what file to search for.

    For instance in `tech/dash/blinkdash.lua` `config.getParameter("blinkOutTime")` refers to the file `tech/dash/blinkdash.tech`. However in most other files it refers to its own file basename with an extension of `config`.

    And instead of directly answering the above question, please explain what resources I should have found to solve this on my own - assuming any exist.

    I appreciate your time,
    Phil
     
  2. bk3k

    bk3k Oxygen Tank

    Scripts environments are attached to something... That something defines what scripts it uses.

    config.getParameter looks for the JSON key present in that thing.
     
  3. olsonpm

    olsonpm Void-Bound Voyager

    so you're saying I would need the source code to determine how exactly that "thing" is loaded
     
  4. bk3k

    bk3k Oxygen Tank

    No I mean every entity has their own environment, and Their own JSON properties. That function pulls information from the JSON properties belonging to that entity.

    Possibly I'm not understanding the question if that doesn't answer it.
     
  5. olsonpm

    olsonpm Void-Bound Voyager

    No worries - your responses helped. I'll try to ask a clearer question next time.
     
  6. slowcold

    slowcold Pangalactic Porcupine

    Yes. And no. :p

    Look at the log file - as the game loads all of the asset IDs - both vanilla game and mods - get put into a set of databases (and the game freaks out if you have two items named the same, as it can't cope). The lua for whatever looks at the database to see where it needs to go to get what it actually needs.
     
  7. olsonpm

    olsonpm Void-Bound Voyager

    Ah I had only looked at the log file for debugging a crash thus far. Thanks so much for pointing me in that direction.
     
  8. bk3k

    bk3k Oxygen Tank

    I probably should clear up something though. The file is relevant because that's the source of the JSON properties, but you have things like object.setConfigParameter to change the JSON attributes of an object. This will not change the file itself and only affects the object. Consider that objects support this in their JSON
    Code:
    "retainObjectParametersInItem" : true,
    Also other things can also be created with custom properties - which aren't present or have been changed from the original file itself. config.getParameter() handles this perfectly. It doesn't merely load from the file, but it also considers custom parameters and (in the case of objects) things like which orientation is selected. Note that the attributes from "orientations" will be treated as though they where merged into the root level, and only one set would be selected. config.getParameter() handles the retrieval of these attributes that way. So don't think of it as accessing a file, but accessing an attribute belonging to the current entity.
     
  9. olsonpm

    olsonpm Void-Bound Voyager

    @bk3k - makes a lot of sense. I appreciate the explanation. (I've been away for a while due to unfun real life - getting back at this tonight)
     

Share This Page