Add files via upload

This commit is contained in:
wintersknight94 2022-02-15 20:06:15 -06:00 committed by GitHub
parent 4921a9e813
commit deb7b7a05b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 1138 additions and 0 deletions

25
README.md Normal file
View File

@ -0,0 +1,25 @@
# WC_LUMINOUS
Adds new light sources to NodeCore
Far superior to the old "nc_light" in the following ways:
- Coal Lantern
- New Model With A More 'Nodecorian' Vibe
- No More Broken Textures (Hopefully)
- Can Be Emptied Without Being Broken Apart
- Fuel Maximum Has Been Buffed
- Recipe Cost Has Been Buffed
- Occasionally Drops Ashes While Lit
- Luxlamp
- New Recipe
- New Model
- Rebalanced Functionality
- Properly Charges (Hopefully)
- Rushlight
- Cheap Light Source
- Doesn't Require Charcoal
- Lasts Approximately 25% As Long As A Torch
- Egg Burner
- Incense Bowls!
- Uses Eggcorns For Fuel
- Dim Light, Long Duration
- Goes Out Faster When Carried
# ~LET THERE BE LIGHT~

240
eggburner.lua Normal file
View File

@ -0,0 +1,240 @@
-- LUALOCALS < ---------------------------------------------------------
local ItemStack, math, minetest, nodecore, pairs, setmetatable, vector
= ItemStack, math, minetest, nodecore, pairs, setmetatable, vector
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
-------------------------------------------------------------------------------
local base = "nc_terrain_stone.png"
local boxy = "nc_concrete_pattern_boxy.png^[opacity:50"
local horzy = "nc_concrete_pattern_horzy.png^[opacity:50"
local pit = "(nc_fire_coal_4.png^[mask:" ..modname.. "_mask_pit.png)^[opacity:75"
local egg = "[combine:24x24:4,4=nc_tree_eggcorn.png\\^[resize\\:8x8"
local ember = "(nc_fire_coal_4.png^nc_fire_ember_3.png^[opacity:150)^[mask:" ..modname.. "_mask_pit.png"
local ash = "nc_fire_ash.png^[mask:" ..modname.. "_mask_pit.png"
-------------------------------------------------------------------------------
local rfcall = function(pos, data)
local ref = minetest.get_player_by_name(data.pname)
local wield = ref:get_wielded_item()
wield:take_item(1)
ref:set_wielded_item(wield)
end
-------------------------------------------------------------------------------
----------------INCENSE-----------------
local function burner(id, light, tile)
minetest.register_node(modname .. ":incense_" ..id, {
description = "Egg Burner",
tiles = tile,
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.25, -0.5, -0.25, 0.25, -0.4375, 0.25}, -- Bowl_1
{-0.375, -0.4375, -0.375, 0.375, -0.375, 0.375}, -- Bowl_2
{-0.4375, -0.375, -0.4375, 0.4375, -0.25, 0.4375}, -- Bowl_3
{-0.5, -0.25, -0.5, 0.5, 0, 0.5}, -- Bowl_4
{-0.4375, 0, -0.4375, 0.4375, 0.0625, 0.4375}, -- Bowl_5
{-0.375, 0.0625, -0.375, 0.375, 0.125, 0.375}, -- Bowl_6
}
},
sunlight_propagates = true,
light_source = light,
groups = {
stack_as_node = 1,
snappy = 1,
incense = 1,
totable = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_terrain_stony")
})
end
-------------------------------------------------------------------------------
burner("empty", 0,
{
"(" ..base.. ")^(" ..boxy.. ")^(" ..pit.. ")",
base,
"(" ..base.. ")^(" ..horzy.. ")"
}
)
burner("unlit", 0,
{
"(" ..base.. ")^(" ..boxy.. ")^(" ..pit.. ")^(" ..egg.. ")",
base,
"(" ..base.. ")^(" ..horzy.. ")"
}
)
burner("lit", 4,
{
"(" ..base.. ")^(" ..boxy.. ")^(" ..pit.. ")^(" ..ember.. ")",
base,
"(" ..base.. ")^(" ..horzy.. ")"
}
)
burner("ashy", 0,
{
"(" ..base.. ")^(" ..boxy.. ")^(" ..pit.. ")^(" ..ash.. ")",
base,
"(" ..base.. ")^(" ..horzy.. ")"
}
)
----------------IGNITION-----------------
minetest.register_abm({
label = "ignite eggburner",
interval = 10,
chance = 2,
nodenames = {modname.. ":incense_unlit"},
neighbors = {"group:igniter", "group:torch_lit", "group:candle_lit"},
-- action_delay = true,
action = function(pos)
if not nodecore.quenched(pos) then
minetest.set_node(pos, {name = modname.. ":incense_lit"})
end
end
})
----------------QUENCHING-----------------
nodecore.register_abm({
label = "Incense Quenching",
interval = 0.1,
chance = 1,
nodenames = {modname .. ":incense_lit"},
action = function(pos)
if nodecore.quenched(pos) then
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
return minetest.set_node(pos, {name = modname.. ":incense_ashy"})
end
end
})
nodecore.register_aism({
label = "Held Incense Quenching",
interval = 0.1,
chance = 1,
itemnames = {modname .. ":incense_lit"},
action = function(stack, data)
local pos = data.pos
local player = data.player
ext = true
if player then
if data.list ~= "main" or player:get_wield_index()
~= data.slot then ext = false end
pos = vector.add(pos, vector.multiply(player:get_look_dir(), 0.5))
end
if ext and nodecore.quenched(pos, data.node and 1 or 0.3) then
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
stack:set_name(modname .. ":incense_ashy")
return stack
end
end
})
------------BURNING UP------------
nodecore.register_abm({
label = "Incense Use",
interval = 900,
chance = 1,
nodenames = {modname .. ":incense_lit"},
action = function(pos)
return minetest.set_node(pos, {name = modname .. ":incense_ashy"})
end
})
nodecore.register_aism({
label = "Held Incense Use",
interval = 90,
chance = 10,
itemnames = {modname .. ":incense_lit"},
action = function(stack, data)
stack:set_name(modname .. ":incense_ashy")
return stack
end
})
------------REFILL BURNER------------
nodecore.register_craft({
label = "refill eggburner",
action = "pummel",
wield = {name = "nc_tree:eggcorn"},
after = rfcall,
nodes = {
{match = modname .. ":incense_empty", replace = modname .. ":incense_unlit"}
}
})
------------ASH DUMPING------------
nodecore.register_craft({
label = "empty incense",
action = "pummel",
duration = 1,
nodes = {
{
match = modname.. ":incense_ashy",
replace = modname.. ":incense_empty"
}
},
items = {
{name = "nc_fire:lump_ash", count = 1}
}
})
------------EGG DUMPING------------
nodecore.register_craft({
label = "remove incense",
action = "pummel",
nodes = {
{
match = modname.. ":incense_unlit",
replace = modname.. ":incense_empty"
}
},
items = {
{name = "nc_tree:eggcorn", count = 1}
}
})
------------Break Burner-----------
nodecore.register_craft({
label = "break incense apart",
action = "pummel",
duration = 2,
toolgroups = {thumpy = 3, cracky = 3, choppy = 3},
nodes = {
{
match = {groups = {incense = true}},
replace = "nc_terrain:gravel"
}
},
items = {
{name = "nc_stonework:chip", count = 3, scatter = 2},
{name = "nc_fire:lump_ash", count = 1, scatter = 2},
},
itemscatter = 2
})
------------CRAFT INCENSE------------
nodecore.register_craft({
label = "chisel eggburner",
action = "pummel",
duration = 2,
toolgroups = {thumpy = 3},
normal = {y = 1},
indexkeys = {"group:chisel"},
nodes = {
{
match = {
lode_temper_cool = true,
groups = {chisel = true}
},
dig = true
},
{
y = -1,
match = "nc_concrete:terrain_stone_boxy",
replace = modname .. ":incense_empty"
}
}
})
----------------------------------------
------------Incense Ambiance------------
nodecore.register_ambiance({
label = "Incense Ambiance",
nodenames = {modname.. ":incense_lit"},
interval = 1,
chance = 2,
sound_name = "nc_fire_flamy",
sound_gain = 0.1
})

