Move nyancats into a separate mod
authorrubenwardy <rubenwardy@gmail.com>
Mon, 11 Jul 2016 16:55:17 +0000 (17:55 +0100)
committerparamat <mat.gregory@virginmedia.com>
Mon, 18 Jul 2016 03:15:44 +0000 (04:15 +0100)
Nyancats are independent in the default mod. Nothing else uses them or
their code. Separating it into a separate mod makes it easier for
subgames to remove them. It also makes it easier for a mod to depend
on nyancats, as lots of subgames don't have them.

Default/mapgen.lua: Register biomes, ores and decorations in
singlenode mapgen. These were never disabled anyway because
singlenode was removed from the world creation menu.

17 files changed:
game_api.txt
mods/default/README.txt
mods/default/aliases.lua
mods/default/crafting.lua
mods/default/mapgen.lua
mods/default/nodes.lua
mods/default/textures/default_nc_back.png [deleted file]
mods/default/textures/default_nc_front.png [deleted file]
mods/default/textures/default_nc_rb.png [deleted file]
mods/default/textures/default_nc_side.png [deleted file]
mods/nyancat/README.txt [new file with mode: 0644]
mods/nyancat/depends.txt [new file with mode: 0644]
mods/nyancat/init.lua [new file with mode: 0644]
mods/nyancat/textures/default_nc_back.png [new file with mode: 0644]
mods/nyancat/textures/default_nc_front.png [new file with mode: 0644]
mods/nyancat/textures/default_nc_rb.png [new file with mode: 0644]
mods/nyancat/textures/default_nc_side.png [new file with mode: 0644]

index e04a33b40a2c92108723d05e73d9fe62708cce48..581d76ccf8dc4245b879ce25e262c173e203a714 100644 (file)
@@ -250,6 +250,18 @@ Give Initial Stuff API
 ^ str is a comma separated list of initial stuff
 ^ Adds items to the list of items to be given
 
+Nyancat API
+-----------
+
+`nyancat.place(pos, facedir, length)`
+
+^ Place a cat at `pos` facing `facedir` with tail length `length`
+  Only accepts facedir 0-3, if facedir > 3 then it will be interpreted as facedir = 0
+
+`nyancat.generate(minp, maxp, seed)`
+
+^ Called by `minetest.register_on_generated`. To disable nyancat generation,
+  you can redefine nyancat.generate() to be an empty function
 
 TNT API
 ----------
index 41dd1eb0a20a71a2380e81d03a3c2f71b4a87dec..85c5a4eff88b232e75837126a0595daac9e8cb96 100644 (file)
@@ -51,10 +51,6 @@ RealBadAngel's animated water (WTFPL):
   default_water_flowing_animated.png
 
 VanessaE (WTFPL):
-  default_nc_back.png
-  default_nc_front.png
-  default_nc_rb.png
-  default_nc_side.png
   default_desert_sand.png
   default_desert_stone.png
   default_sand.png
index 63fe59b29d6b029a6dc169394a0fbd81d45d1197..1259ac0e97ce85446d0072f38d0940a42816fc66 100644 (file)
@@ -39,8 +39,6 @@ minetest.register_alias("locked_chest", "default:chest_locked")
 minetest.register_alias("cobble", "default:cobble")
 minetest.register_alias("mossycobble", "default:mossycobble")
 minetest.register_alias("steelblock", "default:steelblock")
-minetest.register_alias("nyancat", "default:nyancat")
-minetest.register_alias("nyancat_rainbow", "default:nyancat_rainbow")
 minetest.register_alias("sapling", "default:sapling")
 minetest.register_alias("apple", "default:apple")
 
@@ -77,4 +75,3 @@ minetest.register_alias("default:pinewood", "default:pine_wood")
 
 minetest.register_alias("default:ladder", "default:ladder_wood")
 minetest.register_alias("default:sign_wall", "default:sign_wall_wood")
