summaryrefslogtreecommitdiff
path: root/crafting_bench
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-17 16:53:18 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2017-03-17 16:53:18 -0400
commit907e8bf6a64215a516fdf16869dd81248aeaa2f6 (patch)
treed199282e5764c7ab5183fe0d78ed0412dbb0b89f /crafting_bench
parent06d9243586cecb1abed74550ce2544b436572a35 (diff)
downloaddreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar.gz
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar.bz2
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.tar.xz
dreambuilder_modpack-907e8bf6a64215a516fdf16869dd81248aeaa2f6.zip
update digilines, technic, unified inventory,
and switched castles to the new modpack form
Diffstat (limited to 'crafting_bench')
-rw-r--r--crafting_bench/LICENSE21
-rw-r--r--crafting_bench/README.txt18
-rw-r--r--crafting_bench/depends.txt4
-rw-r--r--crafting_bench/description.txt1
-rw-r--r--crafting_bench/init.lua170
-rw-r--r--crafting_bench/intllib.lua45
-rw-r--r--crafting_bench/locale/template.pot67
-rw-r--r--crafting_bench/mod.conf1
-rw-r--r--crafting_bench/screenshot.pngbin0 -> 42865 bytes
-rw-r--r--crafting_bench/settingtypes.txt2
-rw-r--r--crafting_bench/textures/LICENSE.txt20
-rw-r--r--crafting_bench/textures/crafting_bench_workbench_back.pngbin0 -> 383 bytes
-rw-r--r--crafting_bench/textures/crafting_bench_workbench_bottom.pngbin0 -> 369 bytes
-rw-r--r--crafting_bench/textures/crafting_bench_workbench_front.pngbin0 -> 391 bytes
-rw-r--r--crafting_bench/textures/crafting_bench_workbench_side.pngbin0 -> 342 bytes
-rw-r--r--crafting_bench/textures/crafting_bench_workbench_top.pngbin0 -> 336 bytes
16 files changed, 349 insertions, 0 deletions
diff --git a/crafting_bench/LICENSE b/crafting_bench/LICENSE
new file mode 100644
index 0000000..456d091
--- /dev/null
+++ b/crafting_bench/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Minetest Mods Team
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/crafting_bench/README.txt b/crafting_bench/README.txt
new file mode 100644
index 0000000..54045a2
--- /dev/null
+++ b/crafting_bench/README.txt
@@ -0,0 +1,18 @@
+=-=-=-=-=-=-=-=-=-=
+
+Crafting Bench
+by: Philipbenr And DanDuncombe
+
+=-=-=-=-=-=-=-=-=-=
+
+Licence: MIT
+
+see: LICENSE
+
+=-=-=-=-=-=-=-=-=-=
+
+An auto-crafting bench. Place raw materials into its inventory, define a crafting recipe in its main grid, and then every five seconds it will generate a crafted output.
+
+This mod is compatible with hoppers.
+
+The crafting rate can be modified in advanced settings. \ No newline at end of file
diff --git a/crafting_bench/depends.txt b/crafting_bench/depends.txt
new file mode 100644
index 0000000..3e4cdce
--- /dev/null
+++ b/crafting_bench/depends.txt
@@ -0,0 +1,4 @@
+default
+intllib?
+hopper?
+doc? \ No newline at end of file
diff --git a/crafting_bench/description.txt b/crafting_bench/description.txt
new file mode 100644
index 0000000..728c836
--- /dev/null
+++ b/crafting_bench/description.txt
@@ -0,0 +1 @@
+An auto-crafting bench
diff --git a/crafting_bench/init.lua b/crafting_bench/init.lua
new file mode 100644
index 0000000..b723424
--- /dev/null
+++ b/crafting_bench/init.lua
@@ -0,0 +1,170 @@
+-- internationalization boilerplate
+local MP = minetest.get_modpath(minetest.get_current_modname())
+local S, NS = dofile(MP.."/intllib.lua")
+
+minetest.register_alias("castle:workbench", "crafting_bench:workbench")
+
+local usage_help = S("The inventory on the left is for raw materials, the inventory on the right holds finished products. The crafting grid in the center defines what recipe this workbench will make use of; place raw materials into it in the crafting pattern corresponding to what you want to build.")
+
+if minetest.get_modpath("hopper") and hopper ~= nil and hopper.add_container ~= nil then
+ usage_help = usage_help .. "\n\n" .. S("This workbench is compatible with hoppers. Hoppers will insert into the raw material inventory and remove items from the finished goods inventory.")
+end
+
+
+local crafting_rate = minetest.setting_get("crafting_bench_crafting_rate")
+if crafting_rate == nil then crafting_rate = 5 end
+
+
+minetest.register_node("crafting_bench:workbench",{
+ description = S("Workbench"),
+ _doc_items_longdesc = string.format(S("A workbench that does work for you. Set a crafting recipe and provide raw materials and items will magically craft themselves once every %i seconds."), crafting_rate),
+ _doc_items_usagehelp = usage_help,
+ tiles = {
+ "crafting_bench_workbench_top.png",
+ "crafting_bench_workbench_bottom.png",
+ "crafting_bench_workbench_side.png",
+ "crafting_bench_workbench_side.png",
+ "crafting_bench_workbench_back.png",
+ "crafting_bench_workbench_front.png"
+ },
+ paramtype2 = "facedir",
+ paramtype = "light",
+ groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2},
+ sounds = default.node_sound_wood_defaults(),
+ drawtype = "normal",
+ on_construct = function ( pos )
+ local meta = minetest.get_meta( pos )
+ meta:set_string( 'formspec',
+ 'size[10,10;]' ..
+ default.gui_bg ..
+ default.gui_bg_img ..
+ default.gui_slots ..
+ 'label[1,0;'..S('Source Material')..']' ..
+ 'list[context;src;1,1;2,4;]' ..
+ 'label[4,0;'..S('Recipe to Use')..']' ..
+ 'list[context;rec;4,1;3,3;]' ..
+ 'label[7.5,0;'..S('Craft Output')..']' ..
+ 'list[context;dst;8,1;1,4;]' ..
+ 'list[current_player;main;1,6;8,4;]' )
+ meta:set_string( 'infotext', S('Workbench'))
+ local inv = meta:get_inventory()
+ inv:set_size( 'src', 2 * 4 )
+ inv:set_size( 'rec', 3 * 3 )
+ inv:set_size( 'dst', 1 * 4 )
+ end,
+ can_dig = function(pos,player)
+ local meta = minetest.get_meta(pos);
+ local inv = meta:get_inventory()
+ return inv:is_empty("main")
+ end,
+ on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
+ minetest.log("action", S("@1 moves stuff in workbench at @2", player:get_player_name(), minetest.pos_to_string(pos)))
+ end,
+ on_metadata_inventory_put = function(pos, listname, index, stack, player)
+ minetest.log("action", S("@1 moves stuff to workbench at @2", player:get_player_name(), minetest.pos_to_string(pos)))
+ end,
+ on_metadata_inventory_take = function(pos, listname, index, stack, player)
+ minetest.log("action", S("@1 takes stuff from workbench at @2", player:get_player_name(), minetest.pos_to_string(pos)))
+ end,
+})
+local get_recipe = function ( inv )
+ local result, needed, input
+ needed = inv:get_list( 'rec' )
+
+ result, input = minetest.get_craft_result( {
+ method = 'normal',
+ width = 3,
+ items = needed
+ })
+
+ local totalneed = {}
+
+ if result.item:is_empty() then
+ result = nil
+ else
+ result = result.item
+ for _, item in ipairs( needed ) do
+ if item ~= nil and not item:is_empty() and not inv:contains_item( 'src', item ) then
+ result = nil
+ break
+ end
+ if item ~= nil and not item:is_empty() then
+ if totalneed[item:get_name()] == nil then
+ totalneed[item:get_name()] = 1
+ else
+ totalneed[item:get_name()] = totalneed[item:get_name()] + 1
+ end
+ end
+ end
+ for name, number in pairs( totalneed ) do
+ local totallist = inv:get_list( 'src' )
+ for i, srcitem in pairs( totallist ) do
+ if srcitem:get_name() == name then
+ local taken = srcitem:take_item( number )
+ number = number - taken:get_count()
+ totallist[i] = srcitem
+ end
+ if number <= 0 then
+ break
+ end
+ end
+ if number > 0 then
+ result = nil
+ break
+ end
+ end
+ end
+
+ return needed, input, result
+end
+
+minetest.register_abm( {
+ nodenames = { 'crafting_bench:workbench' },
+ interval = crafting_rate,
+ chance = 1,
+ action = function ( pos, node )
+ local meta = minetest.get_meta( pos )
+ local inv = meta:get_inventory()
+ local result, newinput, needed
+ if not inv:is_empty( 'src' ) then
+ -- Check for a valid recipe and sufficient resources to craft it
+ needed, newinput, result = get_recipe( inv )
+ if result ~= nil and inv:room_for_item( 'dst', result ) then
+ inv:add_item( 'dst', result )
+ for i, item in pairs( needed ) do
+ if item ~= nil and item ~= '' then
+ inv:remove_item( 'src', ItemStack( item ) )
+ end
+ if newinput[i] ~= nil and not newinput[i]:is_empty() then
+ inv:add_item( 'src', newinput[i] )
+ end
+ end
+ end
+ end
+ end
+} )
+
+local function has_locked_chest_privilege(meta, player)
+ if player:get_player_name() ~= meta:get_string("owner") then
+ return false
+ end
+ return true
+end
+
+minetest.register_craft({
+ output = "crafting_bench:workbench",
+ recipe = {
+ {"default:steel_ingot","default:steel_ingot","default:steel_ingot"},
+ {"default:wood", "default:wood","default:steel_ingot"},
+ {"default:tree", "default:tree","default:steel_ingot"},
+ }
+})
+
+-- Hopper compatibility
+if minetest.get_modpath("hopper") and hopper ~= nil and hopper.add_container ~= nil then
+ hopper:add_container({
+ {"top", "crafting_bench:workbench", "dst"},
+ {"side", "crafting_bench:workbench", "src"},
+ {"bottom", "crafting_bench:workbench", "src"},
+ })
+end
diff --git a/crafting_bench/intllib.lua b/crafting_bench/intllib.lua
new file mode 100644
index 0000000..6669d72
--- /dev/null
+++ b/crafting_bench/intllib.lua
@@ -0,0 +1,45 @@
+
+-- Fallback functions for when `intllib` is not installed.
+-- Code released under Unlicense <http://unlicense.org>.
+
+-- Get the latest version of this file at:
+-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
+
+local function format(str, ...)
+ local args = { ... }
+ local function repl(escape, open, num, close)
+ if escape == "" then
+ local replacement = tostring(args[tonumber(num)])
+ if open == "" then
+ replacement = replacement..close
+ end
+ return replacement
+ else
+ return "@"..open..num..close
+ end
+ end
+ return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
+end
+
+local gettext, ngettext
+if minetest.get_modpath("intllib") then
+ if intllib.make_gettext_pair then
+ -- New method using gettext.
+ gettext, ngettext = intllib.make_gettext_pair()
+ else
+ -- Old method using text files.
+ gettext = intllib.Getter()
+ end
+end
+
+-- Fill in missing functions.
+
+gettext = gettext or function(msgid, ...)
+ return format(msgid, ...)
+end
+
+ngettext = ngettext or function(msgid, msgid_plural, n, ...)
+ return format(n==1 and msgid or msgid_plural, ...)
+end
+
+return gettext, ngettext
diff --git a/crafting_bench/locale/template.pot b/crafting_bench/locale/template.pot
new file mode 100644
index 0000000..7ac578e
--- /dev/null
+++ b/crafting_bench/locale/template.pot
@@ -0,0 +1,67 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2017-02-28 21:08-0700\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: init.lua:7
+msgid ""
+"The inventory on the left is for raw materials, the inventory on the right "
+"holds finished products. The crafting grid in the center defines what recipe "
+"this workbench will make use of; place raw materials into it in the crafting "
+"pattern corresponding to what you want to build."
+msgstr ""
+
+#: init.lua:10
+msgid ""
+"This workbench is compatible with hoppers. Hoppers will insert into the raw "
+"material inventory and remove items from the finished goods inventory."
+msgstr ""
+
+#: init.lua:19 init.lua:49
+msgid "Workbench"
+msgstr ""
+
+#: init.lua:20
+#, lua-format
+msgid ""
+"A workbench that does work for you. Set a crafting recipe and provide raw "
+"materials and items will magically craft themselves once every %i seconds."
+msgstr ""
+
+#: init.lua:42
+msgid "Source Material"
+msgstr ""
+
+#: init.lua:44
+msgid "Recipe to Use"
+msgstr ""
+
+#: init.lua:46
+msgid "Craft Output"
+msgstr ""
+
+#: init.lua:61
+msgid "@1 moves stuff in workbench at @2"
+msgstr ""
+
+#: init.lua:64
+msgid "@1 moves stuff to workbench at @2"
+msgstr ""
+
+#: init.lua:67
+msgid "@1 takes stuff from workbench at @2"
+msgstr ""
diff --git a/crafting_bench/mod.conf b/crafting_bench/mod.conf
new file mode 100644
index 0000000..9d51c80
--- /dev/null
+++ b/crafting_bench/mod.conf
@@ -0,0 +1 @@
+name = crafting_bench
diff --git a/crafting_bench/screenshot.png b/crafting_bench/screenshot.png
new file mode 100644
index 0000000..e068be8
--- /dev/null
+++ b/crafting_bench/screenshot.png
Binary files differ
diff --git a/crafting_bench/settingtypes.txt b/crafting_bench/settingtypes.txt
new file mode 100644
index 0000000..9276289
--- /dev/null
+++ b/crafting_bench/settingtypes.txt
@@ -0,0 +1,2 @@
+# The number of seconds between each operation of the crafting bench.
+crafting_bench_crafting_rate (Crafting rate) int 5 1 60 \ No newline at end of file
diff --git a/crafting_bench/textures/LICENSE.txt b/crafting_bench/textures/LICENSE.txt
new file mode 100644
index 0000000..bd7ca92
--- /dev/null
+++ b/crafting_bench/textures/LICENSE.txt
@@ -0,0 +1,20 @@
+--------------------------------------------
+
+License Textures: Philipner - CC-BY-SA 3.0
+
+-crafting_bench_workbench_back.png
+-crafting_bench_workbench_front.png
+-crafting_bench_workbench_side.png
+-crafting_bench_workbench_top.png
+
+
+--------------------------------------------
+
+16 px textures based on crafting_bench mod
+original textures by Philipner
+
+License Textures: Napiophelios - CC-BY-SA 3.0
+
+-crafting_bench_workbench_bottom.png
+
+--------------------------------------------
diff --git a/crafting_bench/textures/crafting_bench_workbench_back.png b/crafting_bench/textures/crafting_bench_workbench_back.png
new file mode 100644
index 0000000..174d941
--- /dev/null
+++ b/crafting_bench/textures/crafting_bench_workbench_back.png
Binary files differ
diff --git a/crafting_bench/textures/crafting_bench_workbench_bottom.png b/crafting_bench/textures/crafting_bench_workbench_bottom.png
new file mode 100644
index 0000000..f50a8f3
--- /dev/null
+++ b/crafting_bench/textures/crafting_bench_workbench_bottom.png
Binary files differ
diff --git a/crafting_bench/textures/crafting_bench_workbench_front.png b/crafting_bench/textures/crafting_bench_workbench_front.png
new file mode 100644
index 0000000..27a1f1f
--- /dev/null
+++ b/crafting_bench/textures/crafting_bench_workbench_front.png
Binary files differ
diff --git a/crafting_bench/textures/crafting_bench_workbench_side.png b/crafting_bench/textures/crafting_bench_workbench_side.png
new file mode 100644
index 0000000..b6418ac
--- /dev/null
+++ b/crafting_bench/textures/crafting_bench_workbench_side.png
Binary files differ
diff --git a/crafting_bench/textures/crafting_bench_workbench_top.png b/crafting_bench/textures/crafting_bench_workbench_top.png
new file mode 100644
index 0000000..fef4827
--- /dev/null
+++ b/crafting_bench/textures/crafting_bench_workbench_top.png
Binary files differ