WIP: Cleanup and fixes, stairs no longer registers new nodes, only API. Workbench adds blocks to creative inventory

This commit is contained in:
MoNTE48 2019-06-11 23:50:38 +02:00
parent 2dc0127af6
commit 2b4dad6f1a
17 changed files with 92 additions and 111 deletions

View File

@ -129,7 +129,7 @@ function default.node_sound_snow_defaults(table)
return table
end
function default.node_wool_defaults(table)
function default.node_sound_wool_defaults(table)
table = table or {}
table.footstep = table.footstep or
{name = "default_wool_footstep", gain = 0.4}

View File

@ -178,7 +178,7 @@ minetest.register_node("default:gravel", {
drop = {
max_items = 1,
items = {
{items = {'default:flint'},rarity = 8},
{items = {'default:flint'}, rarity = 8},
{items = {'default:gravel'}}
}
},
@ -1462,6 +1462,7 @@ minetest.register_node("default:brick", {
minetest.register_node("default:glowstone", {
description = "Glowstone",
tiles = {"default_glowstone.png"},
paramtype = "light",
groups = {cracky = 3},
--[[ drop = {
max_items = 1,
@ -1594,7 +1595,7 @@ function AddGlass(desc, recipeitem, color)
tiles = {"xpanes_pane_glass"..color..".png"},
paramtype = "light",
use_texture_alpha = true,
groups = {cracky = 3, oddly_breakable_by_hand = 3},
groups = {cracky = 3, oddly_breakable_by_hand = 3, colorglass = 1},
sounds = default.node_sound_glass_defaults(),
drop = "",
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 B

After

Width:  |  Height:  |  Size: 346 B

View File

@ -5,7 +5,7 @@ local modpath = minetest.get_modpath(modname)
dofile(modpath .. "/override.lua")
local MAX_HUD_XP = 44
local MAX_HUD_XP = 32
local MAX_LEVEL = 40
local ORB_SOUND_INTERVAL = 0.01
local ORB_COLLECT_RADIUS = 3
@ -43,7 +43,7 @@ minetest.register_on_joinplayer(function(player)
hud = player:hud_add({
hud_elem_type = "statbar",
position = {x = 0.5, y = 0.97},
offset = {x = -252, y = -48},
offset = {x = -191, y = -29},
scale = {x = 1, y = 1},
alignment = {x = -1, y = -1},
text = "expbar_empty.png",
@ -54,7 +54,7 @@ minetest.register_on_joinplayer(function(player)
hud2 = player:hud_add({
hud_elem_type = "statbar",
position = {x = 0.5, y = 0.97},
offset = {x = -252, y = -48},
offset = {x = -191, y = -29},
scale = {x = 1, y = 1},
alignment = {x = -1, y = -1},
text = "expbar_full.png",
@ -64,9 +64,9 @@ minetest.register_on_joinplayer(function(player)
hud3 = player:hud_add({
hud_elem_type = "text",
texture = ("xp_blank"),
position = {x = 0.5, y = 0.97},
position = {x = 0.495, y = 0.976},
offset = {x = 6, y = -42},
alignment = {x = -1, y = -1},
alignment = {x = -0.5, y = -1},
number = 0x3cff00,
text = "",
})
@ -168,7 +168,7 @@ minetest.register_entity("experience:orb", {
glow = 12,
physical = true,
textures = {"orb.png"},
visual_size = {x = 0.15, y = 0.15},
visual_size = {x = 0.1, y = 0.1},
collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
collide_with_objects = false,
@ -185,7 +185,7 @@ minetest.register_entity("experience:orb", {
self.last_color_change = self.last_color_change or 0
self.color_ratio = self.color_ratio or 0
if self.timer > 300 then
if self.timer > 60 then
obj:remove()
elseif self.timer >= self.last_color_change + 0.001 then
if self.color_ratio >= 120 then

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 241 B

View File

@ -14,7 +14,6 @@ local function throw_error(msg)
minetest.log("error", "Better HUD[error]: " .. msg)
end
--
-- API
--
@ -121,9 +120,9 @@ function hud.change_item(player, name, def)
if def.offset and elem.offset then
if def.item_name and def.offset == "item" then
-- for legacy reasons
if def.item_name then
--[[if def.item_name then
hud.swap_statbar(player, name, def.item_name)
end
end]]
else
player:hud_change(elem.id, "offset", def.offset)
elem.offset = def.offset
@ -149,6 +148,35 @@ function hud.remove_item(player, name)
return true
end
-- Armor
if hud.show_armor then
local armor_org_func = armor.set_player_armor
local function get_armor_lvl(def)
-- items/protection based display
local lvl = def.level or 0
local max = 63 -- full diamond armor
-- TODO: is there a sane way to read out max values?
local ret = lvl/max
if ret > 1 then
ret = 1
end
return tonumber(20 * ret)
end
function armor.set_player_armor(self, player)
armor_org_func(self, player)
local name = player:get_player_name()
local def = self.def
local armor_lvl = 0
if def[name] and def[name].level then
armor_lvl = get_armor_lvl(def[name])
end
hud.change_item(player, "armor", {number = armor_lvl})
end
end
--
-- Add registered HUD items to joining players
@ -168,10 +196,10 @@ end
minetest.register_on_joinplayer(function(player)
-- first: hide the default statbars
local hud_flags = player:hud_get_flags()
--[[local hud_flags = player:hud_get_flags()
hud_flags.healthbar = false
hud_flags.breathbar = false
player:hud_set_flags(hud_flags)
player:hud_set_flags(hud_flags)]]
-- now add the backgrounds for statbars
for _,item in pairs(sb_bg) do

View File

@ -1,31 +1,12 @@
HUD_SB_SIZE = {x = 24, y = 24}
HUD_HEALTH_POS = {x = 0.5, y = 1}
HUD_HEALTH_OFFSET = {x = -248, y = -110}
HUD_AIR_POS = {x = 0.5, y = 1}
HUD_AIR_OFFSET = {x = 6, y = -124}
HUD_HUNGER_POS = {x = 0.5, y = 1}
HUD_HUNGER_OFFSET = {x = 6, y = -110}
HUD_ARMOR_POS = {x = 0.5, y = 1}
HUD_ARMOR_OFFSET = {x = -248, y = -124}
-- read hud.conf settings
function hud.read_conf()
local mod_path = minetest.get_modpath("hud")
local set = io.open(mod_path .. "/hud.conf", "r")
if set then
dofile(mod_path .. "/hud.conf")
set:close()
end
end
hud.read_conf()
hud.show_hunger = minetest.get_modpath("hunger") ~= nil
hud.show_armor = minetest.get_modpath("3d_armor") ~= nil
HUD_HEALTH_OFFSET = {x = -255, y = -109}
HUD_AIR_OFFSET = {x = 15, y = -134}
HUD_HUNGER_OFFSET = {x = 15, y = -109}
HUD_ARMOR_OFFSET = {x = -255, y = -134}
hud.register("health", {
hud_elem_type = "statbar",
position = HUD_HEALTH_POS,
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "heart.png",
number = 20,
@ -44,7 +25,7 @@ hud.register("health", {
hud.register("air", {
hud_elem_type = "statbar",
position = HUD_AIR_POS,
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "bubble.png",
number = 0,
@ -68,7 +49,7 @@ hud.register("air", {
hud.register("armor", {
hud_elem_type = "statbar",
position = HUD_ARMOR_POS,
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "hud_armor_fg.png",
number = 0,
@ -81,7 +62,7 @@ hud.register("armor", {
hud.register("hunger", {
hud_elem_type = "statbar",
position = HUD_HUNGER_POS,
position = {x = 0.5, y = 1},
size = HUD_SB_SIZE,
text = "hud_hunger_fg.png",
number = 20,

View File

@ -1,10 +1,11 @@
hud = {}
hud.show_armor = minetest.get_modpath("3d_armor") ~= nil
if minetest.settings:get_bool("enable_damage") then
local modpath = minetest.get_modpath("hud")
dofile(modpath .. "/api.lua")
dofile(modpath .. "/builtin.lua")
dofile(modpath .. "/legacy.lua")
end

View File

@ -1,35 +0,0 @@
-- Armor
function hud.set_armor()
end
if hud.show_armor then
local shields = minetest.get_modpath("shields") ~= nil
local armor_org_func = armor.set_player_armor
local function get_armor_lvl(def)
-- items/protection based display
local lvl = def.level or 0
local max = 63 -- full diamond armor
if shields then
max = 84.14 -- full diamond armor + diamond shield
end
-- TODO: is there a sane way to read out max values?
local ret = lvl/max
if ret > 1 then
ret = 1
end
return tonumber(20 * ret)
end
function armor.set_player_armor(self, player)
armor_org_func(self, player)
local name = player:get_player_name()
local def = self.def
local armor_lvl = 0
if def[name] and def[name].level then
armor_lvl = get_armor_lvl(def[name])
end
hud.change_item(player, "armor", {number = armor_lvl})
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 B

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 B

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

After

Width:  |  Height:  |  Size: 425 B

View File

@ -1,12 +1,13 @@
stairs = {}
stairs.mod = "redo"
stairs.wood = default.node_sound_wood_defaults()
--[[stairs.wood = default.node_sound_wood_defaults()
stairs.dirt = default.node_sound_dirt_defaults()
stairs.stone = default.node_sound_stone_defaults()
stairs.glass = default.node_sound_glass_defaults()
stairs.leaves = default.node_sound_leaves_defaults()
stairs.metal = default.node_sound_metal_defaults()
stairs.wool = default.node_sound_wool_defaults()]]
-- cache creative
local creative = minetest.settings:get_bool("creative_mode")
@ -82,7 +83,7 @@ end
-- Node will be called stairs:stair_<subname>
function stairs.register_stair(subname, recipeitem, groups, images, description, snds, alpha)
--[[function stairs.register_stair(subname, recipeitem, groups, images, description, snds, alpha)
local stair_images = set_textures(images)
local new_groups = table.copy(groups)
new_groups.stair = 1
@ -133,11 +134,11 @@ function stairs.register_stair(subname, recipeitem, groups, images, description,
{"stairs:stair_" .. subname, "stairs:stair_" .. subname},
},
})
end
end]]
-- Node will be called stairs:slab_<subname>
function stairs.register_slab(subname, recipeitem, groups, images, description, snds, alpha)
--[[function stairs.register_slab(subname, recipeitem, groups, images, description, snds, alpha)
local slab_images = set_textures(images)
local new_groups = table.copy(groups)
new_groups.slab = 1
@ -183,7 +184,7 @@ function stairs.register_slab(subname, recipeitem, groups, images, description,
{"stairs:slab_" .. subname},
},
})
end
end]]
-- Node will be called stairs:stair_outer_<subname>
@ -219,7 +220,7 @@ function stairs.register_stair_outer(subname, recipeitem, groups, images, descri
minetest.register_alias("stairs:corner_" .. subname, "stairs:stair_outer_" .. subname)
-- if no recipe item provided then skip craft recipes
if not recipeitem then
--[[if not recipeitem then
return
end
@ -240,18 +241,17 @@ function stairs.register_stair_outer(subname, recipeitem, groups, images, descri
{"stairs:stair_outer_" .. subname, "stairs:stair_outer_" .. subname},
{"stairs:stair_outer_" .. subname, "stairs:stair_outer_" .. subname},
},
})
})]]
end
-- compatibility function for previous stairs:corner_<subname>
function stairs.register_corner(subname, recipeitem, groups, images, description, snds, alpha)
--[[function stairs.register_corner(subname, recipeitem, groups, images, description, snds, alpha)
stairs.register_stair_outer(subname, recipeitem, groups, images, description, snds, alpha)
end
end]]
-- Node will be called stairs:stair_inner_<subname>
function stairs.register_stair_inner(subname, recipeitem, groups, images, description, snds, alpha)
--[[function stairs.register_stair_inner(subname, recipeitem, groups, images, description, snds, alpha)
local stair_images = set_textures(images)
local new_groups = table.copy(groups)
new_groups.stair = 1
@ -306,12 +306,12 @@ function stairs.register_stair_inner(subname, recipeitem, groups, images, descri
{"stairs:stair_inner_" .. subname, "stairs:stair_inner_" .. subname},
},
})
end
end]]
-- compatibility function for previous stairs:invcorner_<subname>
function stairs.register_invcorner(subname, recipeitem, groups, images, description, snds, alpha)
--[[function stairs.register_invcorner(subname, recipeitem, groups, images, description, snds, alpha)
stairs.register_stair_inner(subname, recipeitem, groups, images, description, snds, alpha)
end
end]]
-- Node will be called stairs:slope_<subname>
@ -352,7 +352,7 @@ function stairs.register_slope(subname, recipeitem, groups, images, description,
})
-- slope recipe
minetest.register_craft({
--[[minetest.register_craft({
output = "stairs:slope_" .. subname .. " 6",
recipe = {
{recipeitem, "", ""},
@ -366,27 +366,28 @@ function stairs.register_slope(subname, recipeitem, groups, images, description,
recipe = {
{"stairs:slope_" .. subname, "stairs:slope_" .. subname},
},
})
})]]
end
-- Nodes will be called stairs:{stair,slab}_<subname>
function stairs.register_stair_and_slab(subname, recipeitem, groups, images,
desc_stair, desc_slab, sounds, alpha)
stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds, alpha)
stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds, alpha)
-- stairs.register_stair(subname, recipeitem, groups, images, desc_stair, sounds, alpha)
-- stairs.register_slab(subname, recipeitem, groups, images, desc_slab, sounds, alpha)
stairs.register_slope(subname, recipeitem, groups, images, desc_stair, snds, alpha)
end
-- Nodes will be called stairs:{stair,slab,corner,invcorner,slope}_<subname>
function stairs.register_all(subname, recipeitem, groups, images, desc, snds, alpha)
--[[function stairs.register_all(subname, recipeitem, groups, images, desc, snds, alpha)
stairs.register_stair(subname, recipeitem, groups, images, desc, snds, alpha)
stairs.register_slab(subname, recipeitem, groups, images, desc, snds, alpha)
stairs.register_corner(subname, recipeitem, groups, images, desc, snds, alpha)
stairs.register_invcorner(subname, recipeitem, groups, images, desc, snds, alpha)
stairs.register_slope(subname, recipeitem, groups, images, desc, snds, alpha)
end
end]]
--[[
local grp = {} -- Helper
--= Default
@ -592,8 +593,8 @@ stairs.register_all("wool_" .. colours[i][1], "wool:" .. colours[i][1],
{snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, flammable = 3},
{"wool_" .. colours[i][1] .. ".png"},
colours[i][2] .. " Wool",
default.node_wool_defaults())
stairs.wool)
end
end
end]]

View File

@ -9,7 +9,7 @@ for i = 1, #dyes do
is_ground_content = false,
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
flammable = 3, wool = 1},
sounds = default.node_wool_defaults(),
sounds = default.node_sound_wool_defaults(),
})
minetest.register_craft{

View File

@ -7,7 +7,8 @@ local min, ceil = math.min, math.ceil
local nodes = {}
for node, def in pairs(minetest.registered_nodes) do
if (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass") and
(def.groups.cracky or def.groups.choppy) and
--(def.groups.crumbly or def.groups.cracky or def.groups.snappy or def.groups.choppy) and // ToDo!!!
(def.groups.cracky or def.groups.snappy or def.groups.choppy) and
not def.on_construct and
not def.after_place_node and
not def.on_rightclick and
@ -15,7 +16,8 @@ for node, def in pairs(minetest.registered_nodes) do
not def.allow_metadata_inventory_take and
not (def.groups.not_in_creative_inventory == 1) and
not (def.groups.not_cuttable == 1) and
not def.groups.wool and
--not def.groups.wool and
not def.groups.colorglass and
(def.tiles and type(def.tiles[1]) == "string" and not
def.tiles[1]:find("default_mineral")) and
not def.mesecons and
@ -46,21 +48,23 @@ nodes = nodes..WB.custom_nodes_register
-- Nodeboxes definitions
workbench.defs = {
-- Name Yield X Y Z W H L
{"nanoslab", 8, { 0, 0, 0, 8, 1, 8 }},
-- {"nanoslab", 8, { 0, 0, 0, 8, 1, 8 }},
{"micropanel", 8, { 0, 0, 0, 16, 1, 8 }},
{"microslab", 4, { 0, 0, 0, 16, 1, 16 }},
{"thinstair", 4, { 0, 7, 0, 16, 1, 8 },
{ 0, 15, 8, 16, 1, 8 }},
{"cube", 4, { 0, 0, 0, 8, 8, 8 }},
{"panel", 4, { 0, 0, 0, 16, 8, 8 }},
{"slab", 2, nil },
{"slab", 2, { 0, 0, 0, 16, 8, 16 }},
{"doublepanel", 2, { 0, 0, 0, 16, 8, 8 },
{ 0, 8, 8, 16, 8, 8 }},
{"halfstair", 2, { 0, 0, 0, 8, 8, 16 },
{ 0, 8, 8, 8, 8, 8 }},
{"outerstair", 1, { 0, 0, 0, 16, 8, 16 },
{ 0, 8, 8, 8, 8, 8 }},
{"stair", 1, nil },
{"stair", 1, { 0, 0, 0, 16, 8, 16 },
{ 0, 8, 8, 16, 8, 8 }},
{"slope", 2, nil },
{"innerstair", 1, { 0, 0, 0, 16, 8, 16 },
{ 0, 8, 8, 16, 8, 8 },
{ 0, 8, 0, 8, 8, 8 }}
@ -325,7 +329,7 @@ for i=1, #nodes do
if d[3] then
local groups = {}
local tiles
groups.not_in_creative_inventory = 1
--groups.not_in_creative_inventory = 1
for k, v in pairs(def.groups) do
if k ~= "wood" and k ~= "stone" and k ~= "level" then
@ -346,7 +350,7 @@ for i=1, #nodes do
if not minetest.registered_nodes["stairs:slab_"..node:match(":(.*)")] then
stairs.register_stair_and_slab(node:match(":(.*)"), node,
groups, tiles, def.description.." Stair",
def.description.." Slab", def.sounds)
def.description, def.sounds)
end
minetest.register_node(":"..node.."_"..d[1], {