sapscaffold: add small sapling scaffold CSM
This commit is contained in:
parent
7e23013727
commit
5eddb0f02a
@ -31,3 +31,4 @@ load_mod_autodupe = true
|
||||
load_mod_randomscreenshot = true
|
||||
load_mod_util = true
|
||||
load_mod_cheats = true
|
||||
load_mod_sapscaffold = true
|
||||
|
70
clientmods/sapscaffold/init.lua
Normal file
70
clientmods/sapscaffold/init.lua
Normal file
@ -0,0 +1,70 @@
|
||||
local function find_swap(items)
|
||||
for i, v in ipairs(items) do
|
||||
local n = minetest.find_item(v)
|
||||
if n then
|
||||
minetest.localplayer:set_wield_index(n - 1)
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function in_list(val, list)
|
||||
for i, v in ipairs(list) do
|
||||
if v == val then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function nilify_node(node)
|
||||
if node and node.name == "air" then
|
||||
return nil
|
||||
end
|
||||
return node
|
||||
end
|
||||
|
||||
local dirt = {
|
||||
"mcl_core:dirt",
|
||||
"mcl_core:dirt_with_grass"
|
||||
}
|
||||
|
||||
local saplings = {
|
||||
"mcl_core:sapling",
|
||||
"mcl_core:darksapling",
|
||||
"mcl_core:junglesapling",
|
||||
"mcl_core:sprucesapling",
|
||||
"mcl_core:birchsapling",
|
||||
"mcl_core:acaciasapling"
|
||||
}
|
||||
|
||||
local function sapper()
|
||||
local lp = minetest.localplayer:get_pos()
|
||||
local below = vector.add(lp, {x = 0, y = -1, z = 0})
|
||||
local node_here = nilify_node(minetest.get_node_or_nil(lp))
|
||||
local node_under = nilify_node(minetest.get_node_or_nil(below))
|
||||
|
||||
-- if theres a node below its prob bad but its good if its dirt
|
||||
if node_under and not in_list(node_under.name, dirt) then
|
||||
return
|
||||
end
|
||||
|
||||
if not node_under and find_swap(dirt) then
|
||||
minetest.place_node(below)
|
||||
end
|
||||
|
||||
if not node_here and find_swap(saplings) then
|
||||
minetest.place_node(lp)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_globalstep(function()
|
||||
if minetest.settings:get_bool("scaffold_saplings") then
|
||||
sapper()
|
||||
end
|
||||
end)
|
||||
|
||||
if minetest.register_cheat then
|
||||
minetest.register_cheat("SapScaffold", "World", "scaffold_saplings")
|
||||
end
|
1
clientmods/sapscaffold/settingtypes.txt
Normal file
1
clientmods/sapscaffold/settingtypes.txt
Normal file
@ -0,0 +1 @@
|
||||
sapling_scaffold (Scaffold with saplings and dirt) bool false
|
Loading…
x
Reference in New Issue
Block a user