mirror of
https://github.com/mt-mods/controls.git
synced 2024-11-30 18:33:43 +01:00
add intial api layout and a test mode
This commit is contained in:
parent
a56de07635
commit
6b32442368
@ -7,7 +7,7 @@ globals = {
|
||||
"minetest", "core",
|
||||
|
||||
--mod provided
|
||||
|
||||
"controls",
|
||||
}
|
||||
|
||||
read_globals = {
|
||||
|
21
init.lua
21
init.lua
@ -0,0 +1,21 @@
|
||||
controls = {
|
||||
modpath = minetest.get_modpath("controls"),
|
||||
testsmode = minetest.settings:get_bool("controls_enable_tests", false)
|
||||
}
|
||||
|
||||
--api functions
|
||||
function controls.register_on_press(callback)
|
||||
|
||||
end
|
||||
|
||||
function controls.register_on_hold(callback)
|
||||
|
||||
end
|
||||
|
||||
function controls.register_on_release(callback)
|
||||
|
||||
end
|
||||
|
||||
if(controls.testsmode) then
|
||||
dofile(controls.modpath .. "/test.lua")
|
||||
end
|
1
settingtypes.txt
Normal file
1
settingtypes.txt
Normal file
@ -0,0 +1 @@
|
||||
controls_enable_tests (enable testing mode for player controls) bool false
|
11
test.lua
Normal file
11
test.lua
Normal file
@ -0,0 +1,11 @@
|
||||
controls.register_on_press(function(player, key)
|
||||
minetest.chat_send_all(player:get_player_name() .. " pressed " .. key)
|
||||
end)
|
||||
|
||||
controls.register_on_hold(function(player, key, length)
|
||||
minetest.chat_send_all(player:get_player_name() .. " held " .. key .. " for " .. length .. " seconds")
|
||||
end)
|
||||
|
||||
controls.register_on_release(function(player, key, length)
|
||||
minetest.chat_send_all(player:get_player_name() .. " released " .. key .. " after " .. length .. " seconds")
|
||||
end)
|
Loading…
Reference in New Issue
Block a user