[(Client)Mod] Event on Key Press [keyevent]
- Desour
- Member
- Posts: 1469
- Joined: Thu Jun 19, 2014 19:49
- GitHub: Desour
- IRC: Desour
- In-game: DS
- Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
[(Client)Mod] Event on Key Press [keyevent]
Keyevent
Adds an event for when player presses a key.
Look into README.md for more information.
This mod can be used as mod and as clientmod.
License: CC0
Download
Github
Adds an event for when player presses a key.
Look into README.md for more information.
This mod can be used as mod and as clientmod.
License: CC0
Download
Github
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)
- GreenXenith
- Member
- Posts: 1356
- Joined: Wed Oct 28, 2015 01:26
- GitHub: GreenXenith
- Location: UTC-8:00
- Contact:
Re: [(Client)Mod] Event on Key Press [keyevent]
So... this allows for key events... but does it also allow for custom mouse clicks?
YouTube | Mods | Patreon | Minetest Discord @greenxenith
You should not be able to read this message.
You should not be able to read this message.
- Desour
- Member
- Posts: 1469
- Joined: Thu Jun 19, 2014 19:49
- GitHub: Desour
- IRC: Desour
- In-game: DS
- Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
Re: [(Client)Mod] Event on Key Press [keyevent]
It uses player:get_player_control_bits(). I'm not sure what you mean with custom mouse clicks.GreenDimond wrote:So... this allows for key events... but does it also allow for custom mouse clicks?
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)
- GreenXenith
- Member
- Posts: 1356
- Joined: Wed Oct 28, 2015 01:26
- GitHub: GreenXenith
- Location: UTC-8:00
- Contact:
Re: [(Client)Mod] Event on Key Press [keyevent]
Like if the player uses the middle-mouse-button on a node or a side button or something can you make actions happen?
YouTube | Mods | Patreon | Minetest Discord @greenxenith
You should not be able to read this message.
You should not be able to read this message.
Re: [(Client)Mod] Event on Key Press [keyevent]
Hi !!
Do you have a small example how to use the keyevent.register_on_keypress_bits() function?
Thank you !! :D
Do you have a small example how to use the keyevent.register_on_keypress_bits() function?
Thank you !! :D
- Desour
- Member
- Posts: 1469
- Joined: Thu Jun 19, 2014 19:49
- GitHub: Desour
- IRC: Desour
- In-game: DS
- Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
Re: [(Client)Mod] Event on Key Press [keyevent]
It don't think this is possible with the api.GreenDimond wrote:Like if the player uses the middle-mouse-button on a node or a side button or something can you make actions happen?
@Nekrofage: Sure.
Client-side:
Code: Select all
keyevent.register_on_keypress_bits(function(keys, old_keys, dtime)
minetest.display_chat_message(keys)
end)
Code: Select all
keyevent.register_on_keypress(function(keys, old_keys, dtime, player_name)
local t = {s = {}, b = {}}
for k, v in pairs(keys) do
if v ~= old_keys[k] then
local bs = (v and "b") or "s"
t[bs][#t[bs]+1] = k
end
end
local msg = player_name.." stopped pressing "
for i = 1, #t.s do
msg = msg..t.s[i]..", "
end
msg = msg:sub(1, -3).."and began pressing "
for i = 1, #t.b do
msg = msg..t.b[i]..", "
end
msg = msg:sub(1, -3).."."
minetest.chat_send_all(msg)
end)
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)
- Desour
- Member
- Posts: 1469
- Joined: Thu Jun 19, 2014 19:49
- GitHub: Desour
- IRC: Desour
- In-game: DS
- Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
Re: [(Client)Mod] Event on Key Press [keyevent]
Update:
You can now set a filter if you want the events not for all keys but specific ones.
You can now set a filter if you want the events not for all keys but specific ones.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)
Re: [(Client)Mod] Event on Key Press [keyevent]
Hi DS !
In the example code, for the 'keyevent.register_on_keypress_bits()' method, I have this error:
attempt to index global 'keyevent' (a nil value)
Do you have informations about this error?
Thank you !
In the example code, for the 'keyevent.register_on_keypress_bits()' method, I have this error:
attempt to index global 'keyevent' (a nil value)
Do you have informations about this error?
Thank you !
- Desour
- Member
- Posts: 1469
- Joined: Thu Jun 19, 2014 19:49
- GitHub: Desour
- IRC: Desour
- In-game: DS
- Location: I'm scared that if this is too exact, I will be unable to use my keyboard.
Re: [(Client)Mod] Event on Key Press [keyevent]
Since you took the csm example, it's most likely that you forgot to activate the mod in clientmods/mods.conf.Nekrofage wrote:Hi DS !
In the example code, for the 'keyevent.register_on_keypress_bits()' method, I have this error:
attempt to index global 'keyevent' (a nil value)
Do you have informations about this error?
Thank you !
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)
Who is online
Users browsing this forum: No registered users and 0 guests