mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2024-12-25 18:30:36 +01:00
revamp spindlestems into a sort of mineral detector, add glowing extract bottles
This commit is contained in:
parent
badcc5e8e0
commit
7631386f29
@ -3,3 +3,4 @@ intllib?
|
||||
doc?
|
||||
moreblocks?
|
||||
stairs?
|
||||
vessels?
|
@ -2,9 +2,14 @@
|
||||
local MP = minetest.get_modpath(minetest.get_current_modname())
|
||||
local S, NS = dofile(MP.."/intllib.lua")
|
||||
|
||||
local vessels = minetest.get_modpath("vessels")
|
||||
|
||||
-- pre-declare
|
||||
local get_cap_type
|
||||
|
||||
-- Copied from subterrane's features.lua
|
||||
-- Figured that was nicer than adding a dependency for just this little bit
|
||||
local stal_on_place = function(itemstack, placer, pointed_thing)
|
||||
local stem_on_place = function(itemstack, placer, pointed_thing)
|
||||
local pt = pointed_thing
|
||||
-- check if pointing at a node
|
||||
if not pt then
|
||||
@ -56,7 +61,7 @@ end
|
||||
local disp = 0.0625 -- adjusting position a bit
|
||||
|
||||
minetest.register_node("df_trees:spindleshroom_stem", {
|
||||
description = S("Spindleshroom Stem"),
|
||||
description = S("Spindlestem"),
|
||||
is_ground_content = true,
|
||||
groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, spindleshroom = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
@ -74,7 +79,7 @@ minetest.register_node("df_trees:spindleshroom_stem", {
|
||||
{-0.125+disp, -0.5, -0.0625+disp, 0.25+disp, 0.5, 0.1875+disp},
|
||||
}
|
||||
},
|
||||
on_place = stal_on_place,
|
||||
on_place = stem_on_place,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
@ -83,14 +88,21 @@ minetest.register_craft({
|
||||
burntime = 5,
|
||||
})
|
||||
|
||||
local cap_def = function(item_name, seedling_item, color_name, color_code, light_level)
|
||||
return {
|
||||
description = S("@1 Spindleshroom Cap", color_name),
|
||||
local register_spindleshroom_type = function(item_suffix, colour_name, colour_code, light_level)
|
||||
local cap_item = "df_trees:spindleshroom_cap_"..item_suffix
|
||||
|
||||
minetest.register_node(cap_item, {
|
||||
description = S("@1 Spindlestem Cap", color_name),
|
||||
is_ground_content = true,
|
||||
groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, spindleshroom = 1},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
tiles = {
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..color_code,
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..colour_code,
|
||||
"dfcaverns_spindlestem_cap.png^[multiply:#"..colour_code,
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..colour_code,
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..colour_code,
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..colour_code,
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..colour_code,
|
||||
},
|
||||
light_source = light_level,
|
||||
drawtype = "nodebox",
|
||||
@ -113,19 +125,19 @@ local cap_def = function(item_name, seedling_item, color_name, color_code, light
|
||||
-- Choose max_items randomly from this list
|
||||
items = {
|
||||
{
|
||||
items = {item_name, seedling_item}, -- Items to drop
|
||||
items = {cap_item, "df_trees:spindleshroom_seedling"}, -- Items to drop
|
||||
rarity = 2, -- Probability of dropping is 1 / rarity
|
||||
},
|
||||
{
|
||||
items = {item_name, seedling_item, seedling_item}, -- Items to drop
|
||||
items = {cap_item, "df_trees:spindleshroom_seedling", "df_trees:spindleshroom_seedling"}, -- Items to drop
|
||||
rarity = 2, -- Probability of dropping is 1 / rarity
|
||||
},
|
||||
{
|
||||
items = {item_name, seedling_item, seedling_item, seedling_item}, -- Items to drop
|
||||
items = {cap_item, "df_trees:spindleshroom_seedling", "df_trees:spindleshroom_seedling", "df_trees:spindleshroom_seedling"}, -- Items to drop
|
||||
rarity = 2, -- Probability of dropping is 1 / rarity
|
||||
},
|
||||
{
|
||||
items = {item_name}, -- Items to drop
|
||||
items = {cap_item}, -- Items to drop
|
||||
rarity = 1, -- Probability of dropping is 1 / rarity
|
||||
},
|
||||
},
|
||||
@ -144,7 +156,7 @@ local cap_def = function(item_name, seedling_item, color_name, color_code, light
|
||||
local height = meta:get_int("spindleshroom_to_grow")
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name="df_trees:spindleshroom_stem", param2 = node.param2})
|
||||
minetest.set_node(above, {name=item_name, param2 = node.param2})
|
||||
minetest.set_node(above, {name=cap_item, param2 = node.param2})
|
||||
height = height - 1
|
||||
if height > 0 then
|
||||
meta = minetest.get_meta(above)
|
||||
@ -152,7 +164,73 @@ local cap_def = function(item_name, seedling_item, color_name, color_code, light
|
||||
minetest.get_node_timer(above):start(growth_delay())
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = cap_item,
|
||||
burntime = 10,
|
||||
})
|
||||
|
||||
local c_stem = minetest.get_content_id("df_trees:spindleshroom_stem")
|
||||
local c_cap = minetest.get_content_id(cap_item)
|
||||
|
||||
if vessels and light_level > 0 then
|
||||
local tex = "dfcaverns_vessels_glowing_liquid.png^[multiply:#"..colour_code.."^vessels_glass_bottle.png"
|
||||
local new_light = light_level + math.floor((minetest.LIGHT_MAX-light_level)/2)
|
||||
minetest.register_node("df_trees:glowing_bottle_"..item_suffix, {
|
||||
description = S("@1 Spindlestem Extract", colour_name),
|
||||
drawtype = "plantlike",
|
||||
tiles = {tex},
|
||||
inventory_image = tex,
|
||||
wield_image = tex,
|
||||
paramtype = "light",
|
||||
is_ground_content = false,
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25}
|
||||
},
|
||||
groups = {vessel = 1, dig_immediate = 3, attached_node = 1},
|
||||
sounds = default.node_sound_glass_defaults(),
|
||||
light_source = new_light,
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "df_trees:glowing_bottle_"..item_suffix.." 3",
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
"vessels:glass_bottle",
|
||||
"vessels:glass_bottle",
|
||||
"vessels:glass_bottle",
|
||||
cap_item,
|
||||
}
|
||||
})
|
||||
|
||||
minetest.register_craft( {
|
||||
output = "vessels:glass_bottle",
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
"df_trees:glowing_bottle_"..item_suffix,
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- mapgen function
|
||||
return function(vi, area, data, data_param2)
|
||||
local stem_height = math.random(1,5)-1
|
||||
local param2 = math.random(1,4)-1
|
||||
local i = 0
|
||||
while i < stem_height do
|
||||
index = vi + i * area.ystride
|
||||
data[index] = c_stem
|
||||
data_param2[index] = param2
|
||||
i = i + 1
|
||||
end
|
||||
index = vi + i * area.ystride
|
||||
data[index] = c_cap
|
||||
data_param2[index] = param2
|
||||
end
|
||||
end
|
||||
|
||||
local seedling_construct = function(pos)
|
||||
@ -162,13 +240,12 @@ local seedling_construct = function(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local seedling_def = function(item_name, color_name, color_code)
|
||||
return {
|
||||
description = S("@1 Spindleshroom Spawn", color_name),
|
||||
minetest.register_node("df_trees:spindleshroom_seedling", {
|
||||
description = S("Spindlestem Spawn"),
|
||||
_doc_items_longdesc = nil,
|
||||
_doc_items_usagehelp = nil,
|
||||
tiles = {
|
||||
"dfcaverns_tower_cap.png^[multiply:#"..color_code,
|
||||
"dfcaverns_tower_cap.png",
|
||||
},
|
||||
groups = {snappy = 3, flammable = 2, plant = 1, attached_node = 1, light_sensitive_fungus = 11, digtron_on_place=1},
|
||||
drawtype = "nodebox",
|
||||
@ -187,60 +264,46 @@ local seedling_def = function(item_name, color_name, color_code)
|
||||
on_construct = seedling_construct,
|
||||
|
||||
on_timer = function(pos, elapsed)
|
||||
local cap_item = "df_trees:spindleshroom_cap_"..get_cap_type(pos)
|
||||
local node = minetest.get_node(pos)
|
||||
minetest.set_node(pos, {name=item_name, param2 = node.param2})
|
||||
minetest.set_node(pos, {name=cap_item, param2 = node.param2})
|
||||
local meta = minetest.get_meta(pos)
|
||||
local height = math.random(1,5)-1
|
||||
local disp = {x=3, y=3, z=3}
|
||||
local nearby = minetest.find_nodes_in_area(vector.add(pos, disp), vector.subtract(pos, disp), {"group:spindleshroom"})
|
||||
local count = #nearby
|
||||
local height = math.random(1,3)-1
|
||||
if count > 10 then height = height + 2 end -- if there are a lot of nearby spindleshrooms, grow taller
|
||||
if height > 0 then
|
||||
meta:set_int("spindleshroom_to_grow", height)
|
||||
minetest.get_node_timer(pos):start(growth_delay())
|
||||
end
|
||||
end,
|
||||
}
|
||||
end
|
||||
})
|
||||
|
||||
local register_spindleshroom_type = function(item_suffix, colour_name, colour_code, light_level)
|
||||
local cap_item = "df_trees:spindleshroom_cap"..item_suffix
|
||||
local seedling_item = "df_trees:spindleshroom_seedling"..item_suffix
|
||||
minetest.register_node(cap_item,
|
||||
cap_def(cap_item, seedling_item, colour_name, colour_code, light_level)
|
||||
)
|
||||
minetest.register_node(seedling_item,
|
||||
seedling_def(cap_item, colour_name, colour_code)
|
||||
)
|
||||
df_trees.spawn_spindleshroom_white_vm = register_spindleshroom_type("white", S("White"), "FFFFFF", 0)
|
||||
df_trees.spawn_spindleshroom_red_vm = register_spindleshroom_type("red", S("Red"), "FFC3C3", 3)
|
||||
df_trees.spawn_spindleshroom_green_vm = register_spindleshroom_type("green", S("Green"), "C3FFC3", 4)
|
||||
df_trees.spawn_spindleshroom_cyan_vm = register_spindleshroom_type("cyan", S("Cyan"), "C3FFFF", 6)
|
||||
df_trees.spawn_spindleshroom_red_vm = register_spindleshroom_type("golden", S("Golden"), "FFFFC3", 12)
|
||||
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = cap_item,
|
||||
burntime = 10,
|
||||
})
|
||||
minetest.register_craft({
|
||||
type = "fuel",
|
||||
recipe = seedling_item,
|
||||
burntime = 3,
|
||||
})
|
||||
|
||||
local c_stem = minetest.get_content_id("df_trees:spindleshroom_stem")
|
||||
local c_cap = minetest.get_content_id(cap_item)
|
||||
|
||||
return function(vi, area, data, data_param2)
|
||||
local stem_height = math.random(1,5)-1
|
||||
local param2 = math.random(1,4)-1
|
||||
local i = 0
|
||||
while i < stem_height do
|
||||
index = vi + i * area.ystride
|
||||
data[index] = c_stem
|
||||
data_param2[index] = param2
|
||||
i = i + 1
|
||||
get_cap_type = function(pos)
|
||||
if pos.y > -100 then
|
||||
return "white"
|
||||
end
|
||||
index = vi + i * area.ystride
|
||||
data[index] = c_cap
|
||||
data_param2[index] = param2
|
||||
local iron = minetest.find_node_near(pos, 10, {"default:stone_with_iron", "default:steelblock"})
|
||||
local copper = minetest.find_node_near(pos, 10, {"default:stone_with_copper", "default:copperblock"})
|
||||
local mese = minetest.find_node_near(pos, 10, {"default:stone_with_mese", "default:mese"})
|
||||
local possibilities = {}
|
||||
|
||||
if mese then table.insert(possibilities, "golden") end
|
||||
if copper then table.insert(possibilities, "green") end
|
||||
if iron then table.insert(possibilities, "red") end
|
||||
if iron and copper then table.insert(possibilities, "cyan") end
|
||||
|
||||
if #possibilities == 0 then
|
||||
return "white"
|
||||
else
|
||||
local pick = math.random(1, #possibilities)
|
||||
return possibilities[pick]
|
||||
end
|
||||
end
|
||||
|
||||
df_trees.spawn_spindleshroom_white_vm = register_spindleshroom_type("_white", S("White"), "FFFFFF", 0)
|
||||
df_trees.spawn_spindleshroom_cyan_vm = register_spindleshroom_type("_cyan", S("Cyan"), "C3FFFF", 2)
|
||||
df_trees.spawn_spindleshroom_red_vm = register_spindleshroom_type("_red", S("Red"), "FFC3C3", 4)
|
||||
df_trees.spawn_spindleshroom_green_vm = register_spindleshroom_type("_green", S("Green"), "C3FFC3", 2)
|
||||
df_trees.spawn_spindleshroom_red_vm = register_spindleshroom_type("_golden", S("Golden"), "FFFFC3", 12)
|
||||
|
BIN
df_trees/textures/dfcaverns_spindlestem_cap.png
Normal file
BIN
df_trees/textures/dfcaverns_spindlestem_cap.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 290 B |
BIN
df_trees/textures/dfcaverns_vessels_glowing_liquid.png
Normal file
BIN
df_trees/textures/dfcaverns_vessels_glowing_liquid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 327 B |
Loading…
Reference in New Issue
Block a user