Merge pull request #1 from wsor4035/main

new features + bug fix
This commit is contained in:
minefaco 2020-11-05 21:11:16 -05:00 committed by GitHub
commit ee79703cce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 98 additions and 45 deletions

17
.github/workflows/build.yml vendored Normal file

@ -0,0 +1,17 @@
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: apt
run: sudo apt-get install -y luarocks
- name: luacheck install
run: luarocks install --local luacheck
- name: luacheck run
run: $HOME/.luarocks/bin/luacheck ./

23
.luacheckrc Normal file

@ -0,0 +1,23 @@
unused_args = false
allow_defined_top = true
exclude_files = {".luacheckrc"}
globals = {
"minetest",
}
read_globals = {
string = {fields = {"split"}},
table = {fields = {"copy", "getn"}},
-- Builtin
"vector", "ItemStack",
"dump", "DIR_DELIM", "VoxelArea", "Settings",
-- MTG
"default", "sfinv", "creative",
--depends
--none in this case/yet
}

@ -1,2 +1,21 @@
# chisel_tree
# Minetest Chisel_Tree Mod
Adds stripped tree trunks to minetest.
## Links
* [Github](https://github.com/minefaco/chisel_tree)
* [Contentdb](not avaible yet)
* [forums](https://forum.minetest.net/viewtopic.php?p=383571#p383571)
## License
__Code__
by minefacto GPLv3.0
contributed to by wsor4035
__Assets__
> "are the textures GPL-3.0 as well?"
> "no, but it's free to use and share."

@ -1,71 +1,65 @@
--Register nodes
local trunk_names = {
"tree", "jungletree", "aspen_tree", "acacia_tree","pine_tree",
"tree", "jungletree", "aspen_tree", "acacia_tree", "pine_tree",
}
-- Register all trees
-- Register all stripped trees
for _, name in ipairs(trunk_names) do
minetest.register_node(":default:stripped_"..name, {
minetest.register_node(":default:stripped_" .. name, {
description = "Stripped "..name,
tiles = {
"stripped_"..name.."_top.png",
"stripped_"..name.."_top.png",
"stripped_"..name..".png"
},
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, not_in_creative_inventory = 1},
sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir",
on_place = minetest.rotate_node,
})
end
--Register tool
minetest.register_tool("chisel_tree:chisel", {
description = "A chisel for wood",
inventory_image = "chisel.png",
wield_image = "chisel.png",
sound = {breaks = "default_tool_breaks"},
stack_max = 1,
on_use = function(itemstack, user, pointed_thing)
--list of axes to override
local axe_types = {
"wood", "stone", "bronze", "steel", "mese", "diamond",
}
if pointed_thing.type ~= "node" then
return
end
for _, axe_name in ipairs(axe_types) do
local pos = pointed_thing.under
local pname = user:get_player_name()
minetest.override_item("default:axe_" .. axe_name, {
on_place = function(itemstack, user, pointed_thing)
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
return
end
local node = minetest.get_node(pos).name
for _, n in ipairs(trunk_names) do
local tree = "default:"..n
if tree==node then
minetest.swap_node(pos, {name = "default:stripped_"..n})
itemstack:add_wear(65535 / 299) -- 300 uses
return itemstack
if pointed_thing.type ~= "node" then
return
end
end
end,
})
local pos = pointed_thing.under
local pname = user:get_player_name()
--Register craft
if minetest.is_protected(pos, pname) then
minetest.record_protection_violation(pos, pname)
return
end
minetest.register_craft({
output = "chisel_tree:chisel",
recipe = {
{"", "default:steel_ingot", ""},
{"", "group:fence", ""},
}
})
local node = minetest.get_node(pos).name
for _, n in ipairs(trunk_names) do
local tree = "default:"..n
if tree==node then
local old_node = minetest.get_node(pos)
minetest.swap_node(pos, {name = "default:stripped_"..n, param2 = old_node.param2})
itemstack:add_wear(65535 / 299) -- 300 uses
return itemstack
end
end
end,
})
end
--register alias to support old tool
minetest.register_alias("chisel_tree:chisel", "default:axe_steel")