Update 'mods/ITEMS/mcl_lanterns/init.lua'

This commit is contained in:
PrairieAstronomer 2022-02-22 18:06:35 +00:00
parent f23fc7c6a1
commit 0ed33b5f45
1 changed files with 191 additions and 32 deletions

View File

@ -1,44 +1,203 @@
local S = minetest.get_translator("mcl_lanterns") local S = minetest.get_translator("mcl_lanterns")
local N = function(s) return s end local modpath = minetest.get_modpath("mcl_lanterns")
minetest.register_node("mcl_lanterns:lantern", { mcl_lanterns = {}
tiles = {
"lantern_top.png", --[[
"lantern_bottom.png", TODO:
"lantern.png", - add lantern specific sounds
"lantern.png", - remove the hack arround walmounted nodes
"lantern.png", ]]
"lantern.png",
}, function mcl_lanterns.register_lantern(name, def)
groups = {pickaxey=3}, local itemstring_floor = "mcl_lanterns:"..name.."_floor"
inventory_image = "lantern.png", local itemstring_ceiling = "mcl_lanterns:"..name.."_ceiling"
light_source = 15,
description = S("Lantern"), local sounds = mcl_sounds.node_sound_metal_defaults()
drawtype = "nodebox",
minetest.register_node(itemstring_floor, {
description = def.description,
_doc_items_longdesc = def.longdesc,
drawtype = "mesh",
mesh = "mcl_lanterns_lantern_floor.obj",
inventory_image = def.texture_inv,
wield_image = def.texture_inv,
tiles = {
{
name = def.texture,
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}
},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
place_param2 = 1,
node_placement_prediction = "",
sunlight_propagates = true,
light_source = def.light_level,
groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1},
selection_box = {
type = "fixed",
fixed = {
{-0.1875, -0.5, -0.1875, 0.1875, -0.0625, 0.1875},
{-0.125, -0.0625, -0.125, 0.125, 0.0625, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, 0.1875, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.1875, -0.5, -0.1875, 0.1875, -0.0625, 0.1875},
{-0.125, -0.0625, -0.125, 0.125, 0.0625, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, 0.1875, 0.0625},
},
},
sounds = sounds,
on_place = function(itemstack, placer, pointed_thing)
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
if new_stack then
return new_stack
end
local under = pointed_thing.under
local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
local fakestack = itemstack
if wdir == 0 then
fakestack:set_name(itemstring_ceiling)
elseif wdir == 1 then
fakestack:set_name(itemstring_floor)
end
local success
itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name(itemstring_floor)
if success then
minetest.sound_play(sounds.place, {pos = under, gain = 1}, true)
end
return itemstack
end,
on_rotate = false,
_mcl_hardness = 3.5,
_mcl_blast_resistance = 3.5,
})
minetest.register_node(itemstring_ceiling, {
description = def.description,
_doc_items_create_entry = false,
drawtype = "mesh",
mesh = "mcl_lanterns_lantern_ceiling.obj",
tiles = {
{
name = def.texture,
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}
},
use_texture_alpha = "clip",
paramtype = "light",
paramtype2 = "wallmounted",
place_param2 = 0,
node_placement_prediction = "",
sunlight_propagates = true,
light_source = def.light_level,
groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1, not_in_creative_inventory = 1},
drop = itemstring_floor,
selection_box = {
type = "fixed",
fixed = {
{-0.1875, 0, -0.1875, 0.1875, 0.4375, 0.1875},
{-0.125, -0.125, -0.125, 0.125, 0, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, -0.125, 0.0625},
},
},
collision_box = {
type = "fixed",
fixed = {
{-0.1875, 0, -0.1875, 0.1875, 0.4375, 0.1875},
{-0.125, -0.125, -0.125, 0.125, 0, 0.125},
{-0.0625, -0.5, -0.0625, 0.0625, -0.125, 0.0625},
},
},
sounds = sounds,
on_rotate = false,
_mcl_hardness = 3.5,
_mcl_blast_resistance = 3.5,
})
end
minetest.register_node("mcl_lanterns:chain", {
description = S("Chain"),
_doc_items_longdesc = S("Chains are metallic decoration blocks."),
inventory_image = "mcl_lanterns_chain_inv.png",
tiles = {"mcl_lanterns_chain.png"},
drawtype = "mesh",
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
_mcl_hardness = 1, use_texture_alpha = "clip",
node_box = { mesh = "mcl_lanterns_chain.obj",
is_ground_content = false,
sunlight_propagates = true,
collision_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.1875, -0.5000, -0.1875, 0.1875, -0.06250, 0.1875}, {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{-0.1250, -0.06250, -0.1250, 0.1250, 0.06250, 0.1250},
{-0.06250, 0.1250, -0.006250, 0.06250, 0.1875, 0.006250},
{-0.06250, 0.06250, -0.006250, -0.03125, 0.1250, 0.006250},
{0.03125, 0.06250, -0.006250, 0.06250, 0.1250, 0.006250},
} }
}, },
stack_max = 64, selection_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
}
},
groups = {pickaxey = 1, deco_block = 1},
sounds = mcl_sounds.node_sound_metal_defaults(),
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
return itemstack
end
local p0 = pointed_thing.under
local p1 = pointed_thing.above
local param2 = 0
local placer_pos = placer:get_pos()
if placer_pos then
local dir = {
x = p1.x - placer_pos.x,
y = p1.y - placer_pos.y,
z = p1.z - placer_pos.z
}
param2 = minetest.dir_to_facedir(dir)
end
if p0.y - 1 == p1.y then
param2 = 20
elseif p0.x - 1 == p1.x then
param2 = 16
elseif p0.x + 1 == p1.x then
param2 = 12
elseif p0.z - 1 == p1.z then
param2 = 8
elseif p0.z + 1 == p1.z then
param2 = 4
end
return minetest.item_place(itemstack, placer, pointed_thing, param2)
end,
_mcl_blast_resistance = 6,
_mcl_hardness = 5,
}) })
minetest.register_craft({ minetest.register_craft({
type = "shaped", output = "mcl_lanterns:chain",
output = "mcl_lanterns:lantern",
recipe = { recipe = {
{"mcl_core:iron_nugget", "mcl_core:iron_nugget","mcl_core:iron_nugget"}, {"mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_core:torch", "mcl_core:iron_nugget"}, {"mcl_core:iron_ingot"},
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"} {"mcl_core:iron_nugget"},
} },
}) })
dofile(modpath.."/register.lua")