forked from Mirrorlandia_minetest/mod-sneeker
Use settings to determine spawn chance, frequency, level, & light requirements
This commit is contained in:
parent
7ca26b4105
commit
7edfb6cb9b
29
README.md
29
README.md
@ -14,6 +14,35 @@ An explosive nuisance for [Minetest](http://minetest.net/).
|
||||
- Original by Rui: WTFPL
|
||||
- tnt_function code: [MIT](tnt_function.lua)
|
||||
|
||||
---
|
||||
### Usage:
|
||||
|
||||
Settings:
|
||||
- ***sneeker.spawn_chance***
|
||||
- Sets possibility for spawn.
|
||||
- type: int
|
||||
- default: 10000
|
||||
- ***sneeker.spawn_interval***
|
||||
- Sets frequency of spawn chance.
|
||||
- type: int
|
||||
- default: 240 (4 minutes)
|
||||
- ***sneeker.spawn_minlight***
|
||||
- Sets the minimum light that a node must have for spawn to occur.
|
||||
- type: int
|
||||
- default: 0
|
||||
- ***sneeker.spawn_maxlight***
|
||||
- Sets the maximum light that a node can have for spawn to occur.
|
||||
- type: int
|
||||
- default: 9
|
||||
- ***sneeker.spawn_minheight***
|
||||
- Sets the maximum light that a node can have for spawn to occur.
|
||||
- type: int
|
||||
- default: -31000
|
||||
- ***sneeker.spawn_maxheight***
|
||||
- Sets the lowest position at which sneeker can spawn.
|
||||
- type: int
|
||||
- default 31000
|
||||
|
||||
---
|
||||
### Links:
|
||||
|
||||
|
13
init.lua
13
init.lua
@ -1,8 +1,17 @@
|
||||
|
||||
sneeker = {}
|
||||
sneeker.modname = core.get_current_modname()
|
||||
sneeker.modpath = core.get_modpath(sneeker.modname)
|
||||
|
||||
dofile(minetest.get_modpath("sneeker").."/tnt_function.lua")
|
||||
dofile(minetest.get_modpath("sneeker").."/spawn.lua")
|
||||
local scripts = {
|
||||
"settings",
|
||||
"tnt_function",
|
||||
"spawn",
|
||||
}
|
||||
|
||||
for _, script in ipairs(scripts) do
|
||||
dofile(sneeker.modpath .. "/" .. script .. ".lua")
|
||||
end
|
||||
|
||||
|
||||
local function jump(self, pos, direction)
|
||||
|
46
settings.lua
Normal file
46
settings.lua
Normal file
@ -0,0 +1,46 @@
|
||||
-- Settings for sneeker mod
|
||||
|
||||
|
||||
local time_min = 60
|
||||
|
||||
--- Sets possibility for spawn.
|
||||
--
|
||||
-- Inverted value (e.g. 10000 = 1/10000).
|
||||
--
|
||||
-- @setting sneeker.spawn_chance
|
||||
sneeker.spawn_chance = tonumber(core.settings:get("sneeker.spawn_chance") or 10000)
|
||||
|
||||
--- Sets frequency of spawn chance.
|
||||
--
|
||||
-- Default 240 is equivalent to 4 minutes (60 * 4).
|
||||
--
|
||||
-- @setting sneeker.spawn_interval
|
||||
sneeker.spawn_interval = tonumber(core.settings:get("sneeker.spawn_interval") or time_min * 4)
|
||||
|
||||
--- Sets the minimum light that a node must have for spawn to occur.
|
||||
--
|
||||
-- Default: 0
|
||||
--
|
||||
-- @setting sneeker.spawn_minlight
|
||||
sneeker.spawn_minlight = tonumber(core.settings:get("sneeker.spawn_minlight") or 0)
|
||||
|
||||
--- Sets the maximum light that a node can have for spawn to occur.
|
||||
--
|
||||
-- Default: 4
|
||||
--
|
||||
-- @setting sneeker.spawn_maxlight
|
||||
sneeker.spawn_maxlight = tonumber(core.settings:get("sneeker.spawn_maxlight") or 4)
|
||||
|
||||
--- Sets the lowest position at which sneeker can spawn.
|
||||
--
|
||||
-- Default: -31000
|
||||
--
|
||||
-- @setting sneeker.spawn_minheight
|
||||
sneeker.spawn_minheight = tonumber(core.settings:get("sneeker.spawn_minheight") or -31000)
|
||||
|
||||
--- Sets the highest position at which sneeker can spawn.
|
||||
--
|
||||
-- Default: 31000
|
||||
--
|
||||
-- @setting sneeker.spawn_maxheight
|
||||
sneeker.spawn_maxheight = tonumber(core.settings:get("sneeker.spawn_maxheight") or 31000)
|
20
settingtypes.txt
Normal file
20
settingtypes.txt
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
# Sets possibility for spawn.
|
||||
#
|
||||
# Rate is the inverted value (e.g. 1/value).
|
||||
sneeker.spawn_chance (Sneeker spawn chance) int 10000
|
||||
|
||||
# Sets frequency of spawn chance. Default 240 is equivalent to 4 minutes (60 * 4).
|
||||
sneeker.spawn_interval (Sneeker spawn interval) int 240
|
||||
|
||||
# Sets the minimum light that a node must have for spawn to occur.
|
||||
sneeker.spawn_minlight (Sneeker min light for spawn) int 0
|
||||
|
||||
# Sets the maximum light that a node can have for spawn to occur.
|
||||
sneeker.spawn_maxlight (Sneeker max light for spawn) int 4
|
||||
|
||||
# Sets the lowest position at which sneeker can spawn.
|
||||
sneeker.spawn_minheight (Sneeker min spawn height) int -31000
|
||||
|
||||
# Sets the highest position at which sneeker can spawn.
|
||||
sneeker.spawn_maxheight (Sneeker max spawn height) int 31000
|
28
spawn.lua
28
spawn.lua
@ -12,32 +12,32 @@ end
|
||||
core.register_abm({
|
||||
nodenames = spawn_nodes,
|
||||
neighbors = {"air"},
|
||||
interval = 30,
|
||||
chance = 9000,
|
||||
interval = sneeker.spawn_interval,
|
||||
chance = sneeker.spawn_chance,
|
||||
action = function(pos, node, _, active_object_count_wider)
|
||||
if active_object_count_wider > 5 then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if not core.get_node_light(pos) then
|
||||
|
||||
if pos.y > sneeker.spawn_maxheight then
|
||||
return
|
||||
end
|
||||
if core.get_node_light(pos) > 5 then
|
||||
if pos.y < sneeker.spawn_minheight then
|
||||
return
|
||||
end
|
||||
if core.get_node_light(pos) < -1 then
|
||||
|
||||
-- needs two vertical air nodes to spawn
|
||||
for _, node_pos in ipairs({pos, {x=pos.x, y=pos.y+1, z=pos.z}}) do
|
||||
if core.get_node(node_pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
if pos.y > 31000 then
|
||||
return
|
||||
end
|
||||
if core.get_node(pos).name ~= "air" then
|
||||
return
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if core.get_node(pos).name ~= "air" then
|
||||
end
|
||||
|
||||
local llevel = core.get_node_light(pos)
|
||||
if not llevel or llevel > sneeker.spawn_maxlight or llevel < sneeker.spawn_minlight then
|
||||
return
|
||||
end
|
||||
|
||||
core.add_entity(pos, "sneeker:sneeker")
|
||||
end
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user