[mod] Automated Storage & Retrieval System [asrs]

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

[mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Image
Are you sick and tired of creating a room full of chests to store all your items, only to forget which chest you put them in? Have you found yourself creating signs for new chests only to discover you now have the same items in multiple different chests scattered throughout your base?
This mod aims to solve that problem. Craft a single controller and then expend it's storage with lifts and storage cells. The inventory can all be accessed from a singular location, and even has handy sorting, searching, and sharing methods builtin.
Pipeworks, techage, and tubelib support included. Pipes from each mod can be connected directly to the main controller or to special cells. These cells allow you to add inventory from anywhere so you can keep a neat looking front to your storage opperations.
Image

Download: https://notabug.org/NathanS21/asrs/archive/master.zip
Git: https://notabug.org/NathanS21/asrs
License: code MIT, media CC by SA 3.0
Attachments
screenshot_20230904_151047.png
screenshot_20230904_151047.png (80.69 KiB) Viewed 8341 times
screenshot_20230904_151031.png
screenshot_20230904_151031.png (743.81 KiB) Viewed 8341 times
Last edited by Nathan.S on Sun Jan 21, 2024 22:56, edited 3 times in total.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Ghaydn
Member
Posts: 64
Joined: Sat Sep 26, 2020 11:58
In-game: ghaydn
Location: Moscow, Russia

Re: [mod]Automated Storage & Retrieval System [asrs]

by Ghaydn » Post

Wow, this looks like a worthy alternative to drawers.
Does it (will it) support pipeworks/tubelib ?
Nobody understands me... — вРН БШ ЯЙЮГЮКХ?

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod]Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Currently this doesn't support any additional mods, but I do plan on adding support for pipeworks. I'll have to see how tubelib works to see if I can add support to that mod.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod]Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Support for pipeworks has been added. Connect to the controller unit from the bottom or back side.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
TechNolaByte
Member
Posts: 465
Joined: Wed May 10, 2017 21:00
GitHub: TechNolaByte

Re: [mod]Automated Storage & Retrieval System [asrs]

by TechNolaByte » Post

Does that include support for filtered item extraction? That would be pretty epic for all kinds of automation.
The great quest of alchemy neither failed nor attained gold; programmers are those great alchemists who transmute caffeine into code.

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod]Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

I believe it should, as the extractors do the sorting and not the storage device.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

I've just added support for techpack/tubelib. I don't personally use those mods, so testing is needed. :)
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

I've just added a button to the settings tab which will let you remove a system, as long as you are the owner. This can be useful if you have a system that was placed prior to some updates that broke some backwards compatibility. This button will only be available for the system owner, and the node will be placed into player inventory, or dropped if there is not inventory space.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Whiskey
Member
Posts: 12
Joined: Sat Sep 01, 2018 19:42
GitHub: git512
In-game: Whiskey SNICKLE011

Re: [mod] Automated Storage & Retrieval System [asrs]

by Whiskey » Post

Seems very similar to the microexpansion mod. I'm super interested in checking this out.

Vince
Member
Posts: 22
Joined: Fri May 20, 2016 02:58
GitHub: vaggrippino
IRC: Vince
In-game: Vince

Re: [mod] Automated Storage & Retrieval System [asrs]

by Vince » Post

I started using it. Now that I've added a bunch of stuff it crashes the server whenever I try to use it. I can right-click on the controller and see the main inventory screen, but as soon as I click on any of the buttons, the server crashes with the following error.

I can remove items from that initial inventory screen, but I can't click on any of the page changing buttons.

Code: Select all

