Camas/mods/lumien/init.lua

219 lines
4.8 KiB
Lua
Raw Normal View History

2015-12-17 19:05:34 +01:00
--
-- Lumien mod
-- By Kaadmy, for Pixture
--
2019-08-28 17:31:41 +02:00
local S = minetest.get_translator("lumien")
local lumien_on_radius = 2
local lumien_off_radius = 4
local timer_interval = 1
local timer = 0
-- Update function
local function on_globalstep(dtime)
timer = timer + dtime
if timer < timer_interval then
return
end
timer = 0
for _, player in ipairs(minetest.get_connected_players()) do
local pos = player:get_pos()
util.nodefunc(
{
x = pos.x-lumien_on_radius,
y = pos.y-lumien_on_radius,
z = pos.z-lumien_on_radius
},
{
x = pos.x+lumien_on_radius,
y = pos.y+lumien_on_radius,
z = pos.z+lumien_on_radius
},
"lumien:crystal_off",
function(pos)
local node = minetest.get_node(pos)
minetest.set_node(
pos,
{
name = "lumien:crystal_on",
param = node.param,
param2 = node.param2
})
end,
true
)
end
end
minetest.register_globalstep(on_globalstep)
-- Nodes
minetest.register_node(
2015-12-17 19:05:34 +01:00
"lumien:crystal_on",
{
2019-08-28 17:31:41 +02:00
description = S("Glowing Lumien Crystal"),
2019-09-21 21:29:25 +02:00
inventory_image = "lumien_crystal_on.png",
2015-12-17 19:05:34 +01:00
tiles = {"lumien_block.png"},
paramtype = "light",
paramtype2 = "wallmounted",
is_ground_content = false,
2015-12-17 19:05:34 +01:00
drawtype = "nodebox",
node_box = {
type = "wallmounted",
wall_top = {-4/16, 0.5-(4/16), -4/16, 4/16, 0.5, 4/16},
wall_side = {-0.5, -4/16, -4/16, -0.5+(4/16), 4/16, 4/16},
wall_bottom = {-4/16, -0.5, -4/16, 4/16, -0.5+(4/16), 4/16}
},
2015-12-17 19:05:34 +01:00
groups = {crumbly = 3, not_in_creative_inventory = 1},
light_source = 12,
2015-12-17 19:05:34 +01:00
drop = "lumien:crystal_off",
sounds = default.node_sound_glass_defaults(),
})
2015-12-17 19:05:34 +01:00
minetest.register_node(
2015-12-17 19:05:34 +01:00
"lumien:crystal_off",
{
2019-08-28 17:31:41 +02:00
description = S("Lumien Crystal"),
2015-12-17 19:05:34 +01:00
inventory_image = "lumien_crystal.png",
tiles = {"lumien_block.png"},
paramtype = "light",
paramtype2 = "wallmounted",
is_ground_content = false,
2015-12-17 19:05:34 +01:00
drawtype = "nodebox",
node_box = {
type = "wallmounted",
wall_top = {-4/16, 0.5-(4/16), -4/16, 4/16, 0.5, 4/16},
wall_side = {-0.5, -4/16, -4/16, -0.5+(4/16), 4/16, 4/16},
wall_bottom = {-4/16, -0.5, -4/16, 4/16, -0.5+(4/16), 4/16}
},
2015-12-17 19:05:34 +01:00
groups = {crumbly = 3},
light_source = 2,
sounds = default.node_sound_glass_defaults(),
})
2015-12-17 19:05:34 +01:00
minetest.register_node(
2015-12-17 19:05:34 +01:00
"lumien:block",
{
2019-08-28 17:31:41 +02:00
description = S("Lumien Block"),
2015-12-17 19:05:34 +01:00
tiles = {"lumien_block.png"},
groups = {cracky = 1},
2015-12-17 19:05:34 +01:00
light_source = 14,
sounds = default.node_sound_stone_defaults(),
})
-- Ores
2015-12-17 19:05:34 +01:00
minetest.register_node(
"lumien:stone_with_lumien",
2015-12-17 19:05:34 +01:00
{
2019-08-28 17:31:41 +02:00
description = S("Stone with Lumien"),
tiles = {"default_stone.png^lumien_mineral_lumien.png"},
2015-12-17 19:05:34 +01:00
groups = {cracky = 1, stone = 1},
drop = "lumien:block",
sounds = default.node_sound_stone_defaults(),
})
2015-12-19 21:38:40 +01:00
minetest.register_ore(
2015-12-17 19:05:34 +01:00
{
ore_type = "scatter",
ore = "lumien:stone_with_lumien",
2015-12-17 19:05:34 +01:00
wherein = "default:stone",
clust_scarcity = 5*5*5,
clust_num_ores = 8,
clust_size = 6,
y_min = -107,
y_max = -100,
})
-- Update functions
2015-12-17 19:05:34 +01:00
minetest.register_abm(
2015-12-17 19:05:34 +01:00
{
2017-05-19 23:04:11 +02:00
label = "Lumien crystals",
2015-12-17 19:05:34 +01:00
nodenames = {"lumien:crystal_on"},
interval = timer_interval,
2015-12-17 19:05:34 +01:00
chance = 1,
action = function(pos, node)
util.nodefunc(
{x = pos.x-1, y = pos.y-1, z = pos.z-1},
{x = pos.x+1, y = pos.y+1, z = pos.z+1},
"tnt:tnt",
function(pos)
tnt.burn(pos)
end,
true
)
local ok = true
for _,object in ipairs(minetest.get_objects_inside_radius(pos, lumien_off_radius)) do
if object:is_player() then
ok = false
end
end
if ok then
minetest.set_node(
pos,
{
name = "lumien:crystal_off",
param = node.param,
param2 = node.param2
})
end
end,
})
2015-12-17 19:05:34 +01:00
-- Crafting
2015-12-17 19:05:34 +01:00
crafting.register_craft(
{
output = "lumien:crystal_off 9",
items = {
"lumien:block"
},
})
2015-12-17 19:05:34 +01:00
crafting.register_craft(
{
output = "lumien:block",
items = {
"lumien:crystal_off 9",
},
})
2015-12-17 19:05:34 +01:00
crafting.register_craft(
{
2019-12-04 14:22:21 +01:00
output = "default:heated_dirt_path 2",
items = {
"default:dirt_path 2",
"lumien:crystal_off",
},
})
-- Achievements
achievements.register_achievement(
"enlightened",
{
2019-08-28 17:31:41 +02:00
title = S("Enlightened"),
description = S("Place a lumien crystal."),
times = 1,
2019-09-03 19:34:50 +02:00
placenode = "lumien:crystal_off",
})
default.log("mod:lumien", "loaded")