18
init.lua Normal file
View File

@ -0,0 +1,18 @@
-- LUALOCALS < ---------------------------------------------------------
local include, nodecore
= include, nodecore
-- LUALOCALS > ---------------------------------------------------------
include("lantern")
include("luxlamp")
include("rushlight")
include("eggburner")
include("smoke")
--include("luxfly")
--include("")
----------Let There Be Light----------
---A mod for NodeCore that adds new---
---light sources while maintaining----
---game balance-----By WintersKnight--
--------------------------------------

438
lantern.lua Normal file
View File

@ -0,0 +1,438 @@
-- LUALOCALS < ---------------------------------------------------------
local ItemStack, math, minetest, nodecore, pairs, setmetatable, vector
= ItemStack, math, minetest, nodecore, pairs, setmetatable, vector
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local checkdirs = {
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z = -1},
{x = 0, y = 1, z = 0}
}
----------------------------------------
nodecore.lantern_life_base = 120
nodecore.max_lantern_fuel = 10
-------------------------------------------------------------------------------
local globe = "nc_optics_glass_glare.png^[mask:" ..modname.. "_mask_globe.png"
local plate = "nc_lode_annealed.png^[mask:" ..modname.. "_mask_lantern.png"
local fslot = modname.. "_fuel_slot.png^[opacity:65"
local ftile = modname.. "_fire.png"
-------------------------------------------------------------------------------
local flame = {
name = modname.. "_fire_anim.png",
animation = {
type = "vertical_frames",
aspect_w = 16,
aspect_h = 16,
length = 4
}
}
-------------------------------------------------------------------------------
----------EMPTY LANTERN----------
minetest.register_node(modname .. ":lantern_empty", {
description = "Lantern",
tiles = {
"nc_lode_annealed.png",
"nc_lode_annealed.png",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")",
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}, -- BasePlate
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- TopPlate
{-0.375, 0.375, -0.375, 0.375, 0.4375, 0.375}, -- TopRiser
{-0.25, 0.4375, -0.25, 0.25, 0.5, 0.25}, -- TopCap
{-0.4375, -0.3125, -0.4375, 0.4375, -0.25, 0.4375}, -- BasePlate
{-0.375, -0.25, -0.375, 0.375, 0.25, 0.375}, -- Globe
}
},
sunlight_propagates = true,
-- light_source = light,
groups = {
stack_as_node = 1,
snappy = 1,
lantern = 1,
lantern_fuel = 0,
lantern_off =1,
totable = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_lode_annealed"),
})
----------------------------------------
------------Lantern Crafting------------
nodecore.register_craft({
label = "assemble lantern",
action = "stackapply",
indexkeys = {"nc_lode:form"},
wield = {name = "nc_optics:glass"},
consumewield = 1,
nodes = {
{match = "nc_lode:form", replace = "air"},
{y = -1, match = "nc_lode:block_annealed", replace = modname .. ":lantern_empty"},
}
})
----------------------------------------
-----------FUELED LANTERN OFF-----------
local lnodes = {}
----------------------------------------
local function lantern (fuel) -- Kimapr: deleted these redundant arguments (fuel, burn, energy, light, refill)
----------------------------------------
local burn = fuel-1
local aburns = burn == 0 and "empty" or "lit_"..burn -- nodename suffix after burn
local aburn = burn == 0 and "empty" or burn
local light = fuel + 6
----------------------------------------
minetest.register_node(modname .. ":lantern_" .. fuel, {
description = "Lantern",
tiles = {
"nc_lode_annealed.png",
"nc_lode_annealed.png",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
"(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)"
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}, -- BasePlate
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- TopPlate
{-0.375, 0.375, -0.375, 0.375, 0.4375, 0.375}, -- TopRiser
{-0.25, 0.4375, -0.25, 0.25, 0.5, 0.25}, -- TopCap
{-0.4375, -0.3125, -0.4375, 0.4375, -0.25, 0.4375}, -- BasePlate
{-0.375, -0.25, -0.375, 0.375, 0.25, 0.375}, -- Globe
}
},
sunlight_propagates = true,
-- light_source = light,
groups = {
falling = 1,
flammable = 1,
stack_as_node = 1,
snappy = 1,
lantern_off = 1,
lantern_fuel = fuel,
lantern = 1,
totable = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_lode_annealed"),
on_ignite = function(pos, node)
minetest.set_node(pos, {name = modname .. ":lantern_lit_" .. fuel})
minetest.sound_play("nc_fire_ignite", {gain = 1, pos = pos})
return true
end
})
----------------------------------------
-----------FUELED LANTERN LIT-----------
minetest.register_node(modname .. ":lantern_lit_" .. fuel, {
description = "Lantern",
tiles = {
"nc_lode_annealed.png",
"nc_lode_annealed.png",
"(" ..ftile.. ")^(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
"(" ..ftile.. ")^(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
"(" ..ftile.. ")^(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
"(" ..ftile.. ")^(" ..globe.. ")^(" ..plate.. ")^(" ..fslot.. ")^(" ..modname.. "_fuel_" ..fuel.. ".png)",
},
drawtype = "nodebox",
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, 0.5, -0.3125, 0.5}, -- BasePlate
{-0.5, 0.25, -0.5, 0.5, 0.375, 0.5}, -- TopPlate
{-0.375, 0.375, -0.375, 0.375, 0.4375, 0.375}, -- TopRiser
{-0.25, 0.4375, -0.25, 0.25, 0.5, 0.25}, -- TopCap
{-0.4375, -0.3125, -0.4375, 0.4375, -0.25, 0.4375}, -- BasePlate
{-0.375, -0.25, -0.375, 0.375, 0.25, 0.375}, -- Globe
}
},
sunlight_propagates = true,
light_source = light,
groups = {
falling = 1,
stack_as_node = 1,
snappy = 1,
lantern_lit = 1,
lantern_fuel = fuel,
lantern = 1,
totable = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_lode_annealed")
})
--lnodes[light] = nodecore.dynamic_light_node(light)
--lnodes[light-2] = nodecore.dynamic_light_node(light-2)
----------------------------------------
------------Fuel Consumption------------
-----Placed-----
nodecore.register_abm({
label = "Lantern Quenching",
interval = 0.1,
chance = 1,
nodenames = {modname .. ":lantern_lit_" .. fuel},
action = function(pos)
if nodecore.quenched(pos) then
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
return minetest.set_node(pos, {name = modname .. ":lantern_"..fuel})
end
end
})
nodecore.register_abm({
label = "Lantern Fuel Use",
interval = 100,
chance = 1,
nodenames = {modname .. ":lantern_lit_" .. fuel},
action = function(pos)
nodecore.sound_play(modname .. "_hissy", {gain = 0.4, pos = pos})
return minetest.set_node(pos, {name = modname .. ":lantern_" .. aburns})
end
})
-- Kimapr: merged two ABMs into one
-----Carried-----
nodecore.register_aism({
label = "Lantern Quenching",
interval = 0.1,
chance = 1,
itemnames = {modname .. ":lantern_lit_" .. fuel},
action = function(stack, data)
local pos = data.pos
local player = data.player
ext = true
if player then
if data.list ~= "main" or player:get_wield_index()
~= data.slot then ext = false end
pos = vector.add(pos, vector.multiply(player:get_look_dir(), 0.5))
end
if ext and nodecore.quenched(pos, data.node and 1 or 0.3) then
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
stack:set_name(modname .. ":lantern_"..fuel)
return stack
end
end
})
nodecore.register_aism({
label = "Held Fuel Use",
interval = 100,
chance = 1,
itemnames = {modname .. ":lantern_lit_" .. fuel},
action = function(stack, data)
minetest.sound_play(modname .. "_hissy", {gain = 0.4, pos = data.pos})
stack:set_name(modname .. ":lantern_" .. aburns)
return stack
end
})
----------------------------------------
-------------Lantern Refill-------------
local rfcall = function(pos, data)
local ref = minetest.get_player_by_name(data.pname)
local wield = ref:get_wielded_item()
wield:take_item(1)
ref:set_wielded_item(wield)
end
nodecore.register_craft({
label = "refill lantern",
action = "pummel",
wield = {name = "nc_fire:lump_coal"},
after = rfcall,
nodes = {
{match = modname .. ":lantern_"..aburn, replace = modname .. ":lantern_"..fuel}
}
})
if fuel > 1 then
nodecore.register_craft({
label = "refill lit lantern",
action = "pummel",
wield = {name = "nc_fire:lump_coal"},
after = rfcall,
nodes = {
{
match = modname .. ":lantern_"..aburns,
replace = modname .. ":lantern_lit_"..fuel
}
}
})
end
----------------------------------------
------------Lantern Emptying------------
nodecore.register_craft({
label = "empty lantern",
action = "pummel",
duration = 1,
-- toolgroups = {thumpy = 1},
nodes = {
{
match = modname.. ":lantern_" ..fuel,
replace = modname.. ":lantern_empty"
}
},
items = {
{name = "nc_fire:lump_coal", count = fuel, scatter = 2}
-- {name = "nc_fire:lump_ash", count = ashes, scatter = ashes}
},
itemscatter = 2
})
----------------------------------------
------------Lantern Recycling-----------
nodecore.register_craft({
label = "break lantern apart",
action = "pummel",
duration = 2,
toolgroups = {choppy = 4},
nodes = {
{
match = {groups = {lantern = true}},
replace = "nc_lode:form"
}
},
items = {
{name = "nc_optics:glass_crude", count = 1, scatter = 1},
{name = "nc_lode:toolhead_mallet_annealed", count = 2, scatter = 3},
{name = "nc_lode:prill_annealed", count = 2, scatter = 4}
-- {name = "nc_fire:lump_coal", count = fuel, scatter = 6},
-- {name = "nc_fire:lump_ash", count = ashes, scatter = ashes}
},
itemscatter = 2
})
----------------------------------------
------------Lantern Ambiance------------
nodecore.register_ambiance({
label = "Flame Ambiance",
nodenames = {modname.. ":lantern_lit_" ..fuel},
interval = 1,
chance = 2,
sound_name = "nc_fire_flamy",
sound_gain = 0.1
})
end
----------------------------------------
---------------Falling Ash--------------
-----Placed-----
nodecore.register_abm({
label = "Lantern Ashing",
interval = 20,
chance = 4,
nodenames = {"group:lantern_lit"},
action = function(pos)
nodecore.item_eject(pos, "nc_fire:lump_ash", 1)
end
})
-----Carried-----
nodecore.register_aism({
label = "Held Lantern Ashing",
interval = 20,
chance = 4,
itemnames = {"group:lantern_lit"},
action = function(stack, data)
nodecore.item_eject(data.pos,"nc_fire:lump_ash",1,1,{x = 1, y = 1, z = 1})
end
})
----------------------------------------
--------------WHEN WIELDED--------------
local litgroup = {}
minetest.after(0, function()
for k, v in pairs(minetest.registered_items) do
if v.groups.lantern_lit then
litgroup[k] = true
end
end
end)
local function islit(stack)
return stack and litgroup[stack:get_name()]
end
local function snuffinv(player, inv, i, fuel)
minetest.sound_play("nc_fire_snuff", {object = player, gain = 0.5})
inv:set_stack("main", i, modname .. ":lantern_"..fuel)
end
local ambtimers = {}
minetest.register_globalstep(function()
local now = nodecore.gametime
for _, player in pairs(minetest.get_connected_players()) do
local inv = player:get_inventory()
local ppos = player:get_pos()
-- Snuff all lanterns if doused in water.
local hpos = vector.add(ppos, {x = 0, y = 1, z = 0})
local head = minetest.get_node(hpos).name
local wielditem = player:get_wielded_item()
local wdef = minetest.registered_items[wielditem:get_name()]
if minetest.get_item_group(head, "water") > 0 then
for i = 1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if islit(stack) then snuffinv(player, inv, i, minetest.get_item_group(stack:get_name(),"lantern_fuel")) end
end
elseif islit(player:get_wielded_item()) then
local bright = lnodes[wdef.light_source]
-- Wield light
local name = player:get_player_name()
-- nodecore.dynamic_light_add(hpos, bright, 0.5)
-- Wield ambiance
local t = ambtimers[name] or 0
if t <= now then
ambtimers[name] = now + 1
minetest.sound_play("nc_fire_flamy",
{object = player, gain = 0.1})
end
else
-- Dimmer non-wielded carry light
for i = 1, inv:get_size("main") do
local stack = inv:get_stack("main", i)
if islit(stack) then
local def = minetest.registered_items[stack:get_name()]
local dim = lnodes[def.light_source - 2]
-- nodecore.dynamic_light_add(hpos, dim, 0.5)
end
end
end
end
end)
-- Apply wield light to entities as well.
local function entlight(self, ...)
local stack = ItemStack(self.node and self.node.name or self.itemstring or "")
local def = minetest.registered_items[stack:get_name()]
if not islit(stack) then return ... end
local bright = lnodes[def.light_source]
-- nodecore.dynamic_light_add(self.object:get_pos(), bright, 0.5)
return ...
end
for _, name in pairs({"item", "falling_node"}) do
local def = minetest.registered_entities["__builtin:" .. name]
local ndef = {
on_step = function(self, ...)
return entlight(self, def.on_step(self, ...))
end
}
setmetatable(ndef, def)
minetest.register_entity(":__builtin:" .. name, ndef)
end
--Lantern-Fuel-Burn-Energy-Light-Refill--
for n=1,nodecore.max_lantern_fuel do
lantern(n)
end

