LUA example:
- Code: Select all
minetest.register_key({
key = 'C',
function = do_c()
})
minetest.register_key({
key = 'C',
function = do_c()
})
TriBlade9 wrote:I love the idea (and have wanted it for ages), but the problem is quite simply that everything runs on the server. A packet would have to be sent for every keypress, which is just nope.
*ahem*someone hurry up and write a system for client-side scripts*ahem*
Zeno wrote:I'm not positive that a packet would have to be sent for *every* keypress. I.e. the client could be told upon connection what a key is bound to and just send a packet if that key is pressed.
Kenney wrote:LUA example:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_key({
key = 'C',
function = do_c()
})
Calinou wrote:This has two problems:
- How do you handle keyboard layouts other than QWERTY?
- How do you let the client change that key, especially if they already use that key for something like movement?
I would rather have more “special” keys (special2, special3, special4 would be a good start), which the client can configure.
minetest.register_action("mymod:myaction", function(player)
-- Example callback
-- player = player who sent the action
kill_player(player)
end)
-- This binding is sent to the client
minetest.register_keybind("mymod:myaction", {
default_key = "X",
description = "Suicide"
})
thetoon wrote:Zeno wrote:I'm not positive that a packet would have to be sent for *every* keypress. I.e. the client could be told upon connection what a key is bound to and just send a packet if that key is pressed.
It has to send on every keypress, as long as scripts are server-side only (IIRC, keypresses are sent no matter what, and server decides what to do with them).
(IIRC, keypresses are sent no matter what, and server decides what to do with them).
Users browsing this forum: No registered users and 5 guests