Added connected_chest, storage_interface. Updated unified_inventory, fromscratch. Removed microexpansion.
This commit is contained in:
parent
5e2009d083
commit
1a5b72c1ec
8
.gitmodules
vendored
8
.gitmodules
vendored
@ -18,7 +18,7 @@
|
||||
url = https://github.com/Quent42340/item_drop.git
|
||||
[submodule "mods/unified_inventory"]
|
||||
path = mods/unified_inventory
|
||||
url = https://github.com/Quent42340/unified_inventory.git
|
||||
url = https://github.com/minetest-mods/unified_inventory.git
|
||||
[submodule "mods/fluid_lib"]
|
||||
path = mods/fluid_lib
|
||||
url = https://gitlab.icynet.eu/evert/fluid_lib.git
|
||||
@ -28,3 +28,9 @@
|
||||
[submodule "mods/melterns"]
|
||||
path = mods/melterns
|
||||
url = https://gitlab.icynet.eu/evert/melterns.git
|
||||
[submodule "mods/storage_interface"]
|
||||
path = mods/storage_interface
|
||||
url = https://github.com/cx384/storage_interface.git
|
||||
[submodule "mods/connected_chests"]
|
||||
path = mods/connected_chests
|
||||
url = https://github.com/HybridDog/connected_chests.git
|
||||
|
6
TODO
6
TODO
@ -9,3 +9,9 @@ TODO
|
||||
|
||||
• TODO: Add more quest pages for `elepower` and `melterns`
|
||||
|
||||
# Other features
|
||||
|
||||
• TODO: Replace `witt` or improve it
|
||||
◦ TODO: Displayed block isn’t always the good block
|
||||
◦ TODO: Animated blocks are displayed with a weird scale
|
||||
|
||||
|
1
mods/connected_chests
Submodule
1
mods/connected_chests
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6a9f308529482ad34f8f8ae1374bea5a4d23354c
|
@ -1 +1 @@
|
||||
Subproject commit 6b28a573fbfdf3cda2e22cc01f0de0cd4039da9d
|
||||
Subproject commit f13e8d9d8c606a79f7a2429edd4689c39444ab16
|
@ -1,16 +0,0 @@
|
||||
MIT License
|
||||
Copyright (c) 2017 Elijah Duffy
|
||||
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.
|
@ -1,29 +0,0 @@
|
||||
![Screenshot](screenshot.png)
|
||||
|
||||
MicroExpansion - ME [microexpansion]
|
||||
======================================
|
||||
|
||||
* **Version:** 0.2, unstable
|
||||
* **Licence:** Code: MIT (see LICENSE), Media: CC-BY-SA 3.0
|
||||
* [Github Repository](https://github.com/octacian/microexpansion)
|
||||
* **Downloads:**
|
||||
* [Master (Unstable)](https://github.com/octacian/microexpansion/archive/master.zip)
|
||||
* ...or browse the code on [GitHub](https://github.com/octacian/microexpansion)
|
||||
|
||||
**Note**: MicroExpansion requires that you have `minetest-dev` with [this commit](https://github.com/minetest/minetest/commit/f2f9a923515386d787a245fac52f78e815b3a839) or later.
|
||||
|
||||
When you really get into a survival world, you typically end up with a lot of items, like a ton of items. Sometimes literally. But with that huge amount of resources, comes something annoying and typically unwanted: chests. Well, of course. You have to have chests to store items, but no biggie, it's just chests. Then your storage room starts to grow, soon you have 25 chests, then 50, then 100. Management gets kinda hard. MicroExpansion, is the solution.
|
||||
|
||||
Originally inspired by Applied Energistics 2 for Minecraft, MicroExpansion introduces many new nodes and items giving the player simpler and more compact ways to store thousands of items inside of a single ME drive.
|
||||
|
||||
**Note:** not all the features mentioned above are complete, so see the list directly below for planned and complete features.
|
||||
|
||||
### To Do List
|
||||
- [x] ME Chests
|
||||
- [ ] ME Networks
|
||||
- [ ] Remote Access to ME Networks
|
||||
- [ ] Spatial Storage Drives
|
||||
- [ ] ...and more.
|
||||
|
||||
### Discussion / Issues
|
||||
Discussion should take place here, on the forum post, or on enDEV IRC (irc.endev.xyz, port 6697, SSL, accept invalid certs), channel `#minetest`. Features requests should be made on the forum or through a GitHub issue. Bugs can best be reported by creating an issue on GitHub.
|
@ -1,84 +0,0 @@
|
||||
-- microexpansion/api.lua
|
||||
local BASENAME = "microexpansion"
|
||||
|
||||
-- [function] Register Recipe
|
||||
function microexpansion.register_recipe(output, recipe)
|
||||
local function isint(n)
|
||||
return n==math.floor(n)
|
||||
end
|
||||
|
||||
local function getAmount()
|
||||
if isint(recipe[2][1]) then
|
||||
local q = recipe[2][1]
|
||||
recipe[2][1] = nil
|
||||
return q
|
||||
else return 1 end
|
||||
end
|
||||
|
||||
local function register(amount, recipe)
|
||||
minetest.register_craft({
|
||||
output = output.." "..amount,
|
||||
recipe = recipe,
|
||||
})
|
||||
end
|
||||
|
||||
local function single()
|
||||
register(getAmount(), recipe[2])
|
||||
end
|
||||
|
||||
local function multiple()
|
||||
for i, item in ipairs(recipe) do
|
||||
if i == 0 then return end
|
||||
register(getAmount(), recipe[i])
|
||||
end
|
||||
end
|
||||
|
||||
-- Check type
|
||||
if recipe[1] == "single" then single()
|
||||
elseif recipe[1] == "multiple" then multiple()
|
||||
else return microexpansion.log("invalid recipe for definition "..output..". "..dump(recipe[2])) end
|
||||
end
|
||||
|
||||
-- [function] Register Item
|
||||
function microexpansion.register_item(itemstring, def)
|
||||
-- Set usedfor
|
||||
if def.usedfor then
|
||||
def.description = def.description .. "\n"..minetest.colorize("grey", def.usedfor)
|
||||
end
|
||||
-- Update inventory image
|
||||
if def.inventory_image then
|
||||
def.inventory_image = BASENAME.."_"..def.inventory_image..".png"
|
||||
else
|
||||
def.inventory_image = BASENAME.."_"..itemstring..".png"
|
||||
end
|
||||
|
||||
-- Register craftitem
|
||||
minetest.register_craftitem(BASENAME..":"..itemstring, def)
|
||||
|
||||
-- if recipe, Register recipe
|
||||
if def.recipe then
|
||||
microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe)
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Register Node
|
||||
function microexpansion.register_node(itemstring, def)
|
||||
-- Set usedfor
|
||||
if def.usedfor then
|
||||
def.description = def.description .. "\n"..minetest.colorize("grey", def.usedfor)
|
||||
end
|
||||
-- Update texture
|
||||
if auto_complete ~= false then
|
||||
for _,i in ipairs(def.tiles) do
|
||||
def.tiles[_] = BASENAME.."_"..i..".png"
|
||||
end
|
||||
end
|
||||
|
||||
-- register craftitem
|
||||
minetest.register_node(BASENAME..":"..itemstring, def)
|
||||
|
||||
-- if recipe, register recipe
|
||||
if def.recipe then
|
||||
microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe)
|
||||
end
|
||||
end
|
@ -1 +0,0 @@
|
||||
default
|
@ -1,8 +0,0 @@
|
||||
# Documentation
|
||||
The APIs provided by MicroExpansion are divided among several different files. Unless otherwise mentioned, the `.md` documentation file is labeled the same as the Lua file containing the code. However, for modules, documentation is found in a subdirectory. Below, the main documentation sections are found before being divided depending on the module.
|
||||
|
||||
### `modules.md`
|
||||
Non-API portions of MicroExpansion are loaded as modules to allow them to be easily enabled or disabled. This documents the API for loading, configuring, and interacting with modules.
|
||||
|
||||
### `api.lua`
|
||||
This section documents the "core" API that is always loaded before any modules (`api.lua`). This API is mostly made up of functions to make registering items, nodes, and recipes quicker and more intuitive.
|
@ -1,49 +0,0 @@
|
||||
# Core API
|
||||
The core API is composed of several functions to make registering new items, nodes, and recipes for items and nodes more efficient and intuitive. Code for this public API is in `./api.lua`. This documentation is divided up per function.
|
||||
|
||||
#### `register_recipe(output, def)`
|
||||
__Usage:__ `microexpansion.register_recipe(<output (string)>, <recipe (table)>)`
|
||||
|
||||
Though this may seem rather complex to understand, this is a very useful timesaving function when registering recipes. It allows registering multiple recipes at once in one table. The output must always remain the same as is specified as the first parameter, while the second parameter should be a table structured like one of the tables below.
|
||||
|
||||
__Single Recipe:__
|
||||
```lua
|
||||
microexpansion.register_recipe("default:steelblock", {
|
||||
"single",
|
||||
{
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
The above registers a single recipe for the item specified.
|
||||
|
||||
__Multiple Recipes:__
|
||||
```lua
|
||||
microexpansion.register_recipe("default:steelblock", {
|
||||
"multiple",
|
||||
{
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
|
||||
},
|
||||
{
|
||||
{ "default:steel_ingot", "default:steel_ingot" },
|
||||
{ "default:steel_ingot", "default:steel_ingot" },
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The above registers multiple recipes for the item specified.
|
||||
|
||||
#### `register_item(itemstring, def)`
|
||||
__Usage:__ `microexpansion.register_item(<itemstring (string)>, <item definition (table)>`
|
||||
|
||||
This API function accepts the same parameters in the definition table as does `minetest.register_craftitem`, however, it makes several modifications to the parameters before passing them on. A new parameter, `usedfor`, is introduced, which if provided is appened on a new line in grey to the item description, a good way to specify what the item does or include more information about it. The `inventory_image` parameter is modified to enforce the naming style adding `microexpansion_` to the beginning of the specified path, and `.png` to the end. If not `inventory_image` is provided, the itemstring is used and then undergoes the above modification. This allows shortening and even removing the `inventory_image` code, while passing everything else (aside from `usedfor`) on to `minetest.register_craftitem`.
|
||||
|
||||
#### `register_node(itemstring, def)`
|
||||
__Usage:__ `microexpansion.register_node(<itemstring (string)>, <item definition (table)>`
|
||||
|
||||
This API function accepts the same parameters in the definition table as does `minetest.register_craftitem`, however, it makes several modifications to the parameters before passing them on. A new parameter, `usedfor`, is introduced, which if provided is appened on a new line in grey to the item description, a good way to specify what the item does or include more information about it. The `tiles` table is modified so as to simplify the definition when registering the node. Each texture in the `tiles` table has `microexpansion_` added to the beginning and `.png` to the end. This means that rather than specifying something like `microexpansion_chest_top.png`, only `chest_top` is required. __Note:__ the texture path "autocomplete" functionality can be disabled by settings `auto_complete` to `false` in the definition (useful if using textures from another mod).
|
@ -1,35 +0,0 @@
|
||||
# Modules
|
||||
Non-API portions of MicroExpansion are loaded as modules to allow them to be easily enabled or disabled. Modules can be manually loaded or required from the API or from another module. Specific modules can be disabled using `modules.conf`, as documented below.
|
||||
|
||||
## Managing Modules
|
||||
Modules listed in the configuration file are automatically loaded at startup unless specifically disabled. For the purpose of listing and/or disabling mods, we've introduced the `modules.conf` file.
|
||||
|
||||
Each module is listed on a new line, as if setting a variable. A module can be disabled or enabled by setting this variable to `true` or `false`. If a module is not listed here, or is set to `false` (disabled), it will not be automatically loaded.
|
||||
|
||||
__Example:__
|
||||
```lua
|
||||
-- Enabled:
|
||||
storage = true
|
||||
-- Disabled:
|
||||
storage = false
|
||||
```
|
||||
|
||||
A small API is provided allowing modules to be loaded from another module or from the main API. A module can be force loaded (overrides configuration), or can be loaded with the configuration in mind.
|
||||
|
||||
## Module API
|
||||
Modules are places a subdirectories of the `modules` directory. Each module must have the same name as its reference in the configuration file. Modules must have an `init.lua` file, where you can load other portions of the module with `dofile`, or use the API documented below.
|
||||
|
||||
#### `get_module_path(name)`
|
||||
__Usage:__ `microexpansion.get_module_path(<module name (string)>)`
|
||||
|
||||
Returns the full path of the module or `nil` if it does not exist. This can be used to check for another module, or to easily access the path of the current module in preparation to load other files with `dofile` or the likes.
|
||||
|
||||
#### `load_module(name)`
|
||||
__Usage:__ `microexpansion.load_module(<module name (string)>)`
|
||||
|
||||
Attempts to load a module. If the module path is `nil`, `nil` is returned to indicate that the module does not exist. Otherwise, a return value of `true` indicates a success or that the module has already been loaded. __Note:__ this function overrides any settings in `modules.conf`, meaning that it will be loaded even if it was disabled. For general use cases, use `require_module` instead.
|
||||
|
||||
#### `require_module(name)`
|
||||
__Usage:__ `microexpansion.require_module(<module name (string)>)`
|
||||
|
||||
Passes name to `load_module` if the mod was not disabled in `modules.conf`. For further documentation, see `load_module`.
|
@ -1,5 +0,0 @@
|
||||
# [Module] Storage
|
||||
The storage module introduces storage systems to allow storing thousands of items inside a single ME Storage Drive. This modules registers an array of storage drives and many devices to make advanced interactions with drives in networks or by themselves. The documentation is divided by section in different files as seen below.
|
||||
|
||||
### `api.md`
|
||||
This section documents the programmatic API used to register storage cells themselves and any other global storage-related functions.
|
@ -1,33 +0,0 @@
|
||||
# Storage API
|
||||
The storage API introduces functions to help register and handle storage devices and related machines and controllers.
|
||||
|
||||
#### `register_cell(itemstring, def)`
|
||||
__Usage:__ `microexpansion.register_cell(<itemstring (string)>, <cell definition (table)>`
|
||||
|
||||
This function registers an item storage cell modifying and adding content to the definition table before passing it on to `minetest.register_craftiem`. Only some definition fields are passed on, as drives are not functional outside of a drive bay or ME Chest. Only the `description` and `capacity` must be required. However, if the `inventory_image` base is any different from the `itemstring`, it should be provided as well. The capacity should be an integer specifying the number of items (not slots, or something else) that the drive can store.
|
||||
|
||||
#### `get_cell_size(name)`
|
||||
__Usage:__ `microexpansion.get_cell_size(<full itemstring (string)>)`<br />
|
||||
__Example__:__ `microexpansion.get_cell_size("microexpansion:cell_8k")`
|
||||
|
||||
Returns the integer containing the size of the storage cell specified (size as in max number of items). __Note:__ The itemstring should be for example `microexpansion:cell_8k`, not just `cell_8k`.
|
||||
|
||||
#### `int_to_stacks(int)`
|
||||
__Usage:__ `microexpansion.int_to_stacks(int)`
|
||||
|
||||
Calculates the approximate number of stacks from the provided integer which should contain the max number of items.
|
||||
|
||||
#### `int_to_pagenum(int)`
|
||||
__Usage:__ `microexpansion.int_to_pagenum(int)`
|
||||
|
||||
Calculates the approximate number of pages from the integer provided which should represent the total number of items.
|
||||
|
||||
#### `move_inv(inv1, inv2)`
|
||||
__Usage:__ `microexpansion.move_inv(<from inventory (userdata)>, <to inventory (userdata)>)`
|
||||
|
||||
Moves all the contents of one inventory (`inv1`) to another inventory (`inv2`).
|
||||
|
||||
#### `cell_desc(inv, listname, stack_pos)`
|
||||
__Usage:__ `microexpansion.cell_desc(<inventory (userdata)>, <list name (string)>, <stack position (integer)>)`
|
||||
|
||||
Updates the description of an ME Storage Cell to show the amount of items in it vs the max amount of items. The first parameter should be a `userdata` value representing the inventory in which the list containing the cell itemstack is found. The second parameter should contain the name of the list in which the cell itemstack is found. The third (and final) parameter must be an integer telling at what position to storage cell is in the inventory list.
|
@ -1,66 +0,0 @@
|
||||
-- microexpansion/init.lua
|
||||
microexpansion = {}
|
||||
microexpansion.modpath = minetest.get_modpath("microexpansion") -- modpath
|
||||
local modpath = microexpansion.modpath -- modpath pointer
|
||||
|
||||
-- Formspec GUI related stuff
|
||||
microexpansion.gui_bg = "bgcolor[#080808BB;true]background[5,5;1,1;gui_formbg.png;true]"
|
||||
microexpansion.gui_slots = "listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]"
|
||||
|
||||
-- logger
|
||||
function microexpansion.log(content, log_type)
|
||||
if not content then return false end
|
||||
if log_type == nil then log_type = "action" end
|
||||
minetest.log(log_type, "[MicroExpansion] "..content)
|
||||
end
|
||||
|
||||
-- Load API
|
||||
dofile(modpath.."/api.lua")
|
||||
|
||||
-------------------
|
||||
----- MODULES -----
|
||||
-------------------
|
||||
|
||||
local loaded_modules = {}
|
||||
|
||||
local settings = Settings(modpath.."/modules.conf"):to_table()
|
||||
|
||||
-- [function] Get module path
|
||||
function microexpansion.get_module_path(name)
|
||||
local module_path = modpath.."/modules/"..name
|
||||
|
||||
if io.open(module_path.."/init.lua") then
|
||||
return module_path
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Load module (overrides modules.conf)
|
||||
function microexpansion.load_module(name)
|
||||
if loaded_modules[name] ~= false then
|
||||
local module_init = microexpansion.get_module_path(name).."/init.lua"
|
||||
|
||||
if module_init then
|
||||
dofile(module_init)
|
||||
loaded_modules[name] = true
|
||||
return true
|
||||
else
|
||||
microexpansion.log("Invalid module \""..name.."\". The module either does not exist "..
|
||||
"or is missing an init.lua file.", "error")
|
||||
end
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Require module (does not override modules.conf)
|
||||
function microexpansion.require_module(name)
|
||||
if settings[name] and settings[name] ~= false then
|
||||
return microexpansion.load_module(name)
|
||||
end
|
||||
end
|
||||
|
||||
for name,enabled in pairs(settings) do
|
||||
if enabled ~= false then
|
||||
microexpansion.load_module(name)
|
||||
end
|
||||
end
|
@ -1 +0,0 @@
|
||||
storage = true
|
@ -1,97 +0,0 @@
|
||||
-- storage/api.lua
|
||||
|
||||
local BASENAME = "microexpansion"
|
||||
|
||||
-- [function] register cell
|
||||
function microexpansion.register_cell(itemstring, def)
|
||||
if not def.inventory_image then
|
||||
def.inventory_image = itemstring
|
||||
end
|
||||
|
||||
-- register craftitem
|
||||
minetest.register_craftitem(BASENAME..":"..itemstring, {
|
||||
description = def.description,
|
||||
inventory_image = BASENAME.."_"..def.inventory_image..".png",
|
||||
groups = {microexpansion_cell = 1},
|
||||
stack_max = 1,
|
||||
microexpansion = {
|
||||
base_desc = def.description,
|
||||
drive = {
|
||||
capacity = def.capacity or 5000,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- if recipe, register recipe
|
||||
if def.recipe then
|
||||
-- if recipe, register recipe
|
||||
if def.recipe then
|
||||
microexpansion.register_recipe(BASENAME..":"..itemstring, def.recipe)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Get cell size
|
||||
function microexpansion.get_cell_size(name)
|
||||
local item = minetest.registered_craftitems[name]
|
||||
if item then
|
||||
return item.microexpansion.drive.capacity
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Calculate max stacks
|
||||
function microexpansion.int_to_stacks(int)
|
||||
return math.floor(int / 99)
|
||||
end
|
||||
|
||||
-- [function] Calculate number of pages
|
||||
function microexpansion.int_to_pagenum(int)
|
||||
return math.floor(microexpansion.int_to_stacks(int) / 32)
|
||||
end
|
||||
|
||||
-- [function] Move items from inv to inv
|
||||
function microexpansion.move_inv(inv1, inv2)
|
||||
local finv, tinv = inv1.inv, inv2.inv
|
||||
local fname, tname = inv1.name, inv2.name
|
||||
|
||||
for i,v in ipairs(finv:get_list(fname) or {}) do
|
||||
if tinv and tinv:room_for_item(tname, v) then
|
||||
local leftover = tinv:add_item( tname, v )
|
||||
finv:remove_item(fname, v)
|
||||
if leftover and not(leftover:is_empty()) then
|
||||
finv:add_item(fname, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- [function] Update cell description
|
||||
function microexpansion.cell_desc(inv, listname, spos)
|
||||
local stack = inv:get_stack(listname, spos)
|
||||
|
||||
if stack:get_name() ~= "" then
|
||||
local meta = stack:get_meta()
|
||||
local base_desc = minetest.registered_craftitems[stack:get_name()].microexpansion.base_desc
|
||||
local max_slots = inv:get_size("main")
|
||||
local max_items = math.floor(max_slots * 99)
|
||||
|
||||
local slots, items = 0, 0
|
||||
-- Get amount of items in drive
|
||||
for i = 1, max_items do
|
||||
local stack = inv:get_stack("main", i)
|
||||
local item = stack:get_name()
|
||||
if item ~= "" then
|
||||
slots = slots + 1
|
||||
local num = stack:get_count()
|
||||
if num == 0 then num = 1 end
|
||||
items = items + num
|
||||
end
|
||||
end
|
||||
|
||||
-- Update description
|
||||
meta:set_string("description", base_desc.."\n"..
|
||||
minetest.colorize("grey", tostring(items).."/"..tostring(max_items).." Items"))
|
||||
-- Update stack
|
||||
inv:set_stack(listname, spos, stack)
|
||||
end
|
||||
end
|
@ -1,12 +0,0 @@
|
||||
-- storage/init.lua
|
||||
|
||||
local module_path = microexpansion.get_module_path("storage")
|
||||
|
||||
-- Load API
|
||||
dofile(module_path.."/api.lua")
|
||||
|
||||
-- Load storage devices
|
||||
dofile(module_path.."/storage.lua")
|
||||
|
||||
-- Load machines
|
||||
dofile(module_path.."/machines.lua")
|
@ -1,195 +0,0 @@
|
||||
-- microexpansion/machines.lua
|
||||
|
||||
local me = microexpansion
|
||||
|
||||
-- [me chest] Get formspec
|
||||
local function chest_formspec(pos, start_id, listname, page_max, query)
|
||||
local list
|
||||
local page_number = ""
|
||||
local to_chest = ""
|
||||
local query = query or ""
|
||||
|
||||
if not listname then
|
||||
list = "label[3,2;" .. minetest.colorize("red", "No cell!") .. "]"
|
||||
else
|
||||
list = "list[current_name;" .. listname .. ";0,0.3;8,4;" .. (start_id - 1) .. "]"
|
||||
to_chest = [[
|
||||
button[3.56,4.35;1.8,0.9;tochest;To Drive]
|
||||
tooltip[tochest;Move everything from your inventory to the ME drive.]
|
||||
]]
|
||||
end
|
||||
if page_max then
|
||||
page_number = "label[6.05,4.5;" .. math.floor((start_id / 32)) + 1 ..
|
||||
"/" .. page_max .."]"
|
||||
end
|
||||
|
||||
return [[
|
||||
size[9,9.5]
|
||||
]]..
|
||||
microexpansion.gui_bg ..
|
||||
microexpansion.gui_slots ..
|
||||
list ..
|
||||
[[
|
||||
label[0,-0.23;ME Chest]
|
||||
list[current_name;cells;8.06,1.8;1,1;]
|
||||
list[current_player;main;0,5.5;8,1;]
|
||||
list[current_player;main;0,6.73;8,3;8]
|
||||
button[5.4,4.35;0.8,0.9;prev;<]
|
||||
button[7.25,4.35;0.8,0.9;next;>]
|
||||
field[0.3,4.6;2.2,1;filter;;]]..query..[[]
|
||||
button[2.1,4.5;0.8,0.5;search;?]
|
||||
button[2.75,4.5;0.8,0.5;clear;X]
|
||||
tooltip[search;Search]
|
||||
tooltip[clear;Reset]
|
||||
listring[current_name;main]
|
||||
listring[current_player;main]
|
||||
field_close_on_enter[filter;false]
|
||||
]]..
|
||||
page_number ..
|
||||
to_chest
|
||||
end
|
||||
|
||||
-- [me chest] Register node
|
||||
microexpansion.register_node("chest", {
|
||||
description = "ME Chest",
|
||||
usedfor = "Can interact with items in ME storage cells",
|
||||
tiles = {
|
||||
"chest_top",
|
||||
"chest_top",
|
||||
"chest_side",
|
||||
"chest_side",
|
||||
"chest_side",
|
||||
"chest_front",
|
||||
},
|
||||
is_ground_content = false,
|
||||
groups = { cracky = 1 },
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec", chest_formspec(pos, 1))
|
||||
meta:set_string("inv_name", "none")
|
||||
meta:set_int("page", 1)
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("cells", 1)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if listname == "main" then
|
||||
return stack:get_count()
|
||||
elseif listname == "cells" then
|
||||
if minetest.get_item_group(stack:get_name(), "microexpansion_cell") ~= 0 then
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
end
|
||||
else
|
||||
return 0
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if listname == "main" then
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
inv:remove_item(listname, stack)
|
||||
inv:add_item(listname, stack)
|
||||
microexpansion.cell_desc(inv, "cells", 1)
|
||||
elseif listname == "cells" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local items = minetest.deserialize(stack:get_meta():get_string("items"))
|
||||
local size = me.get_cell_size(stack:get_name())
|
||||
local page_max = me.int_to_pagenum(size) + 1
|
||||
inv:set_size("main", me.int_to_stacks(size))
|
||||
if items then
|
||||
inv:set_list("main", items)
|
||||
end
|
||||
meta:set_string("inv_name", "main")
|
||||
meta:set_string("formspec", chest_formspec(pos, 1, "main", page_max))
|
||||
end
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
if listname == "search" then
|
||||
inv:remove_item("main", stack)
|
||||
end
|
||||
microexpansion.cell_desc(inv, "cells", 1)
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if listname == "cells" then
|
||||
local t = minetest.get_us_time()
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local tab = {}
|
||||
local new_stack = inv:get_stack(listname, 1)
|
||||
local item_meta = new_stack:get_meta()
|
||||
for i = 1, inv:get_size("main") do
|
||||
if inv:get_stack("main", i):get_name() ~= "" then
|
||||
tab[#tab + 1] = inv:get_stack("main", i):to_string()
|
||||
end
|
||||
end
|
||||
item_meta:set_string("items", minetest.serialize(tab))
|
||||
inv:set_stack(listname, 1, new_stack)
|
||||
inv:set_size("main", 0)
|
||||
meta:set_int("page", 1)
|
||||
meta:set_string("formspec", chest_formspec(pos, 1))
|
||||
return new_stack:get_count()
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local page = meta:get_int("page")
|
||||
local inv_name = meta:get_string("inv_name")
|
||||
local inv = meta:get_inventory()
|
||||
local page_max = math.floor(inv:get_size("main") / 32) + 1
|
||||
local cell_stack = inv:get_stack("cells", 1)
|
||||
if inv_name == "none" then
|
||||
return
|
||||
end
|
||||
if fields.next then
|
||||
if page + 32 > inv:get_size(inv_name) then
|
||||
return
|
||||
end
|
||||
meta:set_int("page", page + 32)
|
||||
meta:set_string("formspec", chest_formspec(pos, page + 32, inv_name, page_max))
|
||||
elseif fields.prev then
|
||||
if page - 32 < 1 then
|
||||
return
|
||||
end
|
||||
meta:set_int("page", page - 32)
|
||||
meta:set_string("formspec", chest_formspec(pos, page - 32, inv_name, page_max))
|
||||
elseif fields.search or fields.key_enter_field == "filter" then
|
||||
inv:set_size("search", 0)
|
||||
if fields.filter == "" then
|
||||
meta:set_int("page", 1)
|
||||
meta:set_string("inv_name", "main")
|
||||
meta:set_string("formspec", chest_formspec(pos, 1, "main", page_max))
|
||||
else
|
||||
local tab = {}
|
||||
for i = 1, microexpansion.get_cell_size(cell_stack:get_name()) do
|
||||
local match = inv:get_stack("main", i):get_name():find(fields.filter)
|
||||
if match then
|
||||
tab[#tab + 1] = inv:get_stack("main", i)
|
||||
end
|
||||
end
|
||||
inv:set_list("search", tab)
|
||||
meta:set_int("page", 1)
|
||||
meta:set_string("inv_name", "search")
|
||||
meta:set_string("formspec", chest_formspec(pos, 1, "search", page_max, fields.filter))
|
||||
end
|
||||
elseif fields.clear then
|
||||
inv:set_size("search", 0)
|
||||
meta:set_int("page", 1)
|
||||
meta:set_string("inv_name", "main")
|
||||
meta:set_string("formspec", chest_formspec(pos, 1, "main", page_max))
|
||||
elseif fields.tochest then
|
||||
local pinv = minetest.get_inventory({type="player", name=sender:get_player_name()})
|
||||
microexpansion.move_inv({ inv=pinv, name="main" }, { inv=inv, name="main" })
|
||||
end
|
||||
end,
|
||||
})
|
@ -1,7 +0,0 @@
|
||||
-- microexpansion/storage.lua
|
||||
|
||||
-- [drive] 8k
|
||||
microexpansion.register_cell("cell_8k", {
|
||||
description = "8k ME Storage Cell",
|
||||
capacity = 8000,
|
||||
})
|
Binary file not shown.
Before Width: | Height: | Size: 696 KiB |
Binary file not shown.
Before Width: | Height: | Size: 971 B |
Binary file not shown.
Before Width: | Height: | Size: 534 B |
Binary file not shown.
Before Width: | Height: | Size: 331 B |
Binary file not shown.
Before Width: | Height: | Size: 292 B |
Binary file not shown.
Before Width: | Height: | Size: 338 B |
1
mods/storage_interface
Submodule
1
mods/storage_interface
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a6e692bd12e21f1b044b1731e02242d15e58bb86
|
@ -1 +1 @@
|
||||
Subproject commit 06db3f49d61543eeb807a17c38b7597eb37611ca
|
||||
Subproject commit 54abad72f0e866f68b88d2fba5768739e26b388a
|
Loading…
x
Reference in New Issue
Block a user