From 043d3fe7f11b7cebdbfcc6c5cc17a17bcb80aa97 Mon Sep 17 00:00:00 2001 From: mckayshirou Date: Fri, 4 Aug 2023 17:03:11 -0400 Subject: [PATCH] add support to detect hudbars and check if exits, then provide command * added satation command if mod does not exits and already we have remade mod * added satiation command only if our mod is present --- README.md | 1 + commands.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ depends.txt | 1 + init.lua | 4 ++++ mod.conf | 2 +- 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c0ac6f..ce240fa 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ account at https://vpnapi.io/ and **if not configured, will be used a simple geo | `/geoip ` | geoip | simple ip player info | no matter if geoip mod is present or not | | `/cstats` | moderator | to see latest detected cheater | its not a privilegie, use config settings | | `/cdebug` | moderator | to see even suspected cheats to be verified later | its not a privilegie, use config settings | +| `/satiation` | server | manipulates the satiation of a player | only provide if our mod its present, the original mod already has it | #### privs diff --git a/commands.lua b/commands.lua index fe45cbd..40970f8 100644 --- a/commands.lua +++ b/commands.lua @@ -99,4 +99,46 @@ minetest.register_chatcommand("govip", { --[[ end of commands for geoip and ip location information ]] +--[[ commands for stamina or satiation based on existing mods ]] + +if not governing.modhbhunger then + if governing.modhudbars and not hb.redo then + minetest.register_chatcommand("satiation", { + privs = {["server"]=true}, + params = S("[] "), + description = S("Set satiation of player or yourself"), + func = function(name, param) + if minetest.settings:get_bool("enable_damage") == false then + return false, S("Not possible, damage is disabled.") + end + local targetname, satiation = string.match(param, "(%S+) (%S+)") + if not targetname then + satiation = param + end + satiation = tonumber(satiation) + if not satiation then + return false, S("Invalid satiation!") + end + if not targetname then + targetname = name + end + local target = minetest.get_player_by_name(targetname) + if target == nil then + return false, S("Player @1 does not exist.", targetname) + end + if satiation > hbhunger.SAT_MAX then + satiation = hbhunger.SAT_MAX + elseif satiation < 0 then + satiation = 0 + end + hbhunger.hunger[targetname] = satiation + hbhunger.set_hunger_raw(target) + return true + end, + }) + end +end + +--[[ end commands for stamina or satiation based on existing mods ]] + diff --git a/depends.txt b/depends.txt index bb2b93d..afa6bd8 100644 --- a/depends.txt +++ b/depends.txt @@ -1,3 +1,4 @@ default? mail? boneworld? +hudbars? \ No newline at end of file diff --git a/init.lua b/init.lua index 6fe7392..6b534b4 100644 --- a/init.lua +++ b/init.lua @@ -27,6 +27,8 @@ local modcreative = minetest.get_modpath("creative") -- if creative is available local modantispawn = minetest.get_modpath("antispam") -- if rnd1 anticheat mod is loaded, cos only wolrs with mt4 local modanticheat = minetest.get_modpath("anticheat") -- if rnd1 anticheat mod is loaded, cos only wolrs with mt4 local modbeowulf = minetest.get_modpath("beowulf") -- if rnd1 anticheat mod is loaded, cos only wolrs with mt4 +local modhudbars = minetest.get_modpath("hudbars") -- if the hudbars mod is loaded and working, from wuzzy +local modhbhunger = minetest.get_modpath("hbhunger") -- if the hudbars hunger mod is loaded and working, from wuzzy local checkapikey = minetest.settings:get("governing.checkapikey") or "" -- need for geoip improved ip information, then geoip normal will be used local is_46 = minetest.has_feature("add_entity_with_staticdata") -- detect minetest engine 4.0.16 or mayor @@ -96,6 +98,8 @@ governing.modcommand = modcommand -- if same killme and commands is present as m governing.modantispawn = modantispawn -- autodetect if older mod antispan by appguru are present governing.modanticheat = modanticheat -- if rnd1 anticheat mod is present cos only works with mt4 governing.modbeowulf = modbeowulf -- if beowulf anticheat mod is present cos only works with mt5 +governing.modhudbars = modhudbars -- if hudbars is present or the mproved hudbars redo +governing.modhbhunger = modhbhunger -- if hbhunger is present or the mproved hudbars redo governing.checkapikey = checkapikey -- need for geoip improved ip information, then geoip normal will be used --[[ end - namespace of the mod and varible usages ]] diff --git a/mod.conf b/mod.conf index 37af350..d8da15c 100644 --- a/mod.conf +++ b/mod.conf @@ -1,2 +1,2 @@ name = governing -optional_depends = default, mail, boneworld +optional_depends = default, mail, boneworld, hudbars