Jump to content

DoLongAction Replace


Recommended Posts

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

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 by Stormish
Link to comment
Share on other sites

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

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

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

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
 Share

×
  • Create New...