generated from your-land/yl_template
Allows configuration of maximum light level and chance
This commit is contained in:
parent
37f86a2264
commit
5823a9df6d
12
README.md
12
README.md
@ -45,6 +45,18 @@ yl_canned_food.duration = 600
|
||||
|
||||
Set this to a time in seconds. This time is necessary to go from the first to the second stage.
|
||||
|
||||
```
|
||||
yl_canned_food.max_light = 5
|
||||
```
|
||||
|
||||
Set this to a light level beetween 0 and 15. This time is the maximum light level the position may have to allow the first stage go to the second stage. A max_light of 5 means, that a position which receives 0 to 5 light can switch stage, while a position that receives 6 to 15 light cannot.
|
||||
|
||||
```
|
||||
yl_canned_food.chance = 33
|
||||
```
|
||||
|
||||
Set this to a number in percent between 0 and 100. This is the chance to go from the first to the second stage. 33 means, one in three will go to the next stage, the remaining restart their timer.
|
||||
|
||||
## Usage
|
||||
|
||||
This mod can be used in singleplayer and multiplayer. It comes with the canned food items, but no crafting recipes. To get those, install the integration mod for your game. The minetest_game integration is here: [yl_canned_food_mtg](https://gitea.your-land.de/your-land/yl_canned_food_mtg)
|
||||
|
||||
@ -10,3 +10,7 @@ yl_canned_food.settings.freeze = minetest.settings:get_bool("yl_canned_food.free
|
||||
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
|
||||
|
||||
yl_canned_food.settings.max_light = minetest.settings:get("yl_canned_food.max_light") or 5
|
||||
|
||||
yl_canned_food.settings.chance = minetest.settings:get("yl_canned_food.chance") or 33
|
||||
32
internal.lua
32
internal.lua
@ -1,8 +1,8 @@
|
||||
-- log
|
||||
--
|
||||
local function log(text)
|
||||
local logmessage = yl_canned_food.t("log_prefix",
|
||||
yl_canned_food.modname, text)
|
||||
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
|
||||
@ -31,18 +31,20 @@ local function get_node_definition(additonal_values)
|
||||
vessel = 1
|
||||
}
|
||||
}
|
||||
for k,v in pairs(additonal_values) do
|
||||
t[k] = v
|
||||
end
|
||||
for k, v in pairs(additonal_values) do t[k] = v end
|
||||
return t
|
||||
end
|
||||
|
||||
function yl_canned_food.get_node_definition(additonal_values) return get_node_definition(additonal_values) end
|
||||
function yl_canned_food.get_node_definition(additonal_values)
|
||||
return get_node_definition(additonal_values)
|
||||
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
|
||||
local roll = math.random() * 100
|
||||
if ((light and (light > yl_canned_food.settings.max_light)) or
|
||||
(roll > yl_canned_food.settings.chance)) then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
@ -57,11 +59,19 @@ local function register_food(itemstring, itemdesc, origin)
|
||||
|
||||
table.insert(stages, {
|
||||
stage_name = origin .. ":" .. itemstring[1],
|
||||
next_stages = origin .. ":" .. itemstring[2],
|
||||
-- next_stages = origin .. ":" .. itemstring[2],
|
||||
next_stages = {
|
||||
{
|
||||
origin .. ":" .. itemstring[2], 1,
|
||||
{can_set = yl_canned_food.can_set}, nil
|
||||
}
|
||||
},
|
||||
duration = tonumber(yl_canned_food.settings.duration) or 600,
|
||||
tiles = {"yl_canned_food_" .. itemstring[1] .. ".png"},
|
||||
description = itemdesc[1],
|
||||
node_definition = yl_canned_food.get_node_definition({inventory_image = "yl_canned_food_" .. itemstring[1] .. ".png"}),
|
||||
node_definition = yl_canned_food.get_node_definition({
|
||||
inventory_image = "yl_canned_food_" .. itemstring[1] .. ".png"
|
||||
}),
|
||||
overwrite = false,
|
||||
restart = true
|
||||
})
|
||||
@ -70,7 +80,9 @@ local function register_food(itemstring, itemdesc, origin)
|
||||
stage_name = origin .. ":" .. itemstring[2],
|
||||
tiles = {"yl_canned_food_" .. itemstring[2] .. ".png"},
|
||||
description = itemdesc[2],
|
||||
node_definition = yl_canned_food.get_node_definition({inventory_image = "yl_canned_food_" .. itemstring[2] .. ".png"}),
|
||||
node_definition = yl_canned_food.get_node_definition({
|
||||
inventory_image = "yl_canned_food_" .. itemstring[2] .. ".png"
|
||||
})
|
||||
})
|
||||
|
||||
local success, good, bad, total, reasons =
|
||||
|
||||
@ -19,3 +19,13 @@ yl_canned_food.legacy (Enables legacy naming mode) bool false
|
||||
# Set this to a time in seconds. This time is necessary to go from the first to the second stage.
|
||||
# Optional, default 600
|
||||
yl_canned_food.duration (Duration) float 600 1
|
||||
|
||||
# Maximum light
|
||||
# Set this to a light level between 0 and 15, above which the canned_food cannot enter second stage.
|
||||
# Optional, default 5
|
||||
yl_canned_food.max_light (Maximum light) int 5 0 15
|
||||
|
||||
# Chance
|
||||
# Set this to a chance in percent. Example: chance of 33 means one in three will go to the next stage, the remaining restart their timer.
|
||||
# Optional, default 33
|
||||
yl_canned_food.chance (Chance) float 33 1 100
|
||||
|
||||
Loading…
Reference in New Issue
Block a user