Adds freeze mode and fixes logging

This commit is contained in:
AliasAlreadyTaken 2024-07-13 21:03:34 +02:00
parent 64c5ef73c0
commit 3d6d4923e6
5 changed files with 26 additions and 12 deletions

View File

@ -1,12 +1,13 @@
# License
Copyright (c) 2024 Developername, Styxcolor
Copyright (c) 2024 AliasAlreadyTaken, Styxcolor
Code:
* [MIT](https://gitea.your-land.de/your-land/yl_canned_food/src/LICENSE-MIT) Developername
* [MIT](https://gitea.your-land.de/your-land/yl_canned_food/src/LICENSE-MIT) AliasAlreadyTaken
Media:
* screenshot.png [CC0](https://gitea.your-land.de/your-land/yl_canned_food/src/LICENSE-CC0) Styxcolor
*

View File

@ -28,6 +28,11 @@ yl_canned_food.debug = false
```
Set to true to enable debug mode
```
yl_canned_food.freeze = false
```
Set to true to prevent the nodes from changing into the next stage
```
yl_canned_food.legacy = false
```

View File

@ -5,6 +5,8 @@ yl_canned_food.settings = {}
yl_canned_food.settings.debug = minetest.settings:get_bool("yl_canned_food.debug",false)
yl_canned_food.settings.freeze = minetest.settings:get_bool("yl_canned_food.freeze",false)
yl_canned_food.settings.legacy = minetest.settings:get_bool("yl_canned_food.legacy",false)
yl_canned_food.settings.duration = minetest.settings:get("yl_canned_food.duration") or 600

View File

@ -1,15 +1,15 @@
-- log
--
local function log(text)
local logmessage = yl_api_nodestages.t("log_prefix",
yl_api_nodestages.modname, text)
if (yl_api_nodestages.settings.debug == true) then
local logmessage = yl_canned_food.t("log_prefix",
yl_canned_food.modname, text)
if (yl_canned_food.settings.debug == true) then
minetest.log("action", logmessage)
end
return logmessage
end
function yl_api_nodestages.log(text) return log(text) end
function yl_canned_food.log(text) return log(text) end
-- get_node_definition
--
@ -37,6 +37,7 @@ end
function yl_canned_food.get_node_definition() return get_node_definition() end
local function can_set(pos)
if (yl_canned_food.settings.freeze == true) then return false end
local light = minetest.get_node_light(pos)
if (light and light > 5) then return false end
return true
@ -73,12 +74,12 @@ local function register_food(itemstring, itemdesc, origin)
yl_api_nodestages.register_stages(stages)
if (success == false) then
yl_api_nodestages.log("action", "item = " .. dump(itemstring[1]))
yl_api_nodestages.log("action", "success = " .. dump(success))
yl_api_nodestages.log("action", "good = " .. dump(good))
yl_api_nodestages.log("action", "bad = " .. dump(bad))
yl_api_nodestages.log("action", "total = " .. dump(total))
yl_api_nodestages.log("action", "reasons = " .. dump(reasons))
yl_canned_food.log("action", "item = " .. dump(itemstring[1]))
yl_canned_food.log("action", "success = " .. dump(success))
yl_canned_food.log("action", "good = " .. dump(good))
yl_canned_food.log("action", "bad = " .. dump(bad))
yl_canned_food.log("action", "total = " .. dump(total))
yl_canned_food.log("action", "reasons = " .. dump(reasons))
return false
end

View File

@ -5,6 +5,11 @@
# Optional, default is false
yl_canned_food.debug (Debug mode) bool false
# Freeze mode
# Set this to true to enable freeze mode, which will prevent the nodes from changing into their next_stages
# Optional, default is false
yl_canned_food.freeze (Freeze mode) bool false
# Enables legacy naming mode
# Set to true if you need drop-in replacement for canned_food. Set to false if you want uniform naming
# Optional, default false