148
luxlamp.lua Normal file
View File

@ -0,0 +1,148 @@
-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore, math
= minetest, nodecore, math
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
------------------------------------------------------------------------
local function luxlamp (desc, id, power, light)
local delum = power-1
local flux = power+1
local charge = power*100
local vlux = power*60
local time = 1000/power
------------------------------------------------------------------------
local particle = "nc_lux_base.png^[mask:nc_lux_dot_mask.png^[opacity:32"
------------------------------------------------------------------------
minetest.register_node(modname .. ":luxlamp_" .. id, {
description = desc.. " Luxlamp",
tiles = {
"nc_optics_glass_frost.png^(nc_lux_base.png^[opacity:" .. vlux .. ")^(nc_lode_annealed.png^[mask:" .. modname .. "_mask_lamp_top.png)",
"nc_lode_annealed.png",
"nc_optics_glass_frost.png^(nc_lux_base.png^[opacity:" .. vlux .. ")^(nc_lode_annealed.png^[mask:" .. modname .. "_mask_lamp_side.png)",
},
drawtype = "nodebox",
paramtype = "light",
light_source = light,
node_box = {
type = "fixed",
fixed = {
{-0.3125, -0.3125, -0.3125, 0.3125, 0.25, 0.3125}, -- Core
{-0.5, -0.375, -0.5, 0.5, -0.25, 0.5}, -- Plate_Large
{-0.375, -0.4375, -0.375, 0.375, -0.375, 0.375}, -- Plate_Med
{-0.25, -0.5, -0.25, 0.25, -0.4375, 0.25}, -- Plate_Small
{-0.375, 0.25, -0.375, 0.375, 0.3125, 0.375}, -- Cap_Large
{-0.25, 0.3125, -0.25, 0.25, 0.375, 0.25}, -- Cap_Med
{-0.125, 0.375, -0.125, 0.125, 0.4375, 0.125}, -- Cap_Small
{-0.0625, 0.4375, -0.0625, 0.0625, 0.5, 0.0625}, -- Cap_Peak
}
},
sunlight_propagates = true,
groups = {
stack_as_node = 1,
snappy = 1,
luxlamp = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_optics_glassy"),
})
---------------------------------------
-----------Luxlamp Crafting------------
nodecore.register_craft({
label = "assemble luxlamp",
action = "stackapply",
indexkeys = {"nc_lode:form"},
wield = {name = "nc_optics:prism"},
consumewield = 1,
nodes = {
{match = "nc_lode:form", replace = "air"},
{y = 1, match = "nc_optics:lens", replace = "air"},
{y = -1, match = "nc_lode:block_annealed", replace = modname .. ":luxlamp_0"},
}
})
---------------------------------------
-----------Luxlamp Recycling-----------
nodecore.register_craft({
label = "break luxlamp apart",
action = "pummel",
toolgroups = {choppy = 5},
nodes = {
{
match = {groups = {luxlamp = true}},
replace = "nc_optics:glass_crude"
}
},
items = {
{name = "nc_lode:rod_tempered", count = 4, scatter = flux},
{name = "nc_lux:flux_flowing", count = flux, scatter = flux}
},
itemscatter = flux
})
---------------------------------------
----------Luxlamp Diminishing----------
nodecore.register_abm({
label = "Luxlamp Delumination",
interval = charge,
chance = 1,
nodenames = {modname .. ":luxlamp_" .. id},
action = function(pos)
if minetest.find_node_near(pos,
1, {"nc_lux:flux_flowing"}) then
return false
end
if power > 0 then
return minetest.set_node(pos, {name = modname .. ":luxlamp_" .. delum})
end
end
})
---------------------------------------
nodecore.register_aism({
label = "Held Delumination",
interval = charge,
chance = 1,
itemnames = {modname .. ":luxlamp_" .. id},
action = function(stack, data)
if power > 0 then
stack:set_name(modname .. ":luxlamp_" .. delum)
return stack
end
end
})
---------------------------------------
-----------Luxlamp Charging------------
nodecore.register_abm({
label = "Luxlamp Effulgence",
nodenames = {"group:luxlamp"},
neighbors = {"nc_lux:flux_source", "nc_lux:flux_flowing"},
interval = time,
chance = 1,
action = function(pos)
nodecore.set_node(pos, {name = modname .. ":luxlamp_5"})
end
})
--nodecore.register_abm({
-- label = "Luxlamp Charging",
-- nodenames = {"group:luxlamp"},
-- neighbors = {"nc_lux:flux_source", "nc_lux:flux_flowing"},
-- interval = 2, --temporary, as a mysterious bug causes serious issue with this value
-- chance = 1,
-- action = function(pos)
-- if power > 4 then
-- nodecore.set_node(pos, {name = modname .. ":luxlamp_" .. flux})
-- elseif 4 then return false
-- end
-- end
-- })
---------------------------------------
---------------------------------------
end
luxlamp("Dull", "0", 0, 1)
luxlamp("Dim", "1", 1, 4)
luxlamp("Lambent", "2", 2, 8)
luxlamp("Radiant", "3", 3, 12)
luxlamp("Brilliant", "4", 4, 16)
luxlamp("Fulgent", "5", 5, 20)

6
mod.conf Normal file
View File

@ -0,0 +1,6 @@
depends = nc_api_all, nc_fire, nc_optics, nc_lode, nc_lux, nc_flora
author = Winter94
description = New light sources for NodeCore
name = wc_luminous
title = NodeCore Lights

209
rushlight.lua Normal file
View File

@ -0,0 +1,209 @@
-- LUALOCALS < ---------------------------------------------------------
local ItemStack, math, minetest, nodecore, pairs, setmetatable, vector
= ItemStack, math, minetest, nodecore, pairs, setmetatable, vector
local math_ceil, math_log, math_random
= math.ceil, math.log, math.random
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local checkdirs = {
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z = -1},
{x = 0, y = 1, z = 0}
}
------------------------------------------------------------------------
nodecore.candle_life_base = 30
------------------------------------------------------------------------
minetest.register_node(modname .. ":rushlight", {
description = "Rushlight",
drawtype = "mesh",
mesh = "nc_torch_torch.obj",
tiles = {
"nc_flora_wicker.png"
},
backface_culling = false,
use_texture_alpha = "clip",
selection_box = nodecore.fixedbox(-1/8, -0.5, -1/8, 1/8, 0.5, 1/8),
collision_box = nodecore.fixedbox(-1/16, -0.5, -1/16, 1/16, 0.5, 1/16),
paramtype = "light",
sunlight_propagates = true,
groups = {
snappy = 1,
falling_repose = 1,
flammable = 1,
firestick = 2,
stack_as_node = 1
},
sounds = nodecore.sounds("nc_terrain_swishy"),
on_ignite = function(pos, node)
minetest.set_node(pos, {name = modname .. ":rushlight_lit"})
nodecore.sound_play("nc_fire_ignite", {gain = 1, pos = pos})
local expire = nodecore.gametime + nodecore.candle_life_base
* (nodecore.boxmuller() * 0.1 + 1)
minetest.get_meta(pos):set_float("expire", expire)
if node and node.count and node.count > 1 then
nodecore.item_disperse(pos, node.name, node.count - 1)
end
return true
end
})
------------------------------------------------------------------------
nodecore.register_craft({
label = "assemble rushlight",
action = "pummel",
duration = 2,
indexkeys = {"nc_flora:rush_dry"},
wield = {name = "nc_woodwork:staff"},
consumewield = 1,
nodes = {
{match = {name = "nc_flora:rush_dry", count = 2}, replace = "air"}
},
items = {
{name = modname .. ":rushlight"}
}
})
------------------------------------------------------------------------
nodecore.candle_life_stages = 4
for i = 1, nodecore.candle_life_stages do
local alpha = (i - 1) * (256 / nodecore.candle_life_stages)
if alpha > 255 then alpha = 255 end
local txr = "nc_flora_wicker.png^nc_fire_ember_4.png^(nc_fire_ash.png^[opacity:"
.. alpha .. ")"
minetest.register_node(modname .. ":rushlight_lit_" .. i, {
description = "Lit Rushlight",
drawtype = "mesh",
mesh = "nc_torch_torch.obj",
tiles = {
txr,
"nc_flora_wicker.png",
txr .. "^[lowpart:50:nc_flora_wicker.png",
{
name = "nc_torch_flame.png",
animation = {
["type"] = "vertical_frames",
aspect_w = 3,
aspect_h = 8,
length = 0.6
}
}
},
backface_culling = false,
use_texture_alpha = "clip",
selection_box = nodecore.fixedbox(-1/8, -0.5, -1/8, 1/8, 0.5, 1/8),
collision_box = nodecore.fixedbox(-1/16, -0.5, -1/16, 1/16, 0.5, 1/16),
paramtype = "light",
sunlight_propagates = true,
light_source = 6 - i,
groups = {
snappy = 1,
falling_repose = 1,
stack_as_node = 1,
candle_lit = 1,
flame_ambiance = 1
--igniter = 1
},
stack_max = 1,
sounds = nodecore.sounds("nc_terrain_swishy"),
preserve_metadata = function(_, _, oldmeta, drops)
drops[1]:get_meta():from_table({fields = oldmeta})
end,
after_place_node = function(pos, _, itemstack)
minetest.get_meta(pos):from_table(itemstack:get_meta():to_table())
end,
node_dig_prediction = nodecore.dynamic_light_node(6 - i),
after_destruct = function(pos)
nodecore.dynamic_light_add(pos, 6 - i)
end
})
end
------------------------------------------------------------------------
minetest.register_abm({
label = "rushlite ignite",
interval = 6,
chance = 1,
nodenames = {"group:candle_lit"},
neighbors = {"group:flammable"},
action_delay = true,
action = function(pos)
for _, ofst in pairs(checkdirs) do
local npos = vector.add(pos, ofst)
local nbr = minetest.get_node(npos)
if minetest.get_item_group(nbr.name, "flammable") > 0
and not nodecore.quenched(npos) then
nodecore.fire_check_ignite(npos, nbr)
end
end
end
})
------------------------------------------------------------------------
local log2 = math_log(2)
local function candlelife(expire)
local max = nodecore.candle_life_stages
if expire <= nodecore.gametime then return max end
local life = (expire - nodecore.gametime) / nodecore.candle_life_base
if life > 1 then return 1 end
local stage = 1 - math_ceil(math_log(life) / log2)
if stage < 1 then return 1 end
if stage > max then return max end
return stage
end
------------------------------------------------------------------------
minetest.register_abm({
label = "candle snuff",
interval = 1,
chance = 1,
nodenames = {"group:candle_lit"},
action = function(pos, node)
local expire = minetest.get_meta(pos):get_float("expire") or 0
if nodecore.quenched(pos) or nodecore.gametime > expire then
minetest.remove_node(pos)
minetest.add_item(pos, {name = "nc_fire:lump_ash"})
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
return
end
local nn = modname .. ":rushlight_lit_" .. candlelife(expire)
if node.name ~= nn then
node.name = nn
return minetest.swap_node(pos, node)
end
end
})
------------------------------------------------------------------------
nodecore.register_aism({
label = "rushlight stack interact",
itemnames = {"group:candle_lit"},
action = function(stack, data)
local expire = stack:get_meta():get_float("expire") or 0
if expire < nodecore.gametime then
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = data.pos})
return "nc_fire:lump_ash"
end
local pos = data.pos
local player = data.player
local wield
if player and data.list == "main"
and player:get_wield_index() == data.slot then
wield = true
pos = vector.add(pos, vector.multiply(player:get_look_dir(), 0.5))
end
if nodecore.quenched(pos, data.node and 1 or 0.3) then
nodecore.sound_play("nc_fire_snuff", {gain = 1, pos = pos})
return "nc_fire:lump_ash"
end
if wield and math_random() < 0.1 then nodecore.fire_check_ignite(pos) end
local nn = modname .. ":rushlight_lit_" .. candlelife(expire)
if stack:get_name() ~= nn then
stack:set_name(nn)
return stack
end
end
})
------------------------------------------------------------------------
minetest.register_alias(modname .. ":rushlight_lit", modname .. ":rushlight_lit_1")
------------------------------------------------------------------------

