Merge pull request #4 from Thomas--S/headwear

Add headlight and hard hat
master
Joachim Stolberg 2022-05-03 21:05:46 +02:00 committed by GitHub
commit 456eaf047b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 84 additions and 5 deletions

View File

@ -8,9 +8,12 @@ screwdriver
moreblocks?
# License
Copyright (C) 2018 Joachim Stolberg
With contributions from maxx, unknown,...
Copyright (C) 2018-2022 Joachim Stolberg
With contributions from maxx, unknown, Thomas S., ...
Code: Licensed under the GNU LGPL version 2.1 or later. See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
Textures: CC0
Code: Licensed under the GNU LGPL version 2.1 or later. See LICENSE.txt and http://www.gnu.org/licenses/lgpl-2.1.txt
`myblocks_hard_hat.png`, `myblocks_hard_hat_inv.png`, `myblocks_hard_hat_preview.png`, `myblocks_headlight.png`, `myblocks_headlight_inv.png`, `myblocks_headlight_preview.png`: [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/), made by Thomas S.
Other Textures: CC0

72
headwear.lua Normal file
View File

@ -0,0 +1,72 @@
--[[
MyBlocks
Copyright (C) 2018-2022 Joachim Stolberg
Copyright (C) 2022 Thomas S.
LGPLv2.1+
See LICENSE.txt for more information
]]--
armor:register_armor("myblocks:hard_hat", {
description = "Hard Hat",
inventory_image = "myblocks_hard_hat_inv.png",
groups = {armor_head=1, armor_heal=12, armor_use=200},
armor_groups = {fleshy=15},
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
})
armor:register_armor("myblocks:hard_hat_headlight", {
description = "Hard Hat with Headlight",
inventory_image = "myblocks_hard_hat_inv.png^myblocks_headlight_inv.png",
texture = "myblocks_hard_hat.png^myblocks_headlight.png",
preview = "myblocks_hard_hat_preview.png^myblocks_headlight_preview.png",
groups = {armor_head=1, armor_heal=12, armor_use=200},
armor_groups = {fleshy=15},
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
})
armor:register_armor("myblocks:headlight", {
description = "Headlight (to be worn like armor)",
inventory_image = "myblocks_headlight_inv.png",
groups = {armor_head=1, armor_use=200},
armor_groups = {},
damage_groups = {cracky=2, snappy=1, choppy=1, level=3},
})
minetest.register_craft({
output = "myblocks:hard_hat",
recipe = {
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
{ "basic_materials:plastic_sheet", "", "basic_materials:plastic_sheet" },
},
})
minetest.register_craft({
output = "myblocks:hard_hat_headlight",
type = "shapeless",
recipe = { "myblocks:hard_hat", "myblocks:headlight" },
})
minetest.register_craft({
output = "myblocks:headlight",
recipe = {
{ "", "default:mese_crystal", "" },
{ "wool:black", "techage:ta4_leds", "wool:black" },
{ "", "default:mese_crystal", "" },
},
})
wielded_light.register_player_lightstep(function (player)
local items = {}
for _,item in pairs(armor:get_weared_armor_elements(player)) do
items[item] = true
end
if items["myblocks:headlight"] or items["myblocks:hard_hat_headlight"] then
wielded_light.track_user_entity(player, "armor", "default:torch")
else
wielded_light.track_user_entity(player, "armor", "default:stick")
end
end)

View File

@ -684,3 +684,7 @@ dofile(minetest.get_modpath("myblocks") .. "/chains.lua")
dofile(minetest.get_modpath("myblocks") .. "/mypattern.lua")
dofile(minetest.get_modpath("myblocks") .. "/moreblocks.lua")
dofile(minetest.get_modpath("myblocks") .. "/cartdispenser.lua")
if minetest.global_exists("armor") and minetest.global_exists("wielded_light") then
dofile(minetest.get_modpath("myblocks") .. "/headwear.lua")
end

View File

@ -1,4 +1,4 @@
name=myblocks
depends=stairs,techage,tubelib2,moreblocks,carts,sections
optional_depends=armor,bakedclay,fachwerk
optional_depends=armor,bakedclay,fachwerk,wielded_light
description=some more or less useful blocks and tools

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B