2024-01-11 08:11:05: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'asrs' in callback on_playerReceiveFields(): /home/vince/.minetest/mods/asrs/formspecs.lua:135: attempt to index local 'sys_data' (a nil value)
2024-01-11 08:11:05: ERROR[Main]: stack traceback:
2024-01-11 08:11:05: ERROR[Main]:       /home/vince/.minetest/mods/asrs/formspecs.lua:135: in function </home/vince/.minetest/mods/asrs/formspecs.lua:94>
2024-01-11 08:11:05: ERROR[Main]:       /usr/share/minetest/builtin/common/register.lua:26: in function </usr/share/minetest/builtin/common/register.lua:12>

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Were you able to change pages in the past?
Looking at the error and code this suggests that the system_id was somehow removed from the controller, which shouldn't be possible as that is stored in the node metadata, and has been since I initially posted the mod.
If you create a new system do you have the same error?
Data is stored in mod storage, if you are using the files backend can you check in the world directory and see if there is a file called asrs_systems? If there is check to see if the file contents are something more than
return {}
It is possible the file got corrupted maybe.
Worse case you should be able to pull out all the items from the first page, sort the inventory, and remove the first page's inventory again, etc etc. Not optimal but it should work.

I can replicate the error if I remove the asrs_systems file is removed, and can remove inventory in the above mentioned fashion. I am at a loss as to how the error could have been triggered. It really shouldn't be possible unless somehow the controller was moved and the meta wasn't moved with it, but any mods that provide mechanics to move nodes should really be moving the meta with the nodes.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Vince
Member
Posts: 22
Joined: Fri May 20, 2016 02:58
GitHub: vaggrippino
IRC: Vince
In-game: Vince

Re: [mod] Automated Storage & Retrieval System [asrs]

by Vince » Post

Nathan.S wrote:
Fri Jan 12, 2024 19:30
Were you able to change pages in the past?
Looking at the error and code this suggests that the system_id was somehow removed from the controller, which shouldn't be possible as that is stored in the node metadata, and has been since I initially posted the mod.
If you create a new system do you have the same error?
Data is stored in mod storage, if you are using the files backend can you check in the world directory and see if there is a file called asrs_systems? If there is check to see if the file contents are something more than
return {}
It is possible the file got corrupted maybe.
Worse case you should be able to pull out all the items from the first page, sort the inventory, and remove the first page's inventory again, etc etc. Not optimal but it should work.

I can replicate the error if I remove the asrs_systems file is removed, and can remove inventory in the above mentioned fashion. I am at a loss as to how the error could have been triggered. It really shouldn't be possible unless somehow the controller was moved and the meta wasn't moved with it, but any mods that provide mechanics to move nodes should really be moving the meta with the nodes.
Thank you very much for your reply, Nathan. I'm sorry I didn't answer sooner. I didn't realize that the topic wouldn't be automatically subscribed if I made a comment.

I was able to use all the buttons while I was setting it up and trying to figure it out.

I was able to move all the stuff out of the controller by removing items from the initial inventory screen like you suggested. I didn't think I'd be able to use the sort button without crashing the server again, but exiting and re-opening the interface showed what I suppose would be on the second page if I could change pages.

I'm not sure what the "files backend" is, but there is an asrs_systems file in the world directory. It only contains

Code: Select all

return {}
The only way I had moved it was by completely disassembling and reassembling it.

I created a new ASRS system on the same server and tried to reproduce the error with a second system by following the same steps...
  1. Controller + 8 lifts + 10 storage cells
  2. Load it up using a distributor and tubes (Techage (tubelib2?))
  3. Start clickin' buttons.
I wasn't able to reproduce the same issue, but I discovered a new one. All the buttons work on the second system, but now if I search for an item and move it to my inventory the server crashes with the following error message:

Code: Select all

2024-01-14 18:05:34: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'asrs' in callback nodemeta_inventory_OnTake(): D:\Programs\minetest-5.8.0-win64\bin\..\mods\asrs/nodes.lua:79: attempt to call a string value
2024-01-14 18:05:34: ERROR[Main]: stack traceback:
2024-01-14 18:05:34: ERROR[Main]:       D:\Programs\minetest-5.8.0-win64\bin\..\mods\asrs/nodes.lua:79: in function <D:\Programs\minetest-5.8.0-win64\bin\..\mods\asrs/nodes.lua:76>
If I restart the server after this, I'll find that the item I was trying to move is in my inventory, but it's also still in the ASRS.

I've also noticed after setting up this second system that the first system I set up doesn't crash the server when I click the buttons any more, but it also presents the search, crash, duplicate bug.

