commit 21f9e44d86a42d054f92e80ec83b4d01ecd2ad70 Author: Wuzzy Date: Mon Aug 26 16:27:24 2019 +0200 Initial commit diff --git a/API.md b/API.md new file mode 100644 index 0000000..44b446a --- /dev/null +++ b/API.md @@ -0,0 +1,28 @@ +# API documentation for Cups mod +This mod provides a simple API for adding more cups. + +## `cups.register_cup(subname, description, tiles, craftitem, craft_count, extra_groups, extra_sounds)` +Adds a new cup with itemstring `cups:cup_` and optionally a crafting recipe for this cup. + +If `craftitem` is non-`nil`, the recipe follows this template: + + C.C + .C. + .C. + + C = `craftitem` + . = nothing + +Yields `craft_count` cups. + +### Parameters +* `subname`: Part of the name which will be used to create the cup's itemstring +* `description`: In-game description/tooltip of the cup +* `tiles`: Textures +* `craftitem`: The item source to be used in the crafting recipe. If `nil`, no crafting recipe will be generated +* `craft_count`: How many cups will be crafted at once (only has an effect if `craftitem ~= nil`) +* `extra_groups`: Table of additional groups to assign to this item (optional) +* `extra_sounds`: Table of additional sounds (`SimpleSoundSpec`) to assign to this item (optional) + +### Returns +Always `nil`. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e06973 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# Cups [`cups`] +This mods adds a few decorative cups: + +* Bronze Cup +* Silver Cup (requires `moreores` mod) +* Golden Cup +* Diamond Cup + +## API +Programmers can add more cups by using the very simple API. See `API.md`. + +## Credits and licenses +This mod is free software. + +### Code +* Author: Wuzzy +* Licensed under: MIT License + +### Graphics +All graphics are derivate works of Minetest Game textures. +They are licensed under [CC-BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/). diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..ac2cfc6 --- /dev/null +++ b/init.lua @@ -0,0 +1,100 @@ +local S = minetest.get_translator("cups") +local has_default = minetest.get_modpath("default") ~= nil +local has_moreores = minetest.get_modpath("moreores") ~= nil +local cups = {} + +-- Nodeboxes +local cupnodebox = { + type = "fixed", + fixed = { + {-0.3,-0.5,-0.3,0.3,-0.4,0.3}, -- stand + {-0.1,-0.4,-0.1,0.1,0,0.1}, -- handle + {-0.3,0,-0.3,0.3,0.1,0.3}, -- cup (lower part) + -- the 4 sides of the upper part + {-0.2,0.1,-0.3,0.2,0.5,-0.2}, + {-0.2,0.1,0.2,0.2,0.5,0.3}, + {-0.3,0.1,-0.3,-0.2,0.5,0.3}, + {0.2,0.1,-0.3,0.3,0.5,0.3}, + } +} + +local cupselbox = { + type = "fixed", + fixed = { + {-0.3,-0.5,-0.3,0.3,-0.4,0.3}, -- stand + {-0.1,-0.4,-0.1,0.1,0,0.1}, -- handle + {-0.3,0,-0.3,0.3,0.5,0.3}, -- upper part + } +} + +-- API +cups.register_cup = function(subname, description, tiles, craftitem, craft_count, extra_groups, extra_sounds) + local groups = { dig_immediate=3, falling_node=1, } + if extra_groups then + for k,v in pairs(extra_groups) do + groups[k] = v + end + end + local sounds + if has_default then + if default.node_sound_metal_defaults then + sounds = default.node_sound_defaults({ + footstep = { name = "default_metal_footstep", gain = 0.3 }, + }) + else + sounds = default.node_sound_defaults({ + footstep = { name = "default_hard_footstep", gain = 0.3 }, + }) + end + end + if extra_sounds then + for k,v in pairs(extra_sounds) do + sounds[k] = v + end + end + local itemstring = "cups:cup_"..subname + minetest.register_node(itemstring, { + description = description, + _doc_items_longdesc = S("A decorative item which can be placed."), + tiles = tiles, + paramtype = "light", + drawtype = "nodebox", + node_box = cupnodebox, + is_ground_content = false, + selection_box = cupselbox, + groups = groups, + sounds = sounds, + }) + + if craftitem ~= nil then + if craft_count == nil then craft_count = 1 end + + if has_default then + minetest.register_craft({ + output = "cups:cup_"..subname.." "..craft_count, + recipe = { + {craftitem, "", craftitem}, + {"", craftitem, ""}, + {"", craftitem, ""}, + } + }) + end + end +end + +-- Register cups +local sound_hard +if has_default then + sound_hard = default.node_sound_defaults({ footstep = { name = "default_hard_footstep", gain = 0.3 }}) +end +cups.register_cup("bronze", S("Bronze Cup"), { "cups_bronze.png" }, "default:bronze_ingot", 2) +cups.register_cup("gold", S("Golden Cup"), { "cups_gold.png" }, "default:gold_ingot", 2) +cups.register_cup("diamond", S("Diamond Cup"), { "cups_diamond.png" }, "default:diamond", 1, nil, sound_hard) +if has_moreores then + cups.register_cup("silver", S("Silver Cup"), { "cups_silver.png" }, "moreores:silver_ingot", 2) +end + +-- Legacy aliases +minetest.register_alias("mtg_plus:cup_bronze", "cups:cup_bronze") +minetest.register_alias("mtg_plus:cup_gold", "cups:cup_gold") +minetest.register_alias("mtg_plus:cup_diamond", "cups:cup_diamond") diff --git a/locale/cups.de.tr b/locale/cups.de.tr new file mode 100644 index 0000000..cb0fed0 --- /dev/null +++ b/locale/cups.de.tr @@ -0,0 +1,6 @@ +# textdomain:cups +A decorative item which can be placed.=Ein dekorativer Gegenstand, den man platzieren kann. +Bronze Cup=Bronzepokal +Golden Cup=Goldpokal +Diamond Cup=Diamantpokal +Silver Cup=Silberpokal diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..853e9e9 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,6 @@ +# textdomain:cups +A decorative item which can be placed.= +Bronze Cup= +Golden Cup= +Diamond Cup= +Silver Cup= diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..3016cf6 --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +name=cups +description=Decorative cups. +optional_depends=default, moreores diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..7f8a957 Binary files /dev/null and b/screenshot.png differ diff --git a/textures/cups_bronze.png b/textures/cups_bronze.png new file mode 100644 index 0000000..c6c1d4c Binary files /dev/null and b/textures/cups_bronze.png differ diff --git a/textures/cups_diamond.png b/textures/cups_diamond.png new file mode 100644 index 0000000..cc350c4 Binary files /dev/null and b/textures/cups_diamond.png differ diff --git a/textures/cups_gold.png b/textures/cups_gold.png new file mode 100644 index 0000000..6299577 Binary files /dev/null and b/textures/cups_gold.png differ diff --git a/textures/cups_silver.png b/textures/cups_silver.png new file mode 100644 index 0000000..c706a7a Binary files /dev/null and b/textures/cups_silver.png differ