controls/init.lua

27 lines
701 B
Lua
Raw Normal View History

2023-12-03 20:44:29 +01:00
controls = {
--util values
2023-12-03 20:44:29 +01:00
modpath = minetest.get_modpath("controls"),
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)
table.insert(controls.registered_on_press, callback)
2023-12-03 20:44:29 +01:00
end
function controls.register_on_hold(callback)
table.insert(controls.registered_on_hold, callback)
2023-12-03 20:44:29 +01:00
end
function controls.register_on_release(callback)
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