1
0
Fork 0

add lanterns, crafts, placement mechanism, doc entries

This commit is contained in:
AFCMS 2022-02-08 22:56:20 +01:00
parent ffa9d2d0fd
commit 6572a8c908
11 changed files with 205 additions and 43 deletions

View File

@ -3,27 +3,39 @@ local modpath = minetest.get_modpath("mcl_lanterns")
mcl_lanterns = {} mcl_lanterns = {}
--[[
TODO:
- add lantern specific sounds
- remove the hack arround walmounted nodes
]]
function mcl_lanterns.register_lantern(name, def) function mcl_lanterns.register_lantern(name, def)
local itemstring_floor = "mcl_lanterns:"..name.."_floor" local itemstring_floor = "mcl_lanterns:"..name.."_floor"
local itemstring_ceiling = "mcl_lanterns:"..name.."_ceiling" local itemstring_ceiling = "mcl_lanterns:"..name.."_ceiling"
local sounds = mcl_sounds.node_sound_metal_defaults()
minetest.register_node(itemstring_floor, { minetest.register_node(itemstring_floor, {
description = def.description, description = def.description,
_doc_items_longdesc = def.longdesc,
drawtype = "mesh", drawtype = "mesh",
mesh = "mcl_lanterns_lantern_floor.obj", mesh = "mcl_lanterns_lantern_floor.obj",
inventory_image = def.texture_inv, inventory_image = def.texture_inv,
wield_image = def.texture_inv, wield_image = def.texture_inv,
tiles = {{ tiles = {
{
name = def.texture, name = def.texture,
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}}, }
},
use_texture_alpha = "clip", use_texture_alpha = "clip",
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
place_param2 = 1,
node_placement_prediction = "",
sunlight_propagates = true, sunlight_propagates = true,
light_source = def.light_level, light_source = def.light_level,
groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1}, groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1},
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
@ -40,19 +52,16 @@ function mcl_lanterns.register_lantern(name, def)
{-0.0625, -0.5, -0.0625, 0.0625, 0.1875, 0.0625}, {-0.0625, -0.5, -0.0625, 0.0625, 0.1875, 0.0625},
}, },
}, },
--sounds = default.node_sound_wood_defaults(), sounds = sounds,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local under = pointed_thing.under local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
local node = minetest.get_node(under) if new_stack then
local def = minetest.registered_nodes[node.name] return new_stack
if def and def.on_rightclick and
not (placer and placer:is_player() and
placer:get_player_control().sneak) then
return def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack
end end
local under = pointed_thing.under
local above = pointed_thing.above local above = pointed_thing.above
local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above)) local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
local fakestack = itemstack local fakestack = itemstack
if wdir == 0 then if wdir == 0 then
@ -61,38 +70,61 @@ function mcl_lanterns.register_lantern(name, def)
fakestack:set_name(itemstring_floor) fakestack:set_name(itemstring_floor)
end end
itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir) local success
itemstack, success = minetest.item_place(fakestack, placer, pointed_thing, wdir)
itemstack:set_name(itemstring_floor) itemstack:set_name(itemstring_floor)
if success then
minetest.sound_play(sounds.place, {pos = under, gain = 1}, true)
end
return itemstack return itemstack
end, end,
--floodable = true, on_rotate = false,
--on_flood = on_flood, _mcl_hardness = 3.5,
on_rotate = false _mcl_blast_resistance = 3.5,
}) })
minetest.register_node(itemstring_ceiling, { minetest.register_node(itemstring_ceiling, {
description = def.description,
_doc_items_create_entry = false,
drawtype = "mesh", drawtype = "mesh",
mesh = "mcl_lanterns_lantern_floor.obj", mesh = "mcl_lanterns_lantern_ceiling.obj",
tiles = {{ tiles = {
{
name = def.texture, name = def.texture,
animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
}}, }
},
use_texture_alpha = "clip", use_texture_alpha = "clip",
paramtype = "light", paramtype = "light",
paramtype2 = "wallmounted", paramtype2 = "wallmounted",
place_param2 = 0,
node_placement_prediction = "",
sunlight_propagates = true, sunlight_propagates = true,
light_source = def.light_level, light_source = def.light_level,
groups = {dig_immediate=3, not_in_creative_inventory=1}, groups = {pickaxey = 1, attached_node = 1, deco_block = 1, lantern = 1, not_in_creative_inventory = 1},
drop = itemstring_floor, drop = itemstring_floor,
selection_box = { selection_box = {
type = "wallmounted", type = "fixed",
wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8}, 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 = default.node_sound_wood_defaults(), collision_box = {
--floodable = true, type = "fixed",
--on_flood = on_flood, fixed = {
on_rotate = false {-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 end
@ -121,6 +153,7 @@ minetest.register_node("mcl_lanterns:chain", {
} }
}, },
groups = {pickaxey = 1, deco_block = 1}, groups = {pickaxey = 1, deco_block = 1},
sounds = mcl_sounds.node_sound_metal_defaults(),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then if pointed_thing.type ~= "node" then
return itemstack return itemstack
@ -158,4 +191,13 @@ minetest.register_node("mcl_lanterns:chain", {
_mcl_hardness = 5, _mcl_hardness = 5,
}) })
minetest.register_craft({
output = "mcl_lanterns:chain",
recipe = {
{"mcl_core:iron_nugget"},
{"mcl_core:iron_ingot"},
{"mcl_core:iron_nugget"},
},
})
dofile(modpath.."/register.lua") dofile(modpath.."/register.lua")

View File

@ -1,6 +1,6 @@
name = mcl_lanterns name = mcl_lanterns
description = Add lanterns and chains to MineClone2 description = Add lanterns and chains to MineClone2
depends = depends = mcl_sounds
optional_depends = optional_depends =
author = AFCMS author = AFCMS
title = MineClone2 Lanterns title = MineClone2 Lanterns

View File

@ -0,0 +1,104 @@
# Blender v3.0.1 OBJ File: 'lantern.blend'
# www.blender.org
o Lantern_Ceiling
v 0.187500 -0.000000 0.187500
v 0.187500 0.437500 0.187500
v 0.187500 0.000000 -0.187500
v 0.187500 0.437500 -0.187500
v -0.187500 -0.000000 0.187500
v -0.187500 0.437500 0.187500
v -0.187500 0.000000 -0.187500
v -0.187500 0.437500 -0.187500
v 0.125000 -0.125000 0.125000
v 0.125000 -0.000000 0.125000
v 0.125000 -0.125000 -0.125000
v 0.125000 0.000000 -0.125000
v -0.125000 -0.125000 0.125000
v -0.125000 -0.000000 0.125000
v -0.125000 -0.125000 -0.125000
v -0.125000 0.000000 -0.125000
v 0.066291 -0.500000 -0.066291
v 0.066291 -0.125000 -0.066291
v -0.066291 -0.500000 0.066291
v -0.066291 -0.125000 0.066291
v -0.066291 -0.500000 -0.066291
v -0.066291 -0.125000 -0.066291
v 0.066291 -0.500000 0.066291
v 0.066291 -0.125000 0.066291
vt 0.000000 0.062500
vt 0.375000 0.062500
vt 0.375000 0.437500
vt 0.000000 0.437500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt -0.000000 0.437500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt 0.000000 0.437500
vt 0.000000 0.062500
vt 0.375000 0.062500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt 0.000000 0.437500
vt 0.375000 0.437500
vt 0.375000 0.875000
vt -0.000000 0.875000
vt -0.000000 0.437500
vt 0.062500 0.125000
vt 0.312500 0.125000
vt 0.312500 0.375000
vt 0.062500 0.375000
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.500000 0.770833
vt 0.500000 0.770833
vt 0.500000 0.770833
vt 0.500000 0.770833
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.312500 0.875000
vt 0.312500 1.000000
vt 0.062500 1.000000
vt 0.062500 0.875000
vt 0.687500 0.625000
vt 0.687500 0.250000
vt 0.875000 0.250000
vt 0.875000 0.625000
vt 0.687500 1.000000
vt 0.687500 0.625000
vt 0.875000 0.625000
vt 0.875000 1.000000
vn 0.0000 -1.0000 -0.0000
vn 0.0000 0.0000 -1.0000
vn -1.0000 -0.0000 0.0000
vn 0.0000 1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 -0.0000 1.0000
vn 0.7071 -0.0000 0.7071
vn 0.7071 0.0000 -0.7071
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/9/3 7/10/3 5/11/3 6/12/3
f 6/13/4 2/14/4 4/5/4 8/8/4
f 2/15/5 1/16/5 3/17/5 4/18/5
f 6/19/6 5/20/6 1/21/6 2/22/6
f 9/23/1 13/24/1 15/25/1 11/26/1
f 12/27/2 11/28/2 15/29/2 16/30/2
f 16/31/3 15/32/3 13/33/3 14/34/3
f 14/35/4 10/36/4 12/37/4 16/38/4
f 10/39/5 9/40/5 11/41/5 12/42/5
f 14/43/6 13/44/6 9/45/6 10/46/6
f 17/47/7 18/48/7 20/49/7 19/50/7
f 21/51/8 22/52/8 24/53/8 23/54/8

View File

@ -1,6 +1,6 @@
# Blender v3.0.1 OBJ File: 'lantern.blend' # Blender v3.0.1 OBJ File: 'lantern.blend'
# www.blender.org # www.blender.org
o Cube o Lantern_Floor
v 0.187500 -0.062500 -0.187500 v 0.187500 -0.062500 -0.187500
v 0.187500 -0.500000 -0.187500 v 0.187500 -0.500000 -0.187500
v 0.187500 -0.062500 0.187500 v 0.187500 -0.062500 0.187500
@ -37,10 +37,8 @@ vt 0.375000 0.437500
vt 0.375000 0.875000 vt 0.375000 0.875000
vt -0.000000 0.875000 vt -0.000000 0.875000
vt 0.000000 0.437500 vt 0.000000 0.437500
vt 0.562500 0.125000 vt 0.000000 0.062500
vt 0.937500 0.125000 vt 0.375000 0.062500
vt 0.937500 0.250000
vt 0.562500 0.250000
vt 0.375000 0.437500 vt 0.375000 0.437500
vt 0.375000 0.875000 vt 0.375000 0.875000
vt -0.000000 0.875000 vt -0.000000 0.875000
@ -93,14 +91,14 @@ s off
f 1/1/1 5/2/1 7/3/1 3/4/1 f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/6/2 7/7/2 8/8/2 f 4/5/2 3/6/2 7/7/2 8/8/2
f 8/9/3 7/10/3 5/11/3 6/12/3 f 8/9/3 7/10/3 5/11/3 6/12/3
f 6/13/4 2/14/4 4/15/4 8/16/4 f 6/13/4 2/14/4 4/5/4 8/8/4
f 2/17/5 1/18/5 3/19/5 4/20/5 f 2/15/5 1/16/5 3/17/5 4/18/5
f 6/21/6 5/22/6 1/23/6 2/24/6 f 6/19/6 5/20/6 1/21/6 2/22/6
f 9/25/1 13/26/1 15/27/1 11/28/1 f 9/23/1 13/24/1 15/25/1 11/26/1
f 12/29/2 11/30/2 15/31/2 16/32/2 f 12/27/2 11/28/2 15/29/2 16/30/2
f 16/33/3 15/34/3 13/35/3 14/36/3 f 16/31/3 15/32/3 13/33/3 14/34/3
f 14/37/4 10/38/4 12/39/4 16/40/4 f 14/35/4 10/36/4 12/37/4 16/38/4
f 10/41/5 9/42/5 11/43/5 12/44/5 f 10/39/5 9/40/5 11/41/5 12/42/5
f 14/45/6 13/46/6 9/47/6 10/48/6 f 14/43/6 13/44/6 9/45/6 10/46/6
f 17/49/7 18/50/7 20/51/7 19/52/7 f 17/47/7 18/48/7 20/49/7 19/50/7
f 21/53/8 22/54/8 24/55/8 23/56/8 f 21/51/8 22/52/8 24/53/8 23/54/8

View File

@ -2,7 +2,25 @@ local S = minetest.get_translator("mcl_lanterns")
mcl_lanterns.register_lantern("lantern", { mcl_lanterns.register_lantern("lantern", {
description = S("Lantern"), description = S("Lantern"),
longdesc = S("Lanterns are light sources which can be placed on the top or the bottom of most blocks."),
texture = "mcl_lanterns_lantern.png", texture = "mcl_lanterns_lantern.png",
texture_inv = "mcl_lanterns_lantern_inv.png", texture_inv = "mcl_lanterns_lantern_inv.png",
light_level = 15, light_level = 15,
}) })
mcl_lanterns.register_lantern("soul_lantern", {
description = S("Soul Lantern"),
longdesc = S("Lanterns are light sources which can be placed on the top or the bottom of most blocks."),
texture = "mcl_lanterns_soul_lantern.png",
texture_inv = "mcl_lanterns_soul_lantern_inv.png",
light_level = 10,
})
minetest.register_craft({
output = "mcl_lanterns:lantern_floor",
recipe = {
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_torches:torch" , "mcl_core:iron_nugget"},
{"mcl_core:iron_nugget", "mcl_core:iron_nugget", "mcl_core:iron_nugget"},
},
})

BIN
mods/ITEMS/mcl_lanterns/textures/mcl_lanterns_chain.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 202 B

BIN
mods/ITEMS/mcl_lanterns/textures/mcl_lanterns_lantern.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB