Jump to content

Action Disabling


Recommended Posts

I'm looking into disabling every action the player can do except maybe Examine(not really that important but wouldnt mind it) I tried inst:ShowActions(false), but it only does half the job, which is just hiding them, the player can still press SPACE to interact with things.

Link to comment
Share on other sites

@Aquaterion I'd refer to Woodie's action changes on his beavermode transformation. So I think this would do the trick:

inst.components.playercontroller.actionbuttonoverride = function() end
inst.components.playeractionpicker.leftclickoverride = function(inst, target)
	--Copied and edited from PlayerActionPicker:GetLeftClickActions
	if inst.components.playercontroller:IsControlPressed(CONTROL_FORCE_INSPECT) and
	target:HasTag("inspectable") and
	(inst.CanExamine == nil or inst:CanExamine()) and
	(inst.sg == nil or inst.sg:HasStateTag("moving") or inst.sg:HasStateTag("idle")) and
	(inst:HasTag("moving") or inst:HasTag("idle")) then
		return inst.components.playeractionpicker:SortActionList({ ACTIONS.LOOKAT }, target, nil)
	end
end
inst.components.playeractionpicker.rightclickoverride = function() end

And if you want to remove examination you could just give the leftclickoverride a function stub like the others.

Do you also want to disable attacks, though? I think that would require something more.

Edited by rezecib
Link to comment
Share on other sites

41 minutes ago, rezecib said:

@Aquaterion I'd refer to Woodie's action changes on his beavermode transformation. So I think this would do the trick:


inst.components.playercontroller.actionbuttonoverride = function() end
inst.components.playercontroller.leftclickoverride = function(inst, target)
	--Copied and edited from PlayerActionPicker:GetLeftClickActions
	if inst.components.playercontroller:IsControlPressed(CONTROL_FORCE_INSPECT) and
	target:HasTag("inspectable") and
	(inst.CanExamine == nil or inst:CanExamine()) and
	(inst.sg == nil or inst.sg:HasStateTag("moving") or inst.sg:HasStateTag("idle")) and
	(inst:HasTag("moving") or inst:HasTag("idle")) then
		return inst.components.playeractionpicker:SortActionList({ ACTIONS.LOOKAT }, target, nil)
	end
end
inst.components.playercontroller.rightclickoverride = function() end

And if you want to remove examination you could just give the leftclickoverride a function stub like the others.

hmm I see, I got it to work combining with ShowActions, cant examine things but that's fine. Thanks for the help!

Link to comment
Share on other sites

5 minutes ago, rezecib said:

@Aquaterion I made a mistake in the first version I posted-- for the leftclick and rightclick overrides, it needs to be the playeractionpicker component. That should enable examination, although ShowActions might be screwing that up if you keep it.

yea showactions hides them, but makes them still usable via space, removing showactions and doing

inst.components.playercontroller.actionbuttonoverride = function() end                                                                                                           inst.components.playeractionpicker.leftclickoverride = function() end
inst.components.playeractionpicker.rightclickoverride = function() end


fixes the "usable via space" issue, but covers examine too.

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...