2023-12-03 20:44:29 +01:00
|
|
|
controls = {
|
2023-12-03 20:51:55 +01:00
|
|
|
--util values
|
2023-12-03 20:44:29 +01:00
|
|
|
modpath = minetest.get_modpath("controls"),
|
2023-12-03 20:51:55 +01:00
|
|
|
testsmode = minetest.settings:get_bool("controls_enable_tests", false),
|
|
|
|
|
|
|
|
--location to store callbacks
|
|
|
|
registered_on_press = {},
|
|
|
|
registered_on_hold = {},
|
|
|
|
registered_on_release = {},
|
2023-12-03 20:44:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
--api functions
|
|
|
|
function controls.register_on_press(callback)
|
2023-12-03 20:51:55 +01:00
|
|
|
table.insert(controls.registered_on_press, callback)
|
2023-12-03 20:44:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function controls.register_on_hold(callback)
|
2023-12-03 20:51:55 +01:00
|
|
|
table.insert(controls.registered_on_hold, callback)
|
2023-12-03 20:44:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function controls.register_on_release(callback)
|
2023-12-03 20:51:55 +01:00
|
|
|
table.insert(controls.registered_on_release, callback)
|
2023-12-03 20:44:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if(controls.testsmode) then
|
|
|
|
dofile(controls.modpath .. "/test.lua")
|
|
|
|
end
|