artifact_one/mods/artifact_world/init.lua

186 lines
4.4 KiB
Lua

artifact.registered_nodes = {}
function artifact.register_node(name, def)
artifact.registered_nodes[name] = def
def._name = name
if not name:find ":" then
name = "artifact:"..name
end
if artifact.debug then
if not def.groups then def.groups = {} end
def.groups.dig_immediate = 3
end
minetest.register_node(":"..name, def)
if name ~= def._name then
minetest.register_alias(def._name, name)
end
end
function artifact.register_craftitem(name, def)
def._name = name
if not name:find ":" then
name = "artifact:"..name
end
minetest.register_craftitem(":"..name, def)
if name ~= def._name then
minetest.register_alias(def._name, name)
end
end
local function rep(tx, size)
local out = "[combine:"..(size *16).."x"..(size *16)
for x = 0, size -1 do
for y = 0, size -1 do
out = out..":"..(x *16)..","..(y *16).."="..tx
end
end
return out
end
artifact.register_node("stone", {
tiles = {"artifact_stone.png"}
})
artifact.register_node("stone_mossy", {
tiles = {{name = rep("artifact_stone.png", 4).."^artifact_moss.png", align_style = "world", scale = 4}}
})
artifact.register_node("stone_bricks", {
tiles = {"artifact_stone_bricks.png"}
})
artifact.register_node("stone_bricks_mossy", {
tiles = {{name = rep("artifact_stone_bricks.png", 4).."^artifact_moss_bricks.png", align_style = "world", scale = 4}}
})
artifact.register_node("stone_bricks_small", {
tiles = {"artifact_stone_bricks_small.png"}
})
artifact.register_node("stone_tile", {
tiles = {"artifact_stone_tile.png"}
})
artifact.register_node("stone_tile_small", {
tiles = {"artifact_stone_tile_small.png"}
})
artifact.register_node("vines", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-0.5, -0.5, 0.48,
0.5, 0.5, 0.48
}
},
walkable = false,
selection_box = {
type = "fixed",
fixed = {
-0.5, -0.5, 0.5,
0.5, 0.5, 0.45
}
},
paramtype = "light",
paramtype2 = "facedir",
tiles = {"artifact_vines.png"},
use_texture_alpha = true
})
artifact.register_node("vines_dry", {
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
-0.5, -0.5, 0.48,
0.5, 0.5, 0.48
}
},
walkable = false,
selection_box = {
type = "fixed",
fixed = {
-0.5, -0.5, 0.5,
0.5, 0.5, 0.45
}
},
paramtype = "light",
paramtype2 = "facedir",
tiles = {"artifact_vines_dry.png"},
use_texture_alpha = true
})
artifact.register_node("leaves", {
drawtype = "allfaces",
-- paramtype = "light",
tiles = {"artifact_leaves.png"},
use_texture_alpha = true
})
artifact.register_node("leaves_dry", {
drawtype = "allfaces",
-- paramtype = "light",
tiles = {"artifact_leaves_dry.png"},
use_texture_alpha = true
})
artifact.register_node("wood_planks", {
tiles = {"artifact_wood_planks.png"}
})
artifact.register_node("ladder_wood", {
drawtype = "mesh",
mesh = "artifact_ladder.obj",
paramtype = "light",
paramtype2 = "facedir",
tiles = {"artifact_ladder_wood.png"},
walkable = false,
climbable = true
})
local function register_lamp(color, brightness)
artifact.register_node("lamp_"..color, {
drawtype = "mesh",
mesh = "artifact_lamp.obj",
tiles = {"artifact_lamp_"..color..".png"},
light_source = brightness,
paramtype = "light",
sunlight_propagates = true
})
artifact.register_node("lamp_"..color.."_hanging", {
drawtype = "mesh",
mesh = "artifact_lamp_hanging.obj",
tiles = {"artifact_lamp_"..color..".png"},
light_source = brightness,
paramtype = "light",
sunlight_propagates = true
})
end
register_lamp("red", 6)
register_lamp("gold", 8)
register_lamp("blue", 10)
artifact.register_node("light", {
tiles = {"artifact_light.png"},
paramtype = "light",
light_source = 14
})
-- Make darkness the default.
minetest.override_item("air", {
sunlight_propagates = false,
light_source = 2
})
minetest.register_mapgen_script(minetest.get_modpath(minetest.get_current_modname()).."/mapgen.lua")
minetest.register_decoration {
deco_type = "simple",
decoration = "lamp_gold",
place_on = "stone",
fill_ratio = 0.02,
}