Jump to content

Cycling through multiple right-click actions


Recommended Posts

Ice Flingomatic's machine component allows right click actions Turn on/Turn off.

My mod adds another right-click action via other component, with lower priority, so Turn on/Turn off is still the default.

Is is somehow possible to select other action than the default one?

Edited by Muche
Link to comment
Share on other sites

@Muche, well, you can make your action a left click one.

So you get your action, the right click action turn on/off, and the examine action when pressing alt.

 

 

One way is, we make your component have higher priority than the machine one, but require an extra tag.

 

First, give your action higher priority.

Then, make your component action insert the action if the player has the "_extra" tag.

 

Then, in modmain, we allow people to toggle the tag.

local function ToggleExtra(player)	if player:HasTag("_extra") then		player:RemoveTag("_extra")	else		player:AddTag("_extra")	endendAddModRPCHandler(modname, "ToggleFlingo", ToggleExtra)AddSimPostInit(function()	if not GLOBAL.TheNet:IsDedicated() then		GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_H, function()			SendModRPCToServer(MOD_RPC[modname]["ToggleFlingo"])		end)	endend)

By having them send RPCs to the server to tell it to toggle the tag on them.

 

I picked the H key for this.

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