2022-08-19 05:40:45 +02:00
local S = minetest.get_translator ( minetest.get_current_modname ( ) )
local nethercap_name = df_dependencies.nethercap_name
2022-08-20 03:42:13 +02:00
local hoe_texture = df_dependencies.texture_tool_steelhoe
local soil_texture = df_dependencies.texture_farming_soil
local ice_texture = df_dependencies.texture_ice
local coal_ore = " ( " .. df_dependencies.texture_stone .. " ^ " .. df_dependencies.texture_mineral_coal .. " ) "
local make_texture = function ( plant_texture , bg_tex )
bg_tex = bg_tex or soil_texture
return " dfcaverns_awards_backgroundx32.png^[combine:32x32:3,4= " .. bg_tex .. " ^[combine:32x32:3,2= " .. plant_texture .. " ^[combine:32x32:14,13= " .. hoe_texture .. " ^dfcaverns_awards_foregroundx32.png "
end
2022-08-19 05:40:45 +02:00
-- forestry
local plant_node_achievements =
{
2022-08-21 07:26:13 +02:00
[ " df_trees:black_cap_sapling " ] = { achievement = " dfcaverns_plant_black_cap " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Black Cap " ) , icon = make_texture ( " dfcaverns_black_cap_sapling.png " , coal_ore ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:fungiwood_sapling " ] = { achievement = " dfcaverns_plant_fungiwood " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Fungiwood " ) , icon = make_texture ( " dfcaverns_fungiwood_sapling.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:goblin_cap_sapling " ] = { achievement = " dfcaverns_plant_goblin_cap " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Goblin Cap " ) , icon = make_texture ( " dfcaverns_goblin_cap_sapling.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:nether_cap_sapling " ] = { achievement = " dfcaverns_plant_nethercap " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant @1 " , nethercap_name ) , icon = make_texture ( " dfcaverns_nether_cap_sapling.png " , ice_texture ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:spore_tree_sapling " ] = { achievement = " dfcaverns_plant_spore_tree " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Spore Tree " ) , icon = make_texture ( " dfcaverns_spore_tree_sapling.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:tower_cap_sapling " ] = { achievement = " dfcaverns_plant_tower_cap " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Tower Cap " ) , icon = make_texture ( " dfcaverns_tower_cap_sapling.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:tunnel_tube_sapling " ] = { achievement = " dfcaverns_plant_tunnel_tube " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Tunnel Tube " ) , icon = make_texture ( " dfcaverns_tunnel_tube_sapling.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:torchspine_ember " ] = { achievement = " dfcaverns_plant_torchspine " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Torchspine " ) , icon = make_texture ( " dfcaverns_torchspine_achievement.png " , coal_ore ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:spindlestem_seedling " ] = { achievement = " dfcaverns_plant_spindlestem " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Spindlestem " ) , icon = make_texture ( " dfcaverns_spindlestem_achievement.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_trees:blood_thorn " ] = { achievement = " dfcaverns_plant_bloodthorn " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Bloodthorn " ) , icon = make_texture ( " dfcaverns_bloodthorn_achievement.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_upper_trees " , " dfcaverns_plant_all_underground_trees " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_primordial_items:giant_hypha_apical_meristem " ] = { achievement = " dfcaverns_plant_giant_mycelium " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Primordial Mycelium " ) , icon = make_texture ( " dfcaverns_mush_soil.png " ) , secret = true , _dfcaverns_achievements = { " dfcaverns_plant_all_primordial " , " dfcaverns_plant_all_underground_trees " } , difficulty = 3 , } ,
2022-08-21 07:26:13 +02:00
[ " df_primordial_items:fern_sapling " ] = { achievement = " dfcaverns_plant_primordial_fern " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Primordial Fern " ) , icon = make_texture ( " dfcaverns_jungle_fern_03.png " ) , secret = true , _dfcaverns_achievements = { " dfcaverns_plant_all_primordial " , " dfcaverns_plant_all_underground_trees " } , difficulty = 3 , } ,
2022-08-21 07:26:13 +02:00
[ " df_primordial_items:jungle_mushroom_sapling " ] = { achievement = " dfcaverns_plant_primordial_jungle_mushroom " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Primordial Jungle Mushroom " ) , icon = make_texture ( " dfcaverns_jungle_mushroom_02.png " ) , secret = true , _dfcaverns_achievements = { " dfcaverns_plant_all_primordial " , " dfcaverns_plant_all_underground_trees " } , difficulty = 3 , } ,
2022-08-21 07:26:13 +02:00
[ " df_primordial_items:jungletree_sapling " ] = { achievement = " dfcaverns_plant_primordial_jungletree " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Primordial Jungle Tree " ) , icon = make_texture ( " dfcaverns_jungle_sapling.png " ) , secret = true , _dfcaverns_achievements = { " dfcaverns_plant_all_primordial " , " dfcaverns_plant_all_underground_trees " } , difficulty = 3 , } ,
2022-08-21 07:26:13 +02:00
[ " df_primordial_items:mush_sapling " ] = { achievement = " dfcaverns_plant_primordial_mushroom " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Primordial Mushroom " ) , icon = make_texture ( " dfcaverns_mush_sapling.png " ) , secret = true , _dfcaverns_achievements = { " dfcaverns_plant_all_primordial " , " dfcaverns_plant_all_underground_trees " } , difficulty = 3 , } ,
2022-08-21 07:26:13 +02:00
[ " df_farming:cave_wheat_seed " ] = { achievement = " dfcaverns_plant_cave_wheat " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Cave Wheat " ) , icon = make_texture ( " dfcaverns_cave_wheat_8.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_farmables " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_farming:dimple_cup_seed " ] = { achievement = " dfcaverns_plant_dimple_cup " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Dimple Cup " ) , icon = make_texture ( " dfcaverns_dimple_cup_4.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_farmables " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_farming:pig_tail_seed " ] = { achievement = " dfcaverns_plant_pig_tail " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Pig Tail " ) , icon = make_texture ( " dfcaverns_pig_tail_8.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_farmables " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_farming:plump_helmet_spawn " ] = { achievement = " dfcaverns_plant_plump_helmet " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Plump Helmet " ) , icon = make_texture ( " dfcaverns_plump_helmet_achievement.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_farmables " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_farming:quarry_bush_seed " ] = { achievement = " dfcaverns_plant_quarry_bush " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Quarry Bush " ) , icon = make_texture ( " dfcaverns_quarry_bush_5.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_farmables " } , difficulty = 1 , } ,
2022-08-21 07:26:13 +02:00
[ " df_farming:sweet_pod_seed " ] = { achievement = " dfcaverns_plant_sweet_pod " ,
2022-08-21 08:23:52 +02:00
title = S ( " Plant Sweet Pod " ) , icon = make_texture ( " dfcaverns_sweet_pod_6.png " ) , _dfcaverns_achievements = { " dfcaverns_plant_all_farmables " } , difficulty = 1 , } ,
2022-08-19 05:40:45 +02:00
}
minetest.register_on_placenode ( function ( pos , newnode , placer , oldnode , itemstack , pointed_thing )
local player_name = placer : get_player_name ( )
if player_name == nil then return end
local player_awards = awards.player ( player_name )
local achievement = plant_node_achievements [ newnode.name ]
if not achievement then return end
local achievement_name = achievement.achievement
2022-08-22 00:38:34 +02:00
if not player_awards.unlocked or player_awards.unlocked [ achievement_name ] ~= achievement_name then
2022-08-19 05:40:45 +02:00
-- all of the growable plants in DFCaverns are timer-based. If you place
-- a seedling or seed and the resulting node has a timer running, then
-- it's passed the checks to see if it was placed in a growable area.
if minetest.get_node_timer ( pos ) : is_started ( ) then
awards.unlock ( player_name , achievement_name )
end
end
end )
2022-08-21 08:23:52 +02:00
for seed_item , def in pairs ( plant_node_achievements ) do
2022-08-19 09:05:57 +02:00
awards.register_achievement ( def.achievement , {
2022-08-19 05:40:45 +02:00
title = def.title ,
2022-08-21 08:23:52 +02:00
description = S ( " Plant a @1 in a place where it can grow. " , minetest.registered_items [ seed_item ] . description ) ,
2022-08-20 03:42:13 +02:00
icon = def.icon ,
2022-08-21 03:39:20 +02:00
secret = def.secret ,
2022-08-21 07:26:13 +02:00
_dfcaverns_achievements = def._dfcaverns_achievements ,
2022-08-19 05:40:45 +02:00
} )
end
awards.register_achievement ( " dfcaverns_plant_all_upper_trees " , {
2022-08-25 06:23:07 +02:00
title = S ( " Fungal Arborist " ) ,
2022-08-21 07:26:13 +02:00
description = S ( " Plant one of every kind of 'tree' found in the caverns above the Sunless Sea. " ) ,
2022-08-21 03:39:20 +02:00
icon = " dfcaverns_awards_backgroundx32.png^ "
.. " (dfcaverns_awards_cavern_towercapx32.png^dfcaverns_awards_cavern_fungiwoodx32.png^dfcaverns_awards_cavern_goblincapx32.png)^[transformFX "
.. " ^[combine:32x32:16,15= " .. hoe_texture .. " ^dfcaverns_awards_foregroundx32.png " ,
2022-08-21 08:23:52 +02:00
difficulty = 1 / df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_upper_trees " ) ,
2022-08-21 07:26:13 +02:00
trigger = {
type = " dfcaverns_achievements " ,
achievement_name = " dfcaverns_plant_all_upper_trees " ,
target = df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_upper_trees " ) ,
} ,
2022-08-19 05:40:45 +02:00
} )
awards.register_achievement ( " dfcaverns_plant_all_primordial " , {
2022-08-25 06:23:07 +02:00
title = S ( " Primordial Arborist " ) ,
2022-08-21 07:26:13 +02:00
description = S ( " Plant one of every kind of 'tree' from the Primordial caverns. " ) ,
2022-08-21 03:39:20 +02:00
icon = " dfcaverns_awards_backgroundx32.png^ "
.. " (dfcaverns_awards_cavern_primordial_mushx32.png^dfcaverns_awards_cavern_junglex32.png)^[transformFX "
.. " ^[combine:32x32:16,15= " .. hoe_texture .. " ^dfcaverns_awards_foregroundx32.png " ,
secret = true ,
2022-08-21 08:23:52 +02:00
difficulty = 3 / df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_primordial " ) ,
2022-08-21 07:26:13 +02:00
trigger = {
type = " dfcaverns_achievements " ,
achievement_name = " dfcaverns_plant_all_primordial " ,
target = df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_primordial " ) ,
} ,
2022-08-19 05:40:45 +02:00
} )
awards.register_achievement ( " dfcaverns_plant_all_underground_trees " , {
2022-08-25 06:23:07 +02:00
title = S ( " Underground Arborist " ) ,
2022-08-21 07:26:13 +02:00
description = S ( " Plant one of every kind of 'tree' found in the caverns beneath the surface. " ) ,
2022-08-21 03:39:20 +02:00
icon = " dfcaverns_awards_backgroundx32.png^ "
.. " (dfcaverns_awards_cavern_towercapx32.png^dfcaverns_awards_cavern_fungiwoodx32.png^dfcaverns_awards_cavern_goblincapx32.png)^[transformFX "
.. " ^dfcaverns_awards_cavern_primordial_mushx32.png^dfcaverns_awards_cavern_junglex32.png "
.. " ^[combine:32x32:16,15= " .. hoe_texture .. " ^dfcaverns_awards_foregroundx32.png " ,
2022-08-21 08:23:52 +02:00
difficulty = 4 / df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_underground_trees " ) ,
2022-08-21 07:26:13 +02:00
trigger = {
type = " dfcaverns_achievements " ,
achievement_name = " dfcaverns_plant_all_underground_trees " ,
target = df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_underground_trees " ) ,
} ,
2022-08-19 05:40:45 +02:00
} )
awards.register_achievement ( " dfcaverns_plant_all_farmables " , {
2022-08-25 06:23:07 +02:00
title = S ( " Underground Farmer " ) ,
2022-08-21 07:26:13 +02:00
description = S ( " Plant one of every kind of small farmable plant found in the caverns beneath the surface. " ) ,
2022-08-21 03:39:20 +02:00
icon = " dfcaverns_awards_backgroundx32.png "
.. " ^[combine:32x32:0,0= " .. soil_texture
.. " ^[combine:32x32:0,16= " .. soil_texture
.. " ^[combine:32x32:16,0= " .. soil_texture
.. " ^[combine:32x32:16,16= " .. soil_texture
.. " ^[combine:32x32:0,0=dfcaverns_cave_wheat_8.png "
.. " ^[combine:32x32:16,0=dfcaverns_dimple_cup_4.png "
.. " ^[combine:32x32:8,8=dfcaverns_plump_helmet_achievement.png "
.. " ^[combine:32x32:0,16=dfcaverns_sweet_pod_6.png "
.. " ^[combine:32x32:16,16=dfcaverns_quarry_bush_5.png "
.. " ^[combine:32x32:16,15= " .. hoe_texture .. " ^dfcaverns_awards_foregroundx32.png " ,
2022-08-21 08:23:52 +02:00
difficulty = 1 / df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_farmables " ) ,
2022-08-21 07:26:13 +02:00
trigger = {
type = " dfcaverns_achievements " ,
achievement_name = " dfcaverns_plant_all_farmables " ,
target = df_achievements.get_child_achievement_count ( " dfcaverns_plant_all_farmables " ) ,
} ,
2022-08-19 05:40:45 +02:00
} )