Modding Help Trying to revive DyeMod, need folks with lua knowledge.

Discussion in 'Starbound Modding' started by mastercookie, Feb 16, 2017.

  1. mastercookie

    mastercookie Existential Complex

    me again... basically what the title says. Currently the game runs with dyemod but its gives the error:

    Exception while calling script init: (LuaException) Error code 2, [string "/objects/dyeengine/dyestation/dyestation.lua"]:4: attempt to call a nil value (field 'configParameter')
    stack traceback:
    [C]: in field 'configParameter'
    [string "/objects/dyeengine/dyestation/dyestation.lua"]:4: in function <[string "/objects/dyeengine/dyestation/dyestation.lua"]:1>

    and the line looks like this:

    storage.config = entity.configParameter("dyeEngine")
     
  2. Errors4l

    Errors4l Spaceman Spiff

    I don't know if the object table has a function for it, but this should work: world.getObjectParameter(entity.id(), "dyeEngine")
     
    mastercookie likes this.
  3. mastercookie

    mastercookie Existential Complex

    neat, it shows pop up message now. but still not working, the current error is this:

    [Error] Exception while invoking lua function 'onInteraction'. (LuaException) Error code 2, [string "/objects/dyeengine/scripts/itemConfig.lua"]:18: attempt to call a nil value (field 'itemType')
    stack traceback:
    [C]: in field 'itemType'
    [string "/objects/dyeengine/scripts/itemConfig.lua"]:18: in field 'get'
    [string "/objects/dyeengine/scripts/dyeEngine.lua"]:4: in field 'all'
    [string "/objects/dyeengine/dyestation/dyestation.lua"]:14: in function <[string "/objects/dyeengine/dyestation/dyestation.lua"]:8>

    ill just post the whole things:


    dyeEngine = {}

    function dyeEngine.all(config, itemName)
    local itemConfig = itemConfig.get(config, itemName)
    if not itemConfig.method then return {} end

    local recipes = {}

    for _,color in ipairs(config.colors) do
    recipes = concatTable(recipes, dyeEngine[itemConfig.method](itemName, color, itemConfig))
    end

    return { recipes = recipes, config = itemConfig.windowConfig }
    end


    function dyeEngine.genericRecipe(itemName, color, itemConfig)
    local recipe = {
    input = {
    { item = itemName, count = itemConfig.amount }
    },
    output = {
    item = itemName,
    count = itemConfig.amount
    },
    groups = color.groups
    }

    if not itemConfig.free then
    local dyes = color.dyes or { color.name.."dye" }

    for _,dye in ipairs(dyes) do
    table.insert(recipe.input, dye)
    end
    end

    return recipe
    end




    itemConfig = {}


    function itemConfig.allowed(itemName, itemTypeConfig)
    local whitelist = itemTypeConfig.whitelist or {}
    local blacklist = itemTypeConfig.blacklist or {}

    if (isEmpty(whitelist)
    or inTable(whitelist, itemName))
    and not inTable(blacklist, itemName)
    then
    return true
    end
    end


    function itemConfig.get(config, itemName)
    local itemType = world.itemType(itemName)

    local globalDefault = config.default or {}

    local itemTypeConfig = config[itemType] or {}
    if type(itemTypeConfig) == "string" then
    itemTypeConfig = config[itemTypeConfig]
    end

    if not itemConfig.allowed(itemName, itemTypeConfig) then
    return {}
    end

    local itemDefault = itemTypeConfig.default or {}

    local itemSpecial = (itemTypeConfig.special or {})[itemName] or {}
    if type(itemSpecial) == "string" then
    itemSpecial = (itemTypeConfig.specialSets or {})[itemSpecial] or {}
    end

    local itemConfig = {}

    for k,v in pairs(globalDefault) do
    itemConfig[k] = v
    end
    for k,v in pairs(itemDefault) do
    itemConfig[k] = v
    end
    for k,v in pairs(itemSpecial) do
    itemConfig[k] = v
    end

    return itemConfig
    end




    function init(virtual)
    if virtual then return end
    object.setInteractive(true)
    storage.config = world.getObjectParameter(entity.id(), "dyeEngine")
    end


    function onInteraction(args)
    local itemName = world.entityHandItem(args.sourceId, "primary")
    if not itemName then
    return { "ShowPopup", { message = "I should hold the item that I want to dye." } }
    end

    local interactionConfig = dyeEngine.all(storage.config, itemName)
    interactionConfig.recipes = reverse(interactionConfig.recipes or {})

    if isEmpty(interactionConfig.recipes) then
    return { "ShowPopup", { message = "I can not dye that item." } }
    end

    return {"OpenCraftingInterface", interactionConfig}
    end

     
  4. bk3k

    bk3k Oxygen Tank

    Make sure you have permission before you consider distributing it. Learning from it and making your own is another matter of course. Let me get you started. That must be pre-1.0

    Assuming you have notepad++ or another advanced text editor? I'll give you the notepad++ directions
    <ctrl>+<f>
    click on "find in files" tab
    "find what :"
    Code:
    entity.configParameter
    "replace with :"
    Code:
    config.getParameter
    "directory :"
    whatever folder you have the mod in

    click on "replace in files"

    That will trade out every instance. This is a useful feature but use it carefully(very specific strings only) or you'll accidentally replace something you didn't intend. You can also limit the file type to *.lua

    Something I saved from the "1.0 is coming" thread
    and from 1.2
     
  5. mastercookie

    mastercookie Existential Complex

    we already fixed entity.configParameter, it's itemType error ive no idea what to do with.

    in itemconfig.lua it's this one (i think):

    function itemConfig.get(config, itemName)
    local itemType = world.itemType(itemName)

    in dyeengine.lua:

    function dyeEngine.all(config, itemName)
    local itemConfig = itemConfig.get(config, itemName)
     
  6. mastercookie

    mastercookie Existential Complex

    guys still need help with this. does the whole need total rewrite? from what i can tell not much changed in sb from beta to 1.0, so im hoping its some little things that need to be fixed

    btw im not planning on redistributing the thing
     
  7. Charlatan

    Charlatan Parsec Taste Tester

    To be honest, I think the easiest way would be to re-create the proper recolored objects (only a few of them actually have the proper variants in the .png file), re-create or .patch each of their .frames files.

    I doubt augments can be used on placed objects, so it'd probably be better to create separate furniture-dyes, or a simple tool meant for coloring objects.
    For my part, I think meddling with the M.M. is probably more problematic than just creating a new tool.

    Then, they can probably all use the same .animation file and .lua file using something bk3k recently explained to me.

    At the start of said animation file:
    Code:
    {
      "globalTagDefaults" : {
        "myColor" : "default"
      },
    
    In the animation file under "parts", the image is set up like this:
    Code:
    "image" : "<partImage>.<myColor>.<frame>"
    Finally, the LUA script simply uses "animator.setGlobalTag("myColor", "string")" to set the "myColor" Tag to the color names matching those in the .frames file.
     
  8. mastercookie

    mastercookie Existential Complex

  9. Charlatan

    Charlatan Parsec Taste Tester

    Because the mechanic involved changed a lot with 1.0, that's simply how it is.
     
  10. mastercookie

    mastercookie Existential Complex

    darn it :( then we'd better stick to the tool thing
     
  11. Charlatan

    Charlatan Parsec Taste Tester

    Hold on, I didn't mean to say its all useless ^^

    DyeMod seems to have made use of about every possible way to color things, and I have to say most of it is definitely way above my head.

    What I meant to say is the regular use of dyes as an item has seemingly changed too much to be salvage-able, but the rest should be fine if all LUA errors can be figured out.

    I suppose "world.itemType" was simply replaced, as it doesnt exist in the default game and only in the itemconfig.lua
    When exactly does this error message come up? After all, the mod has many different methods and we need to know which you are trying.
     
    Last edited: Mar 14, 2017
  12. mastercookie

    mastercookie Existential Complex

    i dont think dyes were ever a part of colouring objects (but not 100% sure)
    dyes were used for armors and all that, but objects seemed to be working separately.
    i tried getting rid of the things that dont relate to objects, but ive no idea which script does what (theres like 7 of them)

    on unrelated note, there was a neat feature of changing blocks hue (i think there was 16 or so variants)
     
  13. mastercookie

    mastercookie Existential Complex

    the error message is this:
    [Error] Exception while invoking lua function 'onInteraction'. (LuaException) Error code 2, [string "/objects/dyeengine/scripts/itemConfig.lua"]:18: attempt to call a nil value (field 'itemType')
    stack traceback:
    [C]: in field 'itemType'
    [string "/objects/dyeengine/scripts/itemConfig.lua"]:18: in field 'get'
    [string "/objects/dyeengine/scripts/dyeEngine.lua"]:4: in field 'all'
    [string "/objects/dyeengine/dyestation/dyestation.lua"]:14: in function <[string "/objects/dyeengine/dyestation/dyestation.lua"]:8>

    3rd post from the top
     
  14. Charlatan

    Charlatan Parsec Taste Tester

    I saw, I was wondering when exactly during your attempt to use it, it appears, but I grabbed the mod and brought it to the same state. Anyhow:

    "world.itemType(itemName)" should now be "root.itemType(itemName)" if i'm not mistaken.


    Next error relates to the itemconfig:

    Code:
    [19:02:14.659] [Error] Exception while invoking lua function 'onInteraction'. (LuaException) Error code 2, [string "/objects/dyeengine/scripts/itemConfig.lua"]:20: attempt to index a nil value (local 'config')
    stack traceback:
        [C]: in metamethod '__index'
        [string "/objects/dyeengine/scripts/itemConfig.lua"]:20: in field 'get'
        [string "/objects/dyeengine/scripts/dyeEngine.lua"]:4: in field 'all'
        [string "/objects/dyeengine/dyestation/dyestation.lua"]:14: in function <[string "/objects/dyeengine/dyestation/dyestation.lua"]:8>
     
  15. mastercookie

    mastercookie Existential Complex

    oh u said WHEN... i need to be more attentive.
     
  16. Charlatan

    Charlatan Parsec Taste Tester

    Anyway, once you or others or I figure out more, You can have whatever you need from this tool I'm gonna add to my mod soon:


    It might be a much simpler solution :p
     
    mastercookie likes this.
  17. mastercookie

    mastercookie Existential Complex

    ah this looks yum :nuruhype:

    im pretty hopeless at this, i mean

    [C]: in metamethod '__index'

    what the hell is this?? i remember the old json system used __merge, but it is lua, so i dont even...
     
  18. Charlatan

    Charlatan Parsec Taste Tester

    I'm not good at explaining these things, but __index basically isn't needed here. The error message simply tells us that line 20 failed to get any kind of value it can use - meaning "nil".

    Here's an example from my coloring scripts:

    Code:
    if storage.animstate == nil then storage.animstate = 1 end
    In the Init function - it's pretty self-explanatory. My script checks if storage.animstate exists or not, and if it doesn't, it sets it to 1.
    If I remove this line, it'll give the same error message as above because my Update function immediately tries to use storage.animstate - so right after placing the object, the script errors and gets stuck because there's no storage.animstate.

    In the case of dyemod, some part of the itemconfig and the local variable config is either missing, or it is defined in a wrong way. Unfortunately, I never worked with item configs and item descriptors before so I'd also take time to check through it first.
     
    mastercookie likes this.

Share This Page