Compare commits

...

1 Commits

Author SHA1 Message Date
Li0n 73789dd741 add settings 1
to do: make it actually work
2022-02-25 20:27:10 +01:00
2 changed files with 31 additions and 2 deletions

View File

@ -12,16 +12,23 @@
-- move python program to a different directory -- move python program to a different directory
-- chat mode: trigger from specific words written by either yourself (humiliation) or others (degradation) -- chat mode: trigger from specific words written by either yourself (humiliation) or others (degradation)
local rumble_strength_max_standard = minetest.settings:get("rumble_strength_max_setting")
local rumble_duration_max_standard = minetest.settings:get("rumble_duration_max_setting")
local rumble_duration_max
local rumble_strength_max
-- step 1 (start) -- step 1 (start)
minetest.register_on_mods_loaded(function() minetest.register_on_mods_loaded(function()
minetest.display_chat_message("rumble mod loaded. May the rumble be with you!") minetest.display_chat_message("rumble mod loaded. May the rumble be with you!")
rumble_duration_max = rumble_strength_max_standard
rumble_strength_max = rumble_duration_max_standard
end) end)
-- step 2 (take damage) -- step 2 (take damage)
minetest.register_on_damage_taken(function(hp) minetest.register_on_damage_taken(function(hp)
local rumble_strength_max = 0.5
local rumble_strength = math.min( hp/20, rumble_strength_max ) local rumble_strength = math.min( hp/20, rumble_strength_max )
local rumble_duration_max = 5
local rumble_duration = math.min( hp, rumble_duration_max ) local rumble_duration = math.min( hp, rumble_duration_max )
minetest.log("action", "[rumble] ".."queue "..rumble_strength.." "..rumble_duration) minetest.log("action", "[rumble] ".."queue "..rumble_strength.." "..rumble_duration)
minetest.display_chat_message("[rumble] ".."queue "..rumble_strength.." "..rumble_duration) minetest.display_chat_message("[rumble] ".."queue "..rumble_strength.." "..rumble_duration)
@ -36,3 +43,20 @@ end)
minetest.register_on_shutdown(function() minetest.register_on_shutdown(function()
minetest.log("action", "[rumble] instant 0 0") minetest.log("action", "[rumble] instant 0 0")
end) end)
-- step 5 (commands)
minetest.register_chatcommand("set_strength_max", {
description = "set max rumble strength (between 0 and 1)",
func = function(text)
rumble_strength_max = (text)
minetest.display_chat_message(rumble_strength_max)
end,
})
minetest.register_chatcommand("set_duration_max", {
description = "set max rumble duration (in seconds)",
func = function(text)
rumble_duration_max = (text)
minetest.display_chat_message(rumble_duration_max)
end,
})

5
settingtypes.txt Normal file
View File

@ -0,0 +1,5 @@
# Sets the max rumble strength. 0 is off and 1 is full strength.
rumble_strength_max_setting (max rumble strength) int 0 0.5 1
# Sets the max rumble duration in seconds.
rumble_strength_max_setting (max rumble strength) int 0 5