
I want to do a simple mod that adds a keybinding to toggle crouch, so that i can ctrl normally and an other key or some situations where i would have to hold crtl for a long period of time.
I'm not familiar with LUA, but this should be simple enough to do with just general programming knowledge and a bit of trial and error. However, i've looked online a bit and i can't find documentation about how the game works, and how to introduce this mechanic. I've looked at the LuaJIT source over here, at the modworkshop wiki and on reddit, but i can't find what i'm looking for.
So far, i've managed to create a leybinding option by looking at some other BLT mods' source, but i'm a bit lost here. I've tried a few things, but nothing succeeded.
My mod.txt looks like this :
{
"name" : "Toggle Crouch",
"keybinds": [
{
"keybind_id": "toggle_crouch",
"name": "Crouch (toggle)",
"script_path": "toggle.lua",
"run_in_menu": false,
"run_in_game": true,
"localized": false
}
]
}
and toggle.lua looks like this :
if alive(managers.player:player_unit()) then
if not managers.player:player_unit().ducking() then
managers.player:player_unit().state:_start_action_ducking(managers.player:player_timer():time())
elseif managers.player:player_unit().ducking() then
managers.player:player_unit().state:_end_action_ducking(managers.player:player_timer():time())
end
end
I would like it if you guys could help me or show me where to find solutions.