firefly/mods/firefly_world/init.lua
2026-02-14 12:37:11 -05:00

298 lines
7.3 KiB
Lua

local ns = firefly
function ns.register_node(name, def)
local needs_alias
if not name:find ":" then
def._name = name
name = "firefly:"..name
needs_alias = true
end
if not def.groups then def.groups = {} end
def.groups.everything = 1
def.groups.dig_immediate = 3
if def._variants then
for i, x in ipairs(def.tiles) do
if not x.name then
def.tiles[i] = {name = x, align_style = "world"}
end
end
for _, x in ipairs(def._variants) do
if x == "slab" then
ns.register_slab(def)
elseif x == "stair" then
ns.register_stair(def)
end
end
end
minetest.register_node(":"..name, def)
if needs_alias then
minetest.register_alias(def._name, name)
end
end
function ns.register_slab(def)
def = table.copy(def)
def._variants = nil
local paramtype2 = def.paramtype2 == "color" and "colorfacedir" or "facedir"
ns.register_node(def._name.."_slab", extend(def, {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
},
paramtype = "light",
paramtype2 = paramtype2
}))
end
function ns.register_stair(def)
def = table.copy(def)
def._variants = nil
def.groups[def._name.."_stair"] = 1
local paramtype2 = def.paramtype2 == "color" and "colorfacedir" or "facedir"
ns.register_node(def._name.."_stair", extend(table.copy(def), {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}}
},
paramtype = "light",
paramtype2 = paramtype2
}))
ns.register_node(def._name.."_stair_inner", extend(table.copy(def), {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 0, 0.5, 0.5}}
},
paramtype = "light",
paramtype2 = paramtype2
}))
ns.register_node(def._name.."_stair_outer", extend(def, {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, 0, 0.5, 0, 0.5, 0}}
},
paramtype = "light",
paramtype2 = paramtype2
}))
end
ns.register_node("dirt", {
tiles = {"firefly_dirt.png"}
})
ns.register_node("dirt_grass", {
tiles = {"firefly_grass_top.png", "firefly_dirt.png", "firefly_dirt.png^firefly_grass_side.png"}
})
ns.register_node("grass", {
drawtype = "plantlike",
tiles = {"firefly_grass.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
})
ns.register_node("snow", {
tiles = {"firefly_snow_top.png"}
})
ns.register_node("snow_leveled", {
drawtype = "nodebox",
tiles = {"firefly_snow_top.png"},
node_box = {
type = "leveled",
fixed = {
-0.5, -0.5, -0.5,
0.5, 6/16, 0.5
}
},
paramtype = "light",
paramtype2 = "leveled",
place_param2 = 8
})
ns.register_node("snow_grass", {
drawtype = "plantlike",
tiles = {"firefly_snow_grass.png"},
paramtype = "light",
sunlight_propagates = true,
walkable = false,
})
ns.register_node("sand", {
tiles = {"firefly_sand.png"}
})
ns.register_node("sand_leveled", {
drawtype = "nodebox",
tiles = {"firefly_sand.png"},
node_box = {
type = "leveled",
fixed = {
-0.5, -0.5, -0.5,
0.5, 6/16, 0.5
}
},
paramtype = "light",
paramtype2 = "leveled",
place_param2 = 64
})
ns.register_node("sandstone", {
tiles = {"firefly_sandstone.png"},
_variants = {"slab", "stair"},
})
ns.register_node("sandstone_sandy", {
tiles = {"firefly_sand.png", "firefly_sandstone.png", "firefly_sandstone.png^firefly_sand_side_2.png"}
})
ns.register_node("sandstone_bricks", {
tiles = {"firefly_sandstone_bricks.png"},
_variants = {"slab", "stair"},
})
ns.register_node("sandstone_bricks_sandy", {
tiles = {"firefly_sand.png", "firefly_sandstone_bricks.png", "firefly_sandstone_bricks.png^firefly_sand_side.png"}
})
ns.register_node("cactus", {
tiles = {"firefly_cactus_top.png", "firefly_cactus_top.png", "firefly_cactus_side.png"},
paramtype2 = "facedir"
})
ns.register_node("stone", {
tiles = {"firefly_stone.png"},
_variants = {"slab", "stair"},
})
ns.register_node("stone_bricks", {
tiles = {"firefly_stone_bricks.png"},
_variants = {"slab", "stair"},
})
ns.register_node("metal_floor", {
tiles = {"firefly_metal_floor.png"},
_variants = {"slab", "stair"},
})
ns.register_node("orange_light", {
tiles = {"firefly_orange_light.png"},
paramtype = "light",
light_source = 14
})
ns.register_node("gray_pillar", {
tiles = {"firefly_gray_pillar_top.png", "firefly_gray_pillar_top.png", "firefly_gray_pillar_side.png"},
paramtype2 = "facedir",
_variants = {"slab", "stair"},
})
ns.register_node("gray_column", {
tiles = {{name = "firefly_gray_column.png"}},
paramtype2 = "4dir",
_variants = {"slab", "stair"},
})
ns.register_node("gray_wall", {
tiles = {"firefly_gray_wall.png"},
_variants = {"slab", "stair"},
})
ns.register_node("gray_tile", {
tiles = {"firefly_gray_tile.png"},
_variants = {"slab", "stair"},
})
local brown = "#584e2d"
ns.register_node("brown_wall", {
tiles = {"firefly_wall.png"},
_variants = {"slab", "stair"},
color = brown,
})
ns.register_node("brown_column", {
tiles = {{name = "firefly_column.png"}},
paramtype2 = "4dir",
_variants = {"slab", "stair"},
color = brown,
})
ns.register_node("brown_pillar", {
tiles = {"firefly_pillar_top.png", "firefly_pillar_top.png", "firefly_pillar_side.png"},
paramtype2 = "facedir",
_variants = {"slab", "stair"},
color = brown,
})
ns.register_node("glass", {
paramtype = "light",
sunlight_propagates = true,
tiles = {{name = "firefly_glass.png", align_style = "world"}},
use_texture_alpha = "clip",
_variants = {"slab", "stair"},
})
ns.register_node("colored_glass", {
drawtype = "glasslike",
paramtype = "light",
paramtype2 = "color",
palette = "firefly_glass_palette.png",
sunlight_propagates = true,
tiles = {{name = "firefly_colored_glass.png", align_style = "world"}},
use_texture_alpha = "blend",
_variants = {"slab", "stair"},
})
ns.register_node("steel_grate", {
drawtype = "mesh",
mesh = "firefly_steel_grate.obj",
tiles = {{name = "firefly_steel_grate.png", backface_culling = true}},
use_texture_alpha = "clip",
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
collision_box = {
type = "fixed",
fixed = {
-0.5, 6/16, -0.5,
0.5, 0.5, 0.5
}
},
selection_box = {
type = "fixed",
fixed = {
-0.5, 6/16, -0.5,
0.5, 0.5, 0.5
}
}
})
minetest.register_chatcommand("chest", {
privs = {give = true},
func = function(name)
minetest.registered_chatcommands.giveme.func(name, "chest_with_everything:chest")
end
})