-
index 3bfce07c1d9596199be7dd347cfa3e006984a606..1151f47bfb225024897b3d119d08d4f46d37cab8 100644 (file)
@@ -888,18 +888,6 @@ minetest.register_craft({
        burntime = 30,
 })
 
-minetest.register_craft({
-       type = "fuel",
-       recipe = "default:nyancat",
-       burntime = 1,
-})
-
-minetest.register_craft({
-       type = "fuel",
-       recipe = "default:nyancat_rainbow",
-       burntime = 1,
-})
-
 minetest.register_craft({
        type = "fuel",
        recipe = "group:sapling",
@@ -935,4 +923,3 @@ minetest.register_craft({
        recipe = "default:dry_grass_1",
        burntime = 2,
 })
-
index 7d0b0fd4887d34e0f576b18fe0e770fa223f1848..52aa294c7e5dd5bd0cfe2861eb7fd779f70f1b4c 100644 (file)
@@ -49,7 +49,7 @@ function default.register_ores()
        -- Clay
        -- This first to avoid clay in sand blobs
 
-       minetest.register_ore({ 
+       minetest.register_ore({
                ore_type        = "blob",
                ore             = "default:clay",
                wherein         = {"default:sand"},
@@ -70,7 +70,7 @@ function default.register_ores()
 
        -- Sand
 
-       minetest.register_ore({ 
+       minetest.register_ore({
                ore_type        = "blob",
                ore             = "default:sand",
                wherein         = {"default:stone", "default:sandstone",
@@ -1464,73 +1464,16 @@ function default.register_decorations()
 end
 
 
---
--- Generate nyan cats
---
-
--- All mapgens except singlenode
-
-function default.make_nyancat(pos, facedir, length)
-       local tailvec = {x = 0, y = 0, z = 0}
-       if facedir == 0 then
-               tailvec.z = 1
-       elseif facedir == 1 then
-               tailvec.x = 1
-       elseif facedir == 2 then
-               tailvec.z = -1
-       elseif facedir == 3 then
-               tailvec.x = -1
-       else
-               facedir = 0
-               tailvec.z = 1
-       end
-       local p = {x = pos.x, y = pos.y, z = pos.z}
-       minetest.set_node(p, {name = "default:nyancat", param2 = facedir})
-       for i = 1, length do
-               p.x = p.x + tailvec.x
-               p.z = p.z + tailvec.z
-               minetest.set_node(p, {name = "default:nyancat_rainbow", param2 = facedir})
-       end
-end
-
-function default.generate_nyancats(minp, maxp, seed)
-       local height_min = -31000
-       local height_max = -32
-       if maxp.y < height_min or minp.y > height_max then
-               return
-       end
-       local y_min = math.max(minp.y, height_min)
-       local y_max = math.min(maxp.y, height_max)
-       local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
-       local pr = PseudoRandom(seed + 9324342)
-       local max_num_nyancats = math.floor(volume / (16 * 16 * 16))
-       for i = 1, max_num_nyancats do
-               if pr:next(0, 1000) == 0 then
-                       local x0 = pr:next(minp.x, maxp.x)
-                       local y0 = pr:next(minp.y, maxp.y)
-                       local z0 = pr:next(minp.z, maxp.z)
-                       local p0 = {x = x0, y = y0, z = z0}
-                       default.make_nyancat(p0, pr:next(0, 3), pr:next(3, 15))
-               end
-       end
-end
-
-
 --
 -- Detect mapgen to select functions
 --
 
--- Mods using singlenode mapgen can call these functions to enable
--- the use of minetest.generate_ores or minetest.generate_decorations
-
 local mg_name = minetest.get_mapgen_setting("mg_name")
 if mg_name == "v6" then
        default.register_ores()
        default.register_mgv6_decorations()
-       minetest.register_on_generated(default.generate_nyancats)
-elseif mg_name ~= "singlenode" then
+else
        default.register_biomes()
        default.register_ores()
        default.register_decorations()
-       minetest.register_on_generated(default.generate_nyancats)
 end
index 86d5565c51dfe614aab6198c36000b0067769334..31e063d4341bc40ff298bf918b35927ef1d9e18e 100644 (file)
@@ -178,8 +178,6 @@ Misc
 ----
 
 default:cloud
-default:nyancat
-default:nyancat_rainbow
 
 --]]
 
@@ -1902,26 +1900,3 @@ minetest.register_node("default:cloud", {
        sounds = default.node_sound_defaults(),
        groups = {not_in_creative_inventory = 1},
 })
-
-minetest.register_node("default:nyancat", {
-       description = "Nyan Cat",
-       tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
-               "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
-       paramtype2 = "facedir",
-       groups = {cracky = 2},
-       is_ground_content = false,
-       legacy_facedir_simple = true,
-       sounds = default.node_sound_defaults(),
-})
-
-minetest.register_node("default:nyancat_rainbow", {
-       description = "Nyan Cat Rainbow",
-       tiles = {
-               "default_nc_rb.png^[transformR90", "default_nc_rb.png^[transformR90",
-               "default_nc_rb.png", "default_nc_rb.png"
-       },
-       paramtype2 = "facedir",
-       groups = {cracky = 2},
-       is_ground_content = false,
-       sounds = default.node_sound_defaults(),
-})
diff --git a/mods/default/textures/default_nc_back.png b/mods/default/textures/default_nc_back.png
deleted file mode 100644 (file)
index e479ace..0000000
Binary files a/mods/default/textures/default_nc_back.png and /dev/null differ
diff --git a/mods/default/textures/default_nc_front.png b/mods/default/textures/default_nc_front.png
deleted file mode 100644 (file)
index c9dd6a3..0000000
Binary files a/mods/default/textures/default_nc_front.png and /dev/null differ
diff --git a/mods/default/textures/default_nc_rb.png b/mods/default/textures/default_nc_rb.png
deleted file mode 100644 (file)
index 685a22c..0000000
Binary files a/mods/default/textures/default_nc_rb.png and /dev/null differ
diff --git a/mods/default/textures/default_nc_side.png b/mods/default/textures/default_nc_side.png
deleted file mode 100644 (file)
index 3152c33..0000000
Binary files a/mods/default/textures/default_nc_side.png and /dev/null differ
diff --git a/mods/nyancat/README.txt b/mods/nyancat/README.txt
new file mode 100644 (file)
index 0000000..95850c9
--- /dev/null
@@ -0,0 +1,29 @@
+Minetest Game mod: nyancat
+==========================
+
+License of source code:
+-----------------------
+Copyright (C) 2011-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
+(at your option) any later version.
+
+http://www.gnu.org/licenses/lgpl-2.1.html
+
+License of media (textures and sounds)
+--------------------------------------
+Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
+http://creativecommons.org/licenses/by-sa/3.0/
+
+Authors of media files
+-----------------------
+Everything not listed in here:
+Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+
+VanessaE (WTFPL):
+  default_nc_back.png
+  default_nc_front.png
+  default_nc_rb.png
+  default_nc_side.png
diff --git a/mods/nyancat/depends.txt b/mods/nyancat/depends.txt
new file mode 100644 (file)
index 0000000..4ad96d5
--- /dev/null
@@ -0,0 +1 @@
+default
diff --git a/mods/nyancat/init.lua b/mods/nyancat/init.lua
new file mode 100644 (file)
index 0000000..6c1d903
--- /dev/null
@@ -0,0 +1,84 @@
+minetest.register_node("nyancat:nyancat", {
+       description = "Nyan Cat",
+       tiles = {"default_nc_side.png", "default_nc_side.png", "default_nc_side.png",
+               "default_nc_side.png", "default_nc_back.png", "default_nc_front.png"},
+       paramtype2 = "facedir",
+       groups = {cracky = 2},
+       is_ground_content = false,
+       legacy_facedir_simple = true,
+       sounds = default.node_sound_defaults(),
+})
+
+minetest.register_node("nyancat:nyancat_rainbow", {
+       description = "Nyan Cat Rainbow",
+       tiles = {
+               "default_nc_rb.png^[transformR90", "default_nc_rb.png^[transformR90",
+               "default_nc_rb.png", "default_nc_rb.png"
+       },
+       paramtype2 = "facedir",
+       groups = {cracky = 2},
+       is_ground_content = false,
+       sounds = default.node_sound_defaults(),
+})
+
+minetest.register_craft({
+       type = "fuel",
+       recipe = "nyancat:nyancat",
+       burntime = 1,
+})
+
+minetest.register_craft({
+       type = "fuel",
+       recipe = "nyancat:nyancat_rainbow",
+       burntime = 1,
+})
+
+nyancat = {}
+
+function nyancat.place(pos, facedir, length)
+       if facedir > 3 then
+               facedir = 0
+       end
+       local tailvec = minetest.facedir_to_dir(facedir)
+       local p = {x = pos.x, y = pos.y, z = pos.z}
+       minetest.set_node(p, {name = "nyancat:nyancat", param2 = facedir})
+       for i = 1, length do
+               p.x = p.x + tailvec.x
+               p.z = p.z + tailvec.z
+               minetest.set_node(p, {name = "nyancat:nyancat_rainbow", param2 = facedir})
+       end
+end
+
+function nyancat.generate(minp, maxp, seed)
+       local height_min = -31000
+       local height_max = -32
+       if maxp.y < height_min or minp.y > height_max then
+               return
+       end
+       local y_min = math.max(minp.y, height_min)
+       local y_max = math.min(maxp.y, height_max)
+       local volume = (maxp.x - minp.x + 1) * (y_max - y_min + 1) * (maxp.z - minp.z + 1)
+       local pr = PseudoRandom(seed + 9324342)
+       local max_num_nyancats = math.floor(volume / (16 * 16 * 16))
+       for i = 1, max_num_nyancats do
+               if pr:next(0, 1000) == 0 then
+                       local x0 = pr:next(minp.x, maxp.x)
+                       local y0 = pr:next(minp.y, maxp.y)
+                       local z0 = pr:next(minp.z, maxp.z)
+                       local p0 = {x = x0, y = y0, z = z0}
+                       nyancat.place(p0, pr:next(0, 3), pr:next(3, 15))
+               end
+       end
+end
+
+minetest.register_on_generated(function(minp, maxp, seed)
+       nyancat.generate(minp, maxp, seed)
+end)
+
+-- Legacy
+minetest.register_alias("default:nyancat", "nyancat:nyancat")
+minetest.register_alias("default:nyancat_rainbow", "nyancat:nyancat_rainbow")
+minetest.register_alias("nyancat", "nyancat:nyancat")
+minetest.register_alias("nyancat_rainbow", "nyancat:nyancat_rainbow")
+default.make_nyancat = nyancat.place
+default.generate_nyancats = nyancat.generate
diff --git a/mods/nyancat/textures/default_nc_back.png b/mods/nyancat/textures/default_nc_back.png
new file mode 100644 (file)
index 0000000..e479ace
Binary files /dev/null and b/mods/nyancat/textures/default_nc_back.png differ
diff --git a/mods/nyancat/textures/default_nc_front.png b/mods/nyancat/textures/default_nc_front.png
new file mode 100644 (file)
index 0000000..c9dd6a3
Binary files /dev/null and b/mods/nyancat/textures/default_nc_front.png differ
diff --git a/mods/nyancat/textures/default_nc_rb.png b/mods/nyancat/textures/default_nc_rb.png
new file mode 100644 (file)
index 0000000..685a22c
Binary files /dev/null and b/mods/nyancat/textures/default_nc_rb.png differ
diff --git a/mods/nyancat/textures/default_nc_side.png b/mods/nyancat/textures/default_nc_side.png
new file mode 100644 (file)
index 0000000..3152c33
Binary files /dev/null and b/mods/nyancat/textures/default_nc_side.png differ