Compare commits

..

4 Commits

Author SHA1 Message Date
loosewheel
cd3f250303 Add files via upload 2022-08-09 20:53:32 +10:00
loosewheel
fcf6b7b6ff Add files via upload 2022-08-09 19:50:22 +10:00
loosewheel
156b47f8b9 Add files via upload 2022-08-09 19:47:29 +10:00
loosewheel
fed7295111 Add files via upload 2022-08-09 19:44:22 +10:00
10 changed files with 1781 additions and 3 deletions

View File

@@ -180,3 +180,11 @@ v0.1.29
v0.1.30
* Added quantity field to droppers.
* Added 'Use player when placing' setting.
v0.1.31
* Added crafter.
v0.1.32
* Fixed crafter not return replacement items properly.

1603
crafter.lua Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -60,6 +60,26 @@ minetest.register_craft( {
})
minetest.register_craft( {
output = "lwcomponents:crafter",
recipe = {
{ "default:steel_ingot", "group:wood", "default:steel_ingot" },
{ "group:wood", "", "group:wood" },
{ "default:copper_ingot", "group:wood", "default:chest" },
},
})
minetest.register_craft( {
output = "lwcomponents:crafter_locked",
recipe = {
{ "default:steel_ingot", "group:wood", "default:steel_ingot" },
{ "group:wood", "", "group:wood" },
{ "default:copper_ingot", "group:wood", "default:chest_locked" },
},
})
minetest.register_craft( {
output = "lwcomponents:force_field",
recipe = {

5
crafting_mods.lua Normal file
View File

@@ -0,0 +1,5 @@
return
{
-- ["mod:crafted_item"] = { add = { "mod:name n", "mod:name n" }, remove = { "mod:name n", "mod:name n" } },
["farming:pineapple_ring"] = { add = { "farming:pineapple_top" } }
}

131
docs/crafter.txt Normal file
View File

@@ -0,0 +1,131 @@
Crafter
-------
Crafters can craft items by recipe or desired output item. Crafted items
are placed in the Output inventory, along with any replacement items (for
example if a bucket of milk is used in the craft the bucket is placed in
the Output inventory as well). Source items for the craft must be in the
Input inventory. If the crafter is adjoined to a storage unit the crafter
will also use source items from it as well.
Only the owner can dig or access the form of the locked version.
Unowned crafters can only access unowned units. Owned crafters can access
units of the same owner or unowned units.
UI
Input inventory - top left, source items for crafting.
Player inventory - lower left.
Channel - digilines channel of crafter, press enter or click Set to set.
Crafting grid - center top, enter a recipe to craft.
Automatic - if checked a craft of the recipe is performed every second (if possible).
Preview - this is a preview of the item crafted from the recipe.
Craft - perform 1 craft from the recipe (if possible).
Output inventory - center bottom, where crafted and replacement items are placed.
Search - top right.
Craftable list - right, list of all items that are possible to craft from
the input items. clicking an item crafts it (if possible).
The form does not update while open. A craft from source items no longer
available will not craft.
Terms can be entered into the search field, and when enter is pressed or
the Search button is pressed, only items whose name or description contains
these terms are shown in the list. That is if they match any of the space
separated terms.
When items are placed into the crafting grid a copy is used and the item
returns to where it was taken from. When items are removed from the crafting
grid they are disposed of.
The preview displays the craft preformed by the recipe. Items cannot be
pulled from here.
The automatic crafting is only operable when the crafter is in an active
block. Mesecons and digilines operations operate in unloaded blocks.
Hoppers placed to the top or sides of a crafter will feed items into the
input. Hoppers placed below a crafter will take items from the output.
Pipeworks tubes can push items into the input, and pull items from the
output.
Mesecons
Perform 1 craft from the recipe when power is turned on (if possible).
Digilines messages
"craft [qty]"
Craft from the recipe if possible. qty is optional, if given must be an
integer between 1 to 10.
"craftitem itemname [qty]"
Craft the given item if possible. itemname must be a valid item name
(eg. "default:wood"). qty is optional, if given must be an integer
between 1 to 10.
"automatic state"
Sets the automatic running state of the crafter. state must be true or
false.
"craftable"
Sends a digilines message with it's own channel of the possible craftable
items in the following form:
{
action = "craftable",
items = {
<items>
}
}
The items key is an indexed list of items. Each item entry is
a table with the following keys:
{
name -- string, the name of the item, as <mod>:<name>
description -- string, short description of item
}
"inventory"
Sends a digilines message with it's own channel of the source items,
including any attached storage, in the following form:
{
action = "inventory",
inventory = {
<items>
}
}
The inventory key is an indexed list of items. Each item entry is
a table with the following keys:
{
name -- string, the name of the item, as <mod>:<name>
description -- string, short description of item
count -- number, the total number of this item in storage
}
Set recipe grid:
{
action = "recipe",
items = { ... }
}
items must be a string list of item names as <mod>:<name>. The grid is
fill left to right, top to bottom. Up to the first 9 items are used.
* When crafting by item the output quantities may not be as expected. The
first found recipe for the craft which is satisfied by the available
items is used. So if you have saplings and wood in the input and try
to craft sticks, if the first recipe found uses the saplings 1 stick will
be output, if wood then 4 sticks. Also, sometimes the same recipe is
registered for more than 1 item. In this case, what item will actually
be crafted is ambiguous.
* The file 'crafting_mods.lua' in the mod folder contains a list of
crafting modifications. Modify this file as necessary. The field name
is the item being crafted. Each item in the add list is added to the
output inventory. Each item in the remove list is removed from the
replacements or source storage.
* Gaining the list of craftable items is an exponential process, based
on the number of unique source items and the total number of items
available. As a guide, 320 source items and 795 total items that resulted
623 craftable items took approx. 200ms (1st gen i5 processor). This list
is only gained: when the form is opened; when the Search button is clicked;
and when the digilines "craftable" message is sent.

View File

@@ -19,7 +19,7 @@ Channel - digilines channel of indexer.
Input - middle.
Output - top right.
Filter - center right.
Player inventor - lower right.
Player inventory - lower right.
When the UI is accessed the storage is scanned, and its contents are
displayed in the list. The list contains the following columns:

View File

@@ -1,4 +1,4 @@
local version = "0.1.30"
local version = "0.1.32"
local mod_storage = minetest.get_mod_storage ()
@@ -40,6 +40,7 @@ loadfile (modpath.."/pistons.lua") (utils)
loadfile (modpath.."/through_wire.lua") (utils)
loadfile (modpath.."/camera.lua") (utils)
loadfile (modpath.."/storage.lua") (utils)
loadfile (modpath.."/crafter.lua") (utils)
loadfile (modpath.."/force_field.lua") (utils)
loadfile (modpath.."/destroyer.lua") (utils)
loadfile (modpath.."/extras.lua") (utils)

View File

@@ -13,7 +13,7 @@ CC BY-SA 3.0
Version
=======
0.1.30
0.1.32
Minetest Version
@@ -71,6 +71,7 @@ Various components for mesecons and digilines.
* Movefloor, similar to vertical mesecons movestone.
* Camera, takes a representative image.
* Storage, indexed storage units.
* Crafter, crafts by recipe or by item, and can pull from storage units.
* Hoppers, that are more compatible with this mod.
* Force Field Generator, repels players and mobs within a radius.
* Mesecons Through Wire, transmits through 1 to 2 solid blocks.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -439,4 +439,13 @@ end
local crafting_mods = dofile (minetest.get_modpath ("lwcomponents").."/crafting_mods.lua")
function utils.get_crafting_mods (item)
return crafting_mods[item]
end
--