Jump to content

Recommended Posts

I am trying to create a relatively simple mod that allows you to insert items with durability such as tools or armor into a science machine and get components back based on the durability they have (each item passing a percent chance to get back check using the percent durability minus a little to make it less overpowered)

this is my first mod, and as i was instructed i looked at various other mods that seem to have similar function as well as base game code, and after several hours i compiled what i thought would be an easy first test, that would simply give back the full recipe cost back from putting anything with durability into the science machine, regaurdless of durability.

unfortunately when i start don't starve and go to the modlist, it says "Crashed!" even before i attempt to enable it! after i attempt to enable it and click apply, it goes unresponsive and i am forced to close it. just looking at the code for a few more hours, i cant think of something that might be wrong with it. 

anything at all would be appreciated.

My Modmain is as follows

local function recycleengine(prefab)
    prefab:AddComponent("trader")
    
    prefab.components.trader:SetAcceptTest(function(prefab, item)
        
        if not item.finiteuses then
            return false
        end
        return true
    end)
    
    prefab.components.trader.onaccept = function(prefab, giver, item)
        if item.components.finiteuses then
                prefab.components.prototyper.onactivate()
                prefab:DoTaskInTime(1.5, function() 
                        prefab.components.lootdropper:SpawnLootPrefab("recipe.ingredients")
                    end
                end)
            end
        end
    end
    
end
AddPrefabPostInit("researchlab", recycleengine)

 

      

Link to comment
https://forums.kleientertainment.com/forums/topic/69051-simple-recycling/
Share on other sites

Don't despair, use the log.txt to gain additional information on the crash:

The indent part (that means with empty space to the left) is the "traceback", the line above should say exactly when and why the game crashed.

Edited by Mobbstar

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...