revamp spindlestems into a sort of mineral detector, add glowing extract bottles

This commit is contained in:
FaceDeer 2019-08-03 22:30:55 -06:00
parent badcc5e8e0
commit 7631386f29
4 changed files with 144 additions and 80 deletions

View File

@ -3,3 +3,4 @@ intllib?
doc? doc?
moreblocks? moreblocks?
stairs? stairs?
vessels?

View File

@ -2,9 +2,14 @@
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP.."/intllib.lua") 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 -- Copied from subterrane's features.lua
-- Figured that was nicer than adding a dependency for just this little bit -- 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 local pt = pointed_thing
-- check if pointing at a node -- check if pointing at a node
if not pt then if not pt then
@ -56,7 +61,7 @@ end
local disp = 0.0625 -- adjusting position a bit local disp = 0.0625 -- adjusting position a bit
minetest.register_node("df_trees:spindleshroom_stem", { minetest.register_node("df_trees:spindleshroom_stem", {
description = S("Spindleshroom Stem"), description = S("Spindlestem"),
is_ground_content = true, is_ground_content = true,
groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, spindleshroom = 1}, groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, spindleshroom = 1},
sounds = default.node_sound_wood_defaults(), 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}, {-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({ minetest.register_craft({
@ -83,14 +88,21 @@ minetest.register_craft({
burntime = 5, burntime = 5,
}) })
local cap_def = function(item_name, seedling_item, color_name, color_code, light_level) local register_spindleshroom_type = function(item_suffix, colour_name, colour_code, light_level)
return { local cap_item = "df_trees:spindleshroom_cap_"..item_suffix
description = S("@1 Spindleshroom Cap", color_name),
minetest.register_node(cap_item, {
description = S("@1 Spindlestem Cap", color_name),
is_ground_content = true, is_ground_content = true,
groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, spindleshroom = 1}, groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2, spindleshroom = 1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
tiles = { 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, light_source = light_level,
drawtype = "nodebox", 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 -- Choose max_items randomly from this list
items = { 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 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 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 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 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 height = meta:get_int("spindleshroom_to_grow")
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
minetest.set_node(pos, {name="df_trees:spindleshroom_stem", param2 = node.param2}) 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 height = height - 1
if height > 0 then if height > 0 then
meta = minetest.get_meta(above) meta = minetest.get_meta(above)
@ -152,77 +164,59 @@ local cap_def = function(item_name, seedling_item, color_name, color_code, light
minetest.get_node_timer(above):start(growth_delay()) minetest.get_node_timer(above):start(growth_delay())
end end
end, end,
} })
end
local seedling_construct = function(pos)
local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
if minetest.get_item_group(below_node.name, "soil") > 0 then
minetest.get_node_timer(pos):start(growth_delay())
end
end
local seedling_def = function(item_name, color_name, color_code)
return {
description = S("@1 Spindleshroom Spawn", color_name),
_doc_items_longdesc = nil,
_doc_items_usagehelp = nil,
tiles = {
"dfcaverns_tower_cap.png^[multiply:#"..color_code,
},
groups = {snappy = 3, flammable = 2, plant = 1, attached_node = 1, light_sensitive_fungus = 11, digtron_on_place=1},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
floodable = true,
node_box = {
type = "fixed",
fixed = {
{-0.0625 + 0.125, -0.5, -0.125 + 0.125, 0.125 + 0.125, -0.375, 0.0625 + 0.125},
}
},
on_place = stal_on_place,
on_construct = seedling_construct,
on_timer = function(pos, elapsed)
local node = minetest.get_node(pos)
minetest.set_node(pos, {name=item_name, param2 = node.param2})
local meta = minetest.get_meta(pos)
local height = math.random(1,5)-1
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)
)
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = cap_item, recipe = cap_item,
burntime = 10, 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_stem = minetest.get_content_id("df_trees:spindleshroom_stem")
local c_cap = minetest.get_content_id(cap_item) 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) return function(vi, area, data, data_param2)
local stem_height = math.random(1,5)-1 local stem_height = math.random(1,5)-1
local param2 = math.random(1,4)-1 local param2 = math.random(1,4)-1
@ -239,8 +233,77 @@ local register_spindleshroom_type = function(item_suffix, colour_name, colour_co
end end
end end
df_trees.spawn_spindleshroom_white_vm = register_spindleshroom_type("_white", S("White"), "FFFFFF", 0) local seedling_construct = function(pos)
df_trees.spawn_spindleshroom_cyan_vm = register_spindleshroom_type("_cyan", S("Cyan"), "C3FFFF", 2) local below_node = minetest.get_node(vector.add(pos, {x=0,y=-1,z=0}))
df_trees.spawn_spindleshroom_red_vm = register_spindleshroom_type("_red", S("Red"), "FFC3C3", 4) if minetest.get_item_group(below_node.name, "soil") > 0 then
df_trees.spawn_spindleshroom_green_vm = register_spindleshroom_type("_green", S("Green"), "C3FFC3", 2) minetest.get_node_timer(pos):start(growth_delay())
df_trees.spawn_spindleshroom_red_vm = register_spindleshroom_type("_golden", S("Golden"), "FFFFC3", 12) end
end
minetest.register_node("df_trees:spindleshroom_seedling", {
description = S("Spindlestem Spawn"),
_doc_items_longdesc = nil,
_doc_items_usagehelp = nil,
tiles = {
"dfcaverns_tower_cap.png",
},
groups = {snappy = 3, flammable = 2, plant = 1, attached_node = 1, light_sensitive_fungus = 11, digtron_on_place=1},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
walkable = false,
floodable = true,
node_box = {
type = "fixed",
fixed = {
{-0.0625 + 0.125, -0.5, -0.125 + 0.125, 0.125 + 0.125, -0.375, 0.0625 + 0.125},
}
},
on_place = stal_on_place,
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=cap_item, param2 = node.param2})
local meta = minetest.get_meta(pos)
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,
})
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)
get_cap_type = function(pos)
if pos.y > -100 then
return "white"
end
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B