Cyde042 Posted August 21, 2014 Share Posted August 21, 2014 Shortly, a mod that stop food spoiling after being done on a drying rack and in the crock pot. This is what I have.PrefabFiles = { "meatrack","cookpot",}function NoSpoil_Rack(inst) if inst.components.dryer and inst.components.dryer.spoiltask then inst.components.dryer.spoiltask:Cancel() inst.components.dryer.spoiltask = nil -- inst.components.dryer.spoiltargettime = nil endendfunction NoSpoil_Pot(inst) if inst.components.stewer and inst.components.stewer.spoiltask then inst.components.stewer.spoiltask:Cancel() inst.components.stewer.spoiltask = nil endendAddPrefabPostInit("meatrack", NoSpoil_Rack)AddPrefabPostInit("cookpot", NoSpoil_Pot)Can anyone help? Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/ Share on other sites More sharing options...
Mobbstar Posted August 21, 2014 Share Posted August 21, 2014 What did you do wrong here? Maybe you need to set a periodic task? Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525253 Share on other sites More sharing options...
Cyde042 Posted August 21, 2014 Author Share Posted August 21, 2014 What did you do wrong here? Maybe you need to set a periodic task? Why would I need a periodic task? I need a set it and forget it approach. What I think I need to do is add custom onload,onsave,ondoncecooking and oncontinuedone. What I'm trying to do now is make the the component(stewer) use a custom local function based on the one present in the cookpot prefab, but the issue is, that function is referencing other local functions leading me eventually into an error. I mean. I want to make inst.components.stewer.ondonecooking = custom_function. But first I need to copy the original function, but that leads into many other missing functions. And it ends with me having to load the cooking.lua script from the modmain, and I have no idea how to do that. I put a copy of it in the scripts folder of the mod, and wrote a require line, and it still gives me an error. Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525338 Share on other sites More sharing options...
plaidman Posted August 21, 2014 Share Posted August 21, 2014 You shouldn't need a require line if you put a copy of the stewer component in your scripts directory. If you upload a copy of your mod, I can try to take a look at the code. Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525388 Share on other sites More sharing options...
Maris Posted August 22, 2014 Share Posted August 22, 2014 function NoSpoil_Pot(inst) if inst.components.stewer then inst.components.stewer.onspoil = nil local oldFunc = inst.components.stewer.Harvest inst.components.stewer.Harvest = function(inst, harvester) inst.targettime = GetTime() --make it cooked just now oldFunc(inst, harvester) end end end Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525716 Share on other sites More sharing options...
Cyde042 Posted August 22, 2014 Author Share Posted August 22, 2014 You shouldn't need a require line if you put a copy of the stewer component in your scripts directory. If you upload a copy of your mod, I can try to take a look at the code. http://www.filedropper.com/nostewerspoilage A copy of cooking.lua not stewer. What I want to do is to override "inst.components.stewer.ondonecooking = donecookfn". The current state of the mod (that's uploaded) will result in a crash because of the local functions. Ignore the custom components, those are a backup plan. Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525720 Share on other sites More sharing options...
Cyde042 Posted August 22, 2014 Author Share Posted August 22, 2014 function NoSpoil_Pot(inst) if inst.components.stewer then inst.components.stewer.onspoil = nil local oldFunc = inst.components.stewer.Harvest inst.components.stewer.Harvest = function(inst, harvester) inst.targettime = GetTime() --make it cooked just now oldFunc(inst, harvester) end endend Crashes, GetTime isn't defined. Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525728 Share on other sites More sharing options...
Maris Posted August 22, 2014 Share Posted August 22, 2014 Sure it is not, bacause it's in global space. I was hoping you could fix any little things that I missed. function NoSpoil_Pot(inst) if inst.components.stewer then inst.components.stewer.onspoil = nil local oldFunc = inst.components.stewer.Harvest inst.components.stewer.Harvest = function(inst, harvester) inst.targettime = GLOBAL.GetTime() --make it cooked just now oldFunc(inst, harvester) end endend Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-525731 Share on other sites More sharing options...
Cyde042 Posted August 25, 2014 Author Share Posted August 25, 2014 Sure it is not, bacause it's in global space. I was hoping you could fix any little things that I missed. function NoSpoil_Pot(inst) if inst.components.stewer then inst.components.stewer.onspoil = nil local oldFunc = inst.components.stewer.Harvest inst.components.stewer.Harvest = function(inst, harvester) inst.targettime = GLOBAL.GetTime() --make it cooked just now oldFunc(inst, harvester) end endend Well, besides the character saying "I can't do that" after harvesting, it works. But when I tried applying the same principle to the Rack, I can't even harvest it, it goes into the animation and then says "I can't do that". This is what I have.function NoSpoil_Rack(inst) if inst.components.dryer then inst.components.dryer.spoiltask = nil local Function = inst.components.dryer:Harvest inst.components.dryer:Harvest = function(inst, harvester) inst.targettime = GLOBAL.GetTime() Function(inst, harvester) end endend Link to comment https://forums.kleientertainment.com/forums/topic/39602-helpwhat-did-i-wrong-here/#findComment-526941 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now