52
smoke.lua Normal file
View File

@ -0,0 +1,52 @@
-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore, math
= minetest, nodecore, math
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
------------------------------------------------------------------------
local function smokey(posa, posb)
posb=posb or posa
local minpos = {
x = (posa.x < posb.x and posa.x or posb.x) - 0.25,
y = (posa.y < posb.y and posa.y or posb.y) - 0,
z = (posa.z < posb.z and posa.z or posb.z) - 0.25
}
local maxpos = {
x = (posa.x > posb.x and posa.x or posb.x) + 0.25,
y = (posa.y > posb.y and posa.y or posb.y) + 0,
z = (posa.z > posb.z and posa.z or posb.z) + 0.25
}
local volume = (maxpos.x - minpos.x + 1) * (maxpos.y - minpos.y + 1)
* (maxpos.z - minpos.z + 1)
minetest.add_particlespawner({
amount = 3 * volume,
time = 10,
minpos = minpos,
maxpos = maxpos,
minvel = {x = -0.1, y = 0.25, z = -0.1},
maxvel = {x = 0.1, y = 0.75, z = 0.1},
texture = "nc_api_craft_smoke.png^[opacity:150",
minexptime = 2,
maxexptime = 12,
collisiondetection = true,
minsize = 1,
maxsize = 4
})
end
------------------------------------------------------------------------
nodecore.register_abm({
label = "particles:incense",
interval = 10,
chance = 1,
nodenames = {modname.. ":incense_lit"},
action = function(pos)
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
local abnod = minetest.get_node(above)
local top = {x = pos.x, y = pos.y + 0.5, z = pos.z}
if abnod.name == "air" then
smokey(top)
end
end
})

2
sounds/license.txt Normal file
View File

@ -0,0 +1,2 @@
gas_hiss.1 is from https://freesound.org/people/wubitog/sounds/234782/ under the public domain (CC0)
gas_hiss.2 is from https://freesound.org/people/kgatto/sounds/240263/ by kgatto under the CC-BY-3.0 license

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B