minetest_doc_minetest_game/init.lua

247 lines
10 KiB
Lua
Raw Normal View History

2016-08-15 08:52:39 -07:00
-- TODO: Mark appropriate entries as hidden (esp. cloud and dirt with footsteps)
2015-05-16 13:57:51 -07:00
local groupdefs = {
2016-07-31 14:58:58 -07:00
["book"] = "Books",
["vessel"] = "Vessels",
["dye"] = "Dyes",
["stick"] = "Sticks",
["wool"] = "Wool",
["sand"] = "Sand",
["wood"] = "Wood",
2016-08-03 13:16:19 -07:00
["stone"] = "Stones",
2016-07-31 19:31:53 -07:00
["metal"] = "Metal",
2016-07-31 14:58:58 -07:00
["tree"] = "Tree Trunks",
2016-08-03 13:16:19 -07:00
["fence"] = "Fences",
["wall"] = "Walls",
2016-07-31 14:58:58 -07:00
["leaves"] = "Leaves and Needles",
["flower"] = "Flowers",
["sapling"] = "Saplings",
2016-08-09 19:57:53 -07:00
["water"] = "Water",
["lava"] = "Lava",
2016-07-31 19:31:53 -07:00
["cracky"] = "Cracky",
["crumbly"] = "Crumbly",
["choppy"] = "Choppy",
["snappy"] = "Snappy",
["bendy"] = "Bendy",
2016-08-04 20:05:19 -07:00
["oddly_breakable_by_hand"] = "Hand-breakable",
2016-07-31 19:31:53 -07:00
["fleshy"] = "Flesh",
2015-05-16 13:57:51 -07:00
}
2016-08-09 19:57:53 -07:00
local miscgroups = { "book", "vessel", "dye", "stick", "wool", "sand", "wood", "stone", "metal", "tree", "fence", "wall", "leaves", "flower", "sapling", "water", "lava" }
2016-08-04 03:41:40 -07:00
2016-08-03 00:50:00 -07:00
local forced_items = {
2016-08-04 20:33:59 -07:00
"default:book_written",
2015-05-16 13:57:51 -07:00
"bones:bones",
"farming:soil",
"farming:soil_wet",
"farming:desert_sand_soil",
"farming:desert_sand_soil_wet",
2016-07-19 08:25:24 -07:00
"fire:basic_flame",
2016-07-25 10:27:54 -07:00
"farming:wheat_8",
"farming:cotton_8",
"doors:door_wood_a",
"doors:door_steel_a",
"doors:door_glass_a",
"doors:door_obsidian_glass_a",
2016-08-28 08:15:14 -07:00
"xpanes:pane_1",
"xpanes:bar_1",
}
local suppressed_items = {
"doors:door_wood",
"doors:door_steel",
"doors:door_glass",
"doors:door_obsidian_glass",
2016-08-28 08:15:14 -07:00
"xpanes:pane",
"xpanes:bar",
2015-05-16 13:57:51 -07:00
}
local item_name_overrides = {
["screwdriver:screwdriver"] = "Screwdriver",
["fire:basic_flame"] = "Basic Flame",
2016-07-25 10:27:54 -07:00
["farming:wheat_8"] = "Wheat Plant",
["farming:cotton_8"] = "Cotton Plant",
2016-07-31 18:20:46 -07:00
["default:lava_source"] = "Lava",
["default:water_source"] = "Water",
["default:river_water_source"] = "River Water",
["doors:door_wood_a"] = minetest.registered_items["doors:door_wood"].description,
["doors:door_steel_a"] = minetest.registered_items["doors:door_steel"].description,
["doors:door_glass_a"] = minetest.registered_items["doors:door_glass"].description,
["doors:door_obsidian_glass_a"] = minetest.registered_items["doors:door_obsidian_glass"].description,
2016-08-28 08:15:14 -07:00
["xpanes:pane_1"] = minetest.registered_items["xpanes:pane"].description,
["xpanes:bar_1"] = minetest.registered_items["xpanes:bar"].description,
}
2016-08-15 15:36:47 -07:00
local image_overrides = {
["doors:door_wood_a"] = minetest.registered_items["doors:door_wood"].inventory_image,
["doors:door_steel_a"] = minetest.registered_items["doors:door_steel"].inventory_image,
["doors:door_glass_a"] = minetest.registered_items["doors:door_glass"].inventory_image,
["doors:door_obsidian_glass_a"] = minetest.registered_items["doors:door_obsidian_glass"].inventory_image,
2016-08-28 08:15:14 -07:00
["xpanes:pane_1"] = minetest.registered_items["xpanes:pane"].inventory_image,
["xpanes:bar_1"] = minetest.registered_items["xpanes:bar"].inventory_image,
2016-08-15 15:36:47 -07:00
}
doc.sub.items.add_real_group_names(groupdefs)
2016-08-04 03:41:40 -07:00
doc.sub.items.add_notable_groups(miscgroups)
2016-08-03 00:50:00 -07:00
doc.sub.items.add_forced_item_entries(forced_items)
doc.sub.items.add_suppressed_item_entries(suppressed_items)
doc.sub.items.add_item_name_overrides(item_name_overrides)
2016-08-15 15:36:47 -07:00
doc.sub.items.add_item_image_overrides(image_overrides)
2015-05-16 13:57:51 -07:00
2016-07-31 22:12:43 -07:00
2016-08-02 07:28:03 -07:00
-- Minetest Game Factoids
2015-05-16 13:57:51 -07:00
2016-08-02 07:28:03 -07:00
-- Groups flammable, puts_out_fire
local function f_fire(itemstring, def)
local s = ""
-- Fire
if def.groups.flammable == 1 then
s = s .. "This block is flammable and burns slowly."
elseif def.groups.flammable == 2 then
s = s .. "This block is flammable and burns at medium speed."
elseif def.groups.flammable == 3 then
s = s .. "This block is highly flammable and burns very quickly."
elseif def.groups.flammable == 4 then
s = s .. "This block is very easily set on fire and burns extremely quickly."
elseif def.groups.flammable ~= nil then
s = s .. "This block is flammable."
end
2016-03-11 00:30:33 -08:00
2016-08-02 07:28:03 -07:00
if def.groups.puts_out_fire ~= nil then
if def.groups.flammable ~= nil then
s = s .. "\n"
end
s = s .. "This block will extinguish nearby fire."
end
2016-08-03 03:41:31 -07:00
if def.groups.igniter ~= nil then
if def.groups.flammable ~= nil or def.groups.puts_out_fire ~= nil then
s = s .. "\n"
end
s = s .. "This block will set flammable blocks within a radius of "..def.groups.igniter.." on fire."
end
2016-08-02 07:28:03 -07:00
return s
end
-- flora group
local function f_flora(itemstring, def)
if def.groups.flora == 1 then
return "This block belongs to the Flora group. It a living organism which likes to grow and spread on dirt with grass or dirt with dry grass when it is in light. On desert sand, it will wither and die and turn into a dry shrub."
else
return ""
end
end
-- soil group
local function f_soil(itemstring, def)
if def.groups.soil == 1 then
2016-08-28 08:06:43 -07:00
if itemstring == "default:desert_sand" then
return "This block is natural soil. It supports the growth of blocks belonging to the Saplings group."
else
return "This block is natural soil. It supports the spreading of blocks belonging to the Flora group and the growth of blocks belonging to the Saplings group."
end
2016-08-02 07:28:03 -07:00
elseif def.groups.soil == 2 or def.groups.soil == 3 then
2016-08-28 08:06:43 -07:00
if itemstring == "farming:desert_sand_soil" or itemstring == "farming:desert_sand_soil_wet" then
return "This block serves as a soil for saplings as well as plants grown from seeds. It supports their growth."
else
return "This block serves as a soil for wild plants (Flora, Saplings) as well as plants grown from seeds. It supports their growth and spreading."
end
2016-08-02 07:28:03 -07:00
else
return ""
end
end
2016-07-23 17:14:01 -07:00
2016-08-15 06:19:22 -07:00
local function f_leafdecay(itemstring, def)
local formstring = ""
if def.groups.leafdecay ~= nil then
if def.groups.leafdecay_drop ~= nil then
formstring = string.format("This block may drop as an item when no trunk is nearby. This is prevented if any block of the group “Tree Trunks” is nearby (up to a distance of %d), the block is completely surrounded by blocks which are neither air or a liquid or it has been manually placed by a player.", def.groups.leafdecay)
else
if def.drop ~= "" and def.drop ~= nil and def.drop ~= itemstring then
formstring = string.format("This block may decay when no trunk is nearby. When decaying, it disappears and may drop one of its mining drops (but never itself). Decay is prevented if any block of the group “Tree Trunks” is nearby (up to a distance of %d), the block is completely surrounded by blocks which are neither air or a liquid or it has been placed by a player.", def.groups.leafdecay)
else
formstring = string.format("This block may decay and disappear when no trunk is nearby. Decay is prevented if any block of the group “Tree Trunks” is nearby (up to a distance of %d), the block is completely surrounded by blocks which are neither air or a liquid or it has been placed by a player.", def.groups.leafdecay)
end
end
end
return formstring
end
2016-08-02 07:28:03 -07:00
doc.sub.items.register_factoid("nodes", "groups", f_fire)
doc.sub.items.register_factoid("nodes", "groups", f_flora)
2016-08-15 06:19:22 -07:00
doc.sub.items.register_factoid("nodes", "groups", f_leafdecay)
2016-08-02 07:28:03 -07:00
doc.sub.items.register_factoid("nodes", "groups", f_soil)
2015-05-16 13:57:51 -07:00
-- Add node aliases
for i=2,5 do
doc.add_entry_alias("nodes", "default:grass_1", "default:grass_"..i)
doc.add_entry_alias("nodes", "default:dry_grass_1", "default:dry_grass_"..i)
end
2016-07-25 10:27:54 -07:00
for i=1,7 do
doc.add_entry_alias("nodes", "farming:wheat_8", "farming:wheat_"..i)
doc.add_entry_alias("nodes", "farming:cotton_8", "farming:cotton_"..i)
end
2016-07-31 18:20:46 -07:00
doc.add_entry_alias("nodes", "default:lava_source", "default:lava_flowing")
doc.add_entry_alias("nodes", "default:water_source", "default:water_flowing")
doc.add_entry_alias("nodes", "default:river_water_source", "default:river_water_flowing")
2016-08-09 21:42:17 -07:00
doc.add_entry_alias("nodes", "default:furnace", "default:furnace_active")
doc.add_entry_aliases("nodes", "doors:door_wood_a", {"doors:door_wood_b", "doors:doors_wood"})
doc.add_entry_aliases("nodes", "doors:door_steel_a", {"doors:door_steel_b", "doors:door_steel"})
doc.add_entry_aliases("nodes", "doors:door_glass_a", {"doors:door_glass_b", "doors:door_glass"})
doc.add_entry_aliases("nodes", "doors:door_obsidian_glass_a", {"doors:door_obsidian_glass_b", "doors:door_obsidian_glass"})
doc.add_entry_alias("nodes", "doors:gate_wood_closed", "doors:gate_wood_open")
doc.add_entry_alias("nodes", "doors:gate_junglewood_closed", "doors:gate_junglewood_open")
doc.add_entry_alias("nodes", "doors:gate_acacia_wood_closed", "doors:gate_acacia_wood_open")
doc.add_entry_alias("nodes", "doors:gate_aspen_wood_closed", "doors:gate_aspen_wood_open")
doc.add_entry_alias("nodes", "doors:gate_pine_wood_closed", "doors:gate_pine_wood_open")
2016-08-09 21:42:17 -07:00
doc.add_entry_alias("nodes", "doors:trapdoor", "doors:trapdoor_open")
doc.add_entry_alias("nodes", "doors:trapdoor_steel", "doors:trapdoor_steel_open")
2016-08-09 21:11:22 -07:00
doc.add_entry_alias("nodes", "tnt:tnt", "tnt:tnt_burning")
2016-08-13 04:54:41 -07:00
local pane_aliases = {}
local bar_aliases = {}
2016-08-28 08:15:14 -07:00
for i=2,15 do
2016-08-13 04:54:41 -07:00
table.insert(pane_aliases, "xpanes:pane_"..i)
table.insert(bar_aliases, "xpanes:bar_"..i)
end
2016-08-28 08:15:14 -07:00
table.insert(pane_aliases, "xpanes:pane")
table.insert(bar_aliases, "xpanes:bar")
doc.add_entry_aliases("nodes", "xpanes:pane_1", pane_aliases)
doc.add_entry_aliases("nodes", "xpanes:bar_1", bar_aliases)
-- Gather help texts
2015-05-16 13:57:51 -07:00
dofile(minetest.get_modpath("doc_minetest_game") .. "/helptexts.lua")
-- Register boat object for doc_identifier
if minetest.get_modpath("doc_identifier") ~= nil then
2016-08-13 04:46:03 -07:00
doc.sub.identifier.register_object("boats:boat", "craftitems", "boats:boat")
end
-- Achievement
local awardchecktime = 0
if minetest.get_modpath("awards") ~= nil then
-- TODO: Change the goal to unlocking/discovering all block entries of Minetest Game
-- (excluding unused blocks like default:cloud)
awards.register_achievement("doc_minetest_game_allnodes", {
title = "Block Index Completed",
2016-08-01 13:48:46 -07:00
icon = "doc_awards_icon_generic.png",
description = "Read all help entries about blocks.",
})
minetest.register_globalstep(function(dtime)
-- Check awards every 30 seconds
awardchecktime = awardchecktime + dtime
if awardchecktime < 30 then return end
awardchecktime = 30 - awardchecktime
local players = minetest.get_connected_players()
for p=1,#players do
2016-08-01 08:57:37 -07:00
local playername = players[p]:get_player_name()
local count = doc.get_viewed_count(playername, "nodes")
if count ~= nil and count >= doc.get_entry_count("nodes") then
2016-08-01 08:57:37 -07:00
awards.unlock(playername, "doc_minetest_game_allnodes")
end
end
end)
end