After all this, with both ASRS systems set up and the server down after crashing, I looked in asrs_systems again and there's a little more in there:

Code: Select all

return {Vince_1={max_inv=200,name="Vince",nodes=23,inv_pos={y=-5,z=-74,x=-72}}}
Let me know if you need more information or you want me to do anything to try and troubleshoot this.

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

The original asrs_systems file, from before you built a second one is/was corrupted somehow, could be my fault not sure as this is the first report I've heard of it happening. I checked over the code and don't see anything that appears to be incorrect with the reading and saving of that file.

The issue with taking an item from the search inventory I was able to replicate and fixed the bug that was causing that.

The second bit of content you pasted from the asrs_systems file is correct for one system, meaning the first one still is not functioning correctly. The file should just list every system and some information about the system so the debug screen, and the pipework/technic compatibility code all works.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Vince
Member
Posts: 22
Joined: Fri May 20, 2016 02:58
GitHub: vaggrippino
IRC: Vince
In-game: Vince

Re: [mod] Automated Storage & Retrieval System [asrs]

by Vince » Post

Wonderful! Thanks for fixing it. I removed the ContentDB version and cloned the notabug repo into my mods directory. I was able to confirm that the search results problem is gone for me.

The first ASRS system I set up seems to be working, too. I won't trust it, though.

😅 All it took was a little bit of punctuation... I don't know Lua, but I can read a diff. I guess .. is Lua's concatenation operator and it kinda makes sense now.

The initial problem is still a mystery, but seems to be gone now.

Thank you.

Vince
Member
Posts: 22
Joined: Fri May 20, 2016 02:58
GitHub: vaggrippino
IRC: Vince
In-game: Vince

Re: [mod] Automated Storage & Retrieval System [asrs]

by Vince » Post

The problem is back, with a very similar error to the first one I reported. This is a different server/world than the one I previously reported. I'm using Technic instead of Techage. I have an ASRS set up and it was loaded via pipeworks. I've been using it for awhile. Now, if I click on debug or any of the page arrows, it crashes the server with the following error.

Code: Select all

2024-01-21 19:32:24: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod 'asrs' in callback on_playerReceiveFields(): ...rams\minetest-5.8.0-win64\bin\..\mods\asrs/formspecs.lua:74: attempt to index local 'sys_data' (a nil value)
2024-01-21 19:32:24: ERROR[Main]: stack traceback:
2024-01-21 19:32:24: ERROR[Main]:       ...rams\minetest-5.8.0-win64\bin\..\mods\asrs/formspecs.lua:74: in function 'debug'
2024-01-21 19:32:24: ERROR[Main]:       ...rams\minetest-5.8.0-win64\bin\..\mods\asrs/formspecs.lua:157: in function <...rams\minetest-5.8.0-win64\bin\..\mods\asrs/formspecs.lua:94>
2024-01-21 19:32:24: ERROR[Main]:       ...\minetest-5.8.0-win64\bin\..\builtin\common\register.lua:26: in function <...\minetest-5.8.0-win64\bin\..\builtin\common\register.lua:12>
This was not installed using ContentDB via the Mintest GUI. This was a git clone that I made after you fixed the last error...

Code: Select all

❯ git log --oneline
7df864b (HEAD -> master, origin/master, origin/HEAD) fix bug with taking item from search results.

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Sorry for the delay, .. is lua's concatenation operator, turns out I forgot to test pulling things from the search inventory after I added the code that logged the inventory movement.
I have been unable to reproduce the new error. The only thing I can think of is a crash could be at fault. The current code only saves the backend data when the world exits, but if it crashes the data doesn't get saved. Have you had any crashes in either of the worlds, that weren't caused from the ASRS mod?
I'll make some changes so the saving happens when the data is modified would should prevent this from being an issue going forwards, but I'd still really like to know what's caused them.
Unfortunately any existing systems may be unstable, as the internal system_id is stored in metadata and that is used to lookup the data in the file. The function that creates the internal id does so by checking the existing ids in the file, and if the file is missing ids there will be two systems that have the same internal id and that will probably be a problem. I did add the internal id to the debug page so it will be possible to check if two systems have the same internal ID, though to fix it you'll have to remove all the inventory from the systems and dig them, which is quite annoying.

ContentDB should automatically pull the latest code from git and prompt you to update, although if it hasn't picked up my changes pulling manually can get you the updated code sooner. :)
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Vince
Member
Posts: 22
Joined: Fri May 20, 2016 02:58
GitHub: vaggrippino
IRC: Vince
In-game: Vince

Re: [mod] Automated Storage & Retrieval System [asrs]

by Vince » Post

Nathan.S wrote:
Sun Jan 21, 2024 18:35
Sorry for the delay, .. is lua's concatenation operator, turns out I forgot to test pulling things from the search inventory after I added the code that logged the inventory movement.
I have been unable to reproduce the new error. The only thing I can think of is a crash could be at fault. The current code only saves the backend data when the world exits, but if it crashes the data doesn't get saved. Have you had any crashes in either of the worlds, that weren't caused from the ASRS mod?
I'll make some changes so the saving happens when the data is modified would should prevent this from being an issue going forwards, but I'd still really like to know what's caused them.
Unfortunately any existing systems may be unstable, as the internal system_id is stored in metadata and that is used to lookup the data in the file. The function that creates the internal id does so by checking the existing ids in the file, and if the file is missing ids there will be two systems that have the same internal id and that will probably be a problem. I did add the internal id to the debug page so it will be possible to check if two systems have the same internal ID, though to fix it you'll have to remove all the inventory from the systems and dig them, which is quite annoying.

ContentDB should automatically pull the latest code from git and prompt you to update, although if it hasn't picked up my changes pulling manually can get you the updated code sooner. :)
I did some reading and experimenting and I think I might've fixed it... Since my asrs_systems file was empty, the problem wasn't that the system_id from minetest.get_meta(pos) was nil. The problem was that there wasn't anything in asrs.data.

I noticed what you pointed out about only writing the data in minetest.register_on_shutdown().
I just added a call to asrs.save() everywhere that asrs.data was modified:
Spoiler
❯ git diff
diff --git a/functions.lua b/functions.lua
index ea493ac..726786d 100644
--- a/functions.lua
+++ b/functions.lua
@@ -11,6 +11,7 @@ function asrs.create_id(player_name, pos)
new_data.name = player_name
new_data.nodes = 0
asrs.data[system_id] = new_data
+ asrs.save()
return system_id
end

diff --git a/nodes.lua b/nodes.lua
index cb17d27..e3eb0be 100644
--- a/nodes.lua
+++ b/nodes.lua
@@ -127,6 +127,7 @@ minetest.register_node('asrs:connection_point', {
that_meta:set_int('children', children + 1)
local connected_nodes = asrs.data[sys_id].nodes
asrs.data[sys_id].nodes = connected_nodes + 1
+ asrs.save()
end
})

@@ -147,6 +148,7 @@ minetest.register_node('asrs:cell', {
asrs.data[sys_id].max_inv = sys_inv_max + 20
local connected_nodes = asrs.data[sys_id].nodes
asrs.data[sys_id].nodes = connected_nodes + 1
+ asrs.save()
else
local name = placer:get_player_name()
minetest.chat_send_player(name, 'You must place this adjacent to a lift node.')
@@ -179,6 +181,7 @@ minetest.register_node('asrs:cell', {
asrs.data[sys_id].max_inv = sys_inv_max - 20
local connected_nodes = asrs.data[sys_id].nodes
asrs.data[sys_id].nodes = connected_nodes - 1
+ asrs.save()
end,
})

@@ -198,6 +201,7 @@ minetest.register_node('asrs:lift', {
that_meta:set_int('children', children + 1)
local connected_nodes = asrs.data[sys_id].nodes
asrs.data[sys_id].nodes = connected_nodes + 1
+ asrs.save()
else
local name = placer:get_player_name() or ''
minetest.chat_send_player(name, 'You must place this adjacent to a lift or controller node.')
@@ -227,5 +231,6 @@ minetest.register_node('asrs:lift', {
local sys_id = oldmetadata.fields.system_id
local connected_nodes = asrs.data[sys_id].nodes
asrs.data[sys_id].nodes = connected_nodes - 1
+ asrs.save()
end,
})
The cause? ↓
At one point, I had added a print statement to the asrs.save function to let me know when it was called and I noticed something; When I Ctrl-C the server, it doesn't run asrs.save 😱 I'm thinkin' this might be a Windows thing.


-----

Although I'm very comfortable in a *nix environment. I'm using Windows. I use WSL and Zsh to give me a better command line, but I'm running the Windows version of Minetest.

I used to be a software engineer. Some stuff happened and I can't really work any more. It's not like work, but I enjoyed troubleshooting this problem.

Thank you.

-- Vince

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Using Ctrl+C to kill the server will probably not call anything in minetest.register_on_shutdown(). Only calling the datasave there is my fault. I should have been doing it more frequently.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

I have added three new nodes, these allow you to connect the asrs system to pipes from pipeworks, techage, and techpack(technically tubelib). You can still connect directly to the main controller as well if you choose.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

Support has been added for Mineclonia and maybe mineclone, mineclone2 and mineclone5 depending on if they all use the same internal names for the items used in the craft recipes.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
TechnoWolfTV
Member
Posts: 72
Joined: Wed Jan 29, 2020 20:04
GitHub: TechnoWolfTV
In-game: TechnoWolfTV
Location: Wisconsin, USA

Re: [mod] Automated Storage & Retrieval System [asrs]

by TechnoWolfTV » Post

Great concept! I've discovered a possible bug. I made a new creative world and gave myself stacks of controllers, storage cells and lifts (99 each). I placed an asrs system and began randomly spreading what was left of the three stacks on various controller pages using a blend of left-click drag, right-click drag, shift-click drag, etc. At some point I clicked the sort button to bring them all to the first page and when I did, there were three stacks of 99 each.
Last edited by TechnoWolfTV on Tue Feb 06, 2024 11:41, edited 2 times in total.

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

The code that does the sorting is code that I've been using for years in several mods and I've never noticed any issues with it. I can do some testing and try to see if I can break anything.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

User avatar
TechnoWolfTV
Member
Posts: 72
Joined: Wed Jan 29, 2020 20:04
GitHub: TechnoWolfTV
In-game: TechnoWolfTV
Location: Wisconsin, USA

Re: [mod] Automated Storage & Retrieval System [asrs]

by TechnoWolfTV » Post

Don't do too much chasing on this. I've not been able to reproduce it after more testing and I'm starting to wonder. I rarely play in creative and it's usually to test something, so I'm not used to the fact that stacks do not deplete when nodes are placed from them in creative. 99 stays 99. You see where I'm going, but I'm reasonably sure I had trashed some of each stack before spreading stuff in the controller pages, which is why I thought it odd that the end result was 99x3. I could be wrong, and if so this obviously a non-issue.

User avatar
TechnoWolfTV
Member
Posts: 72
Joined: Wed Jan 29, 2020 20:04
GitHub: TechnoWolfTV
In-game: TechnoWolfTV
Location: Wisconsin, USA

Re: [mod] Automated Storage & Retrieval System [asrs]

by TechnoWolfTV » Post

Okay, so this time I really did find a bug that I can reproduce every time:
Add a few stacks of any item into the console, then search for that item. Remove one of the stacks from the search results into your inventory. 1/2 the stack in your inventory and put one of the halves back into the empty cell in the search results, then close search or exit the asrs formspec and poof! The half stack in asrs is now gone (deleted?). I've made an unlisted video example, here: https://youtu.be/xKlmElZ17WI

User avatar
Nathan.S
Member
Posts: 1182
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
Contact:

Re: [mod] Automated Storage & Retrieval System [asrs]

by Nathan.S » Post

That certainly doesn't look good. I'll take a look and see what's going on and get it fixed.
I record Luanti videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest