bed item added, todo sleeping

This commit is contained in:
wsor 2021-05-17 21:18:58 -04:00
parent 27f840a7ae
commit 7d1464d044
21 changed files with 136 additions and 0 deletions

6
mods/fl_beds/README Normal file
View File

@ -0,0 +1,6 @@
Jean-Patrick Guerrero(Kilbith)(CC0)
farlands_bed.obj
wsor(aka wsor4035)(CC-BY-SA 3.0)
derived from texture by BlockMen under same license
farlands_bed_top.png

90
mods/fl_beds/init.lua Normal file
View File

@ -0,0 +1,90 @@
for counter, dye in pairs(fl_dyes.dyes) do
local cwool = "farlands_wool.png\\^[multiply\\:" .. fl_dyes.dyes[counter][3]
minetest.register_node("fl_beds:bed_" .. fl_dyes.dyes[counter][1], {
description = fl_dyes.dyes[counter][2] .. " bed",
inventory_image = "farlands_beds_" .. fl_dyes.dyes[counter][1] .. ".png",
wield_image = "farlands_beds_" .. fl_dyes.dyes[counter][1] .. ".png",
paramtype = "light",
paramtype2 = "facedir",
drawtype = "mesh",
mesh = "farlands_bed.obj",
selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0.0625, 1.5}},
collision_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 0.0625, 1.5}},
tiles = {
"[combine:41x41:" ..
"30,9=(farlands_apple_planks.png^[transformR90):37,9=" .. cwool .. ":" .. --foot side
"30,25=(farlands_apple_planks.png^[transformR90):37,25=(farlands_bed_top.png^[transformR90):" .. --head side
"0,0=" .. cwool .. ":16,0=" .. cwool .. ":24,0=farlands_bed_top.png:" .. --upper side
"0,4=farlands_apple_planks.png:16,4=farlands_apple_planks.png:" .. --lower side
"0,9=" .. cwool .. ":0,25=" .. cwool .. ":0,9=farlands_bed_top.png:" .. --top
"16,9=farlands_apple_planks.png:16,25=farlands_apple_planks.png" --bottom
},
after_place_node = function(pos, placer, itemstack)
local base = minetest.get_node_or_nil(pos)
if not base or not base.param2 then minetest.remove_node(pos) return true end
local dir = minetest.facedir_to_dir(base.param2)
local head_pos = {x=pos.x+dir.x,y=pos.y,z=pos.z+dir.z}
local head = minetest.get_node_or_nil(head_pos)
local def = minetest.registered_items[head.name] or nil
if not head or not def or not def.buildable_to then
minetest.remove_node(pos)
minetest.chat_send_player(placer:get_player_name(), "No room to place the bed!")
return true
end
minetest.set_node(pos, {name = base.name, param2 = base.param2})
return false
end,
--[[ non complete bed sleep function that needs to be completed
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local dir = minetest.facedir_to_dir(minetest.get_node(pos).param2)
local mpos = {x = pos.x + dir.x/2, y = pos.y+.07, z = pos.z+dir.z/2}
clicker:set_pos(mpos)
fl_player.ignore[clicker:get_player_name()] = true
clicker:set_animation(fl_player.animations["lay"], 0)
end,
--]]
groups = {oddly_breakable_by_hand = 3, bed = 1},
})
--note that this does not work properly in the engine, only exists for i3, see craft_hacks
local wool = ItemStack(minetest.itemstring_with_palette("fl_wool:wool", counter - 1))
wool:get_meta():set_string("description", fl_dyes.dyes[counter][2] .. " wool")
minetest.register_craft({
output = "fl_beds:bed_" .. fl_dyes.dyes[counter][1],
recipe = {
{wool:to_string(), wool:to_string(), wool:to_string()},
{"group:plank", "group:plank", "group:plank"}
},
})
minetest.register_craft({
output = "fl_beds:bed_" .. fl_dyes.dyes[counter][1],
type = "shapeless",
recipe = {
"group:bed",
"fl_dyes:" .. dye[1] .. "_dye"
},
})
end
--i3 currently does not support showing this correctly
local function craft_hacks(itemstack, player, old_craft_grid, craft_inv)
if string.sub(itemstack:get_name(), 1, 7) ~= "fl_beds" then return end
local indexs = {}
--for _, stack in pairs(craft_inv:get_list("craft")) do
for _, stack in pairs(old_craft_grid) do
--if stack ~= nil then
if stack:get_name() == "fl_wool:wool" then
local meta = stack:get_meta()
table.insert(indexs, meta:get_int("palette_index"))
end
--end
end
if indexs[1] == indexs[2] and indexs[2] == indexs[3] then
return ItemStack("fl_beds:bed_" .. fl_dyes.dyes[indexs[1]+1][1])
end
return ItemStack()
end
minetest.register_craft_predict(craft_hacks)
minetest.register_on_craft(craft_hacks)

1
mods/fl_beds/mod.conf Normal file
View File

@ -0,0 +1 @@
depends = fl_wool

View File

@ -0,0 +1,32 @@
# Blender v2.69 (sub 0) OBJ File: ''
# www.blender.org
mtllib simple_bed.mtl
o Simple_Bed
v 0.500000 -0.500000 -0.500000
v 0.500000 0.060000 -0.500000
v 0.500000 0.060000 1.500000
v 0.500000 -0.500000 1.500000
v -0.500000 -0.500000 -0.500000
v -0.500000 -0.500000 1.500000
v -0.500000 0.060000 1.500000
v -0.500000 0.060000 -0.500000
vt 0.000112 0.780442
vt 0.000110 0.999969
vt 0.780324 0.999889
vt 0.780377 0.780471
vt 0.780636 0.390284
vt 0.999906 0.780382
vt 0.999906 0.390284
vt 0.780636 0.000047
vt 0.999906 0.000094
vt 0.390235 0.780320
vt 0.390235 0.000071
vt 0.000142 0.000142
usemtl none.002
s off
f 1/1 2/2 3/3 4/4
f 5/1 6/4 7/3 8/2
f 1/5 5/4 8/6 2/7
f 4/8 3/9 7/7 6/5
f 1/8 4/4 6/10 5/11
f 2/11 8/12 7/1 3/10

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 771 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 774 B

View File

@ -2,6 +2,8 @@
--local modpath = minetest.get_modpath("fl_player")
--local texture_list = minetest.get_dir_list(modpath .. "/textures")
fl_player = {}
local animations = {
stand = {x=0, y=79},
lay = {x=162, y=166},
@ -20,6 +22,9 @@ local animations = {
climb = {x=410, y=429},
}
fl_player.animations = animations
fl_player.ignore = {}
minetest.register_on_joinplayer(function(player)
player:get_meta():set_int("vanish", 0)
player:set_properties({
@ -50,6 +55,8 @@ minetest.register_globalstep(function(dtime)
vector.new(0, 6.35, 0), vector.new(-math.deg(player:get_look_vertical()), 0, 0)
)
if fl_player.ignore[player:get_player_name()] then return end
if math.floor(player:get_properties().eye_height * 100) ~= 147 and not pcontrols.sneak then
player:set_properties({
eye_height = 1.47,