Adding new iuse functions to a mod?

Is there any way to add a simple “toggle” function to an item? Something like “activate to turn on, activate to turn off, no batteries required”? I’ve added the “use_action” : “turnon” and “use_action” : “turnoff” to the melee.json, I have added this to the item_actions.json:

“type” : “item_action”,
“name” : “Turn off”
“type” : “item_action”,
“name” : “Turn on”


but I think that I need some hardcoding to put it together. Can somebody more geacky than me help?

dont know how chainsaws work, but if all you want is a trainsforming weapon you only need a useaction: transform in the item raw.

you xould get kinky and have more than 2 states even. each state (off, on, hi, etc) would be its own item with its own fuel consumption rate and damage output. but id imagine theres some kind of special effect youre after.

for my own, iuse is next on my list of stuff to play with so id like to know too

My friend pisskop, nobody helped but I have figured it out. Maybe you will make some use of it. I consulted this:

Look for use_action

and made this:

[ { "id": "chainsword_off", "type": "TOOL", "symbol": "/", "color": "red", "name": "chainsword (off)", "name_plural": "chainswords (off)", "description": "This is MK.xf Hell's Teeth pattern chainsword, a sword with motorized teeth used in close combat. It is off.", "price": 8000, "material": ["steel", "plastic"], "techniques": "SWEEP", "weight": 6577, "volume": 10, "bashing": 10, "to_hit": 0, "flags" : ["DURABLE_MELEE"], "use_action": { "type": "transform", "target": "chainsword_on", "active": true, "msg": "You turn the chainsword on! Gut them! For the Emperor!", "moves" : 500 } }, { "id": "chainsword_on", "type": "TOOL", "symbol": "/", "color": "red", "name": "chainsword (on)", "name_plural": "chainswords (on)", "description": "This chainsword is running, its atomic motor whirring noisily and its teeth ready to bite into the enemies of the Emperor. Use it to turn it off.", "price": 8000, "material": ["steel", "plastic"], "techniques": "SWEEP", "weight": 6577, "volume": 10, "cutting": 120, "flags" : ["CHOP", "MESSY", "DURABLE_MELEE"], "qualities": [["AXE", 3],["BUTCHER", 100],["CUT", 3]], "use_action": { "type": "transform", "target": "chainsword_off", "active": true, "msg": "You turn the chainsword off.", "moves" : 1 } } ]

It works quite fine, but I still need to attach a strap on it to make it more faithful to the canon.