Well-met Posted March 31, 2019 Share Posted March 31, 2019 hi I'm trying to mod a thing for my character. Essentially I want it so anytime a "dolongaction" is called, it should do "doshortaction" instead. If this proves to be impossible, I'd just want to have ActionHandler(ACTIONS.HARVEST) use the doshortaction instead of dolongaction. I don't really know if I got to mess with wilson's stategraph, or do some addprefrabpostinit thingie? Many times I've been fiddling with stuff pointlessly when it just comes down to 1 simple line. help Link to comment Share on other sites More sharing options...
Stormish Posted March 31, 2019 Share Posted March 31, 2019 (edited) Hi. Here's the code for making your character harvest stuff quick. Spoiler local function MakeCharacter_HarvestQuick(inst) local _harvesthandler = inst.actionhandlers[GLOBAL.ACTIONS.HARVEST].deststate inst.actionhandlers[GLOBAL.ACTIONS.HARVEST].deststate = function(inst, ...) if inst.prefab == "charactername" then return "doshortaction" end return _harvesthandler(inst, ...) end end AddStategraphPostInit("wilson", function(inst) MakeCharacter_HarvestQuick(inst) end) AddStategraphPostInit("wilson_client", function(inst) MakeCharacter_HarvestQuick(inst) end) Just change "charactername" in the 4th line with your character's prefab name and put the code in modmain.lua and you're done. Edited March 31, 2019 by Stormish Link to comment Share on other sites More sharing options...
Well-met Posted March 31, 2019 Author Share Posted March 31, 2019 thank you very much sir Link to comment Share on other sites More sharing options...
Well-met Posted March 31, 2019 Author Share Posted March 31, 2019 1 hour ago, Stormish said: Hi. Here's the code for making your character harvest stuff quick. Hide contents local function MakeCharacter_HarvestQuick(inst) local _harvesthandler = inst.actionhandlers[GLOBAL.ACTIONS.HARVEST].deststate inst.actionhandlers[GLOBAL.ACTIONS.HARVEST].deststate = function(inst, ...) if inst.prefab == "charactername" then return "doshortaction" end return _harvesthandler(inst, ...) end end AddStategraphPostInit("wilson", function(inst) MakeCharacter_HarvestQuick(inst) end) AddStategraphPostInit("wilson_client", function(inst) MakeCharacter_HarvestQuick(inst) end) Just change "charactername" in the 4th line with your character's prefab name and put the code in modmain.lua and you're done. sorry to bother but this does not appear to work. I've put all 3 in the modmain and changed charname but it's still the dolongaction when I pick a grass tuft or a sapling. Am I meant to put something in the character.lua? Or make a function to run MakeCharacter_HarvestQuick? Link to comment Share on other sites More sharing options...
Ultroman Posted March 31, 2019 Share Posted March 31, 2019 The two calls to AddStategraphPostInit already call MakeCharacter_HarvestQuick. Nothing more needs to happen. Please attach your modmain.lua to a reply, otherwise we can't see what's going on. Maybe also your character's lua. Link to comment Share on other sites More sharing options...
Well-met Posted March 31, 2019 Author Share Posted March 31, 2019 modmain.lua Link to comment Share on other sites More sharing options...
Ultroman Posted March 31, 2019 Share Posted March 31, 2019 That looks correct, assuming the prefab name of your character is "melium". Time to break out the print-statements to see what gets called and what doesn't. Link to comment Share on other sites More sharing options...
Stormish Posted April 1, 2019 Share Posted April 1, 2019 16 hours ago, Hell-met said: sorry to bother but this does not appear to work. I've put all 3 in the modmain and changed charname but it's still the dolongaction when I pick a grass tuft or a sapling. Am I meant to put something in the character.lua? Or make a function to run MakeCharacter_HarvestQuick? The code I gave you only makes it easier for your character to harvest stuff quick. (Harvesting crops, foods from crock pots, drying racks etc.) If you want to make your character be able to pick saplings and other pickable items fast, then here's the code for this too. (replace the function and the postinits with the following code) Code: Spoiler local function MakeCharacter_PickAndHarvestQuick(inst) local _harvesthandler = inst.actionhandlers[GLOBAL.ACTIONS.HARVEST].deststate inst.actionhandlers[GLOBAL.ACTIONS.HARVEST].deststate = function(inst, ...) if inst.prefab == "melium" then return "doshortaction" end return _harvesthandler(inst, ...) end local _pickhandler = inst.actionhandlers[GLOBAL.ACTIONS.PICK].deststate inst.actionhandlers[GLOBAL.ACTIONS.PICK].deststate = function(inst, ...) if inst.prefab == "melium" then return "doshortaction" end return _pickhandler(inst, ...) end end AddStategraphPostInit("wilson", function(inst) MakeCharacter_PickAndHarvestQuick(inst) end) AddStategraphPostInit("wilson_client", function(inst) MakeCharacter_PickAndHarvestQuick(inst) end) Link to comment Share on other sites More sharing options...
Well-met Posted April 1, 2019 Author Share Posted April 1, 2019 oh haha. Sorry about that, just me not knowing about the actionhandlers. works great! thank you Link to comment Share on other sites More sharing options...
Stormish Posted April 1, 2019 Share Posted April 1, 2019 Just now, Hell-met said: oh haha. Sorry about that, just me not knowing about the actionhandlers. works great! thank you I am always glad to be of service! Link to comment 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