[Mod] Tubelib [tubelib]

User avatar
joe7575
Member
 
Posts: 253
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

[Mod] Tubelib [tubelib]

by joe7575 » Tue Oct 03, 2017 11:41

This mod is now part of the Modpack TechPack


Minetest Tube Mod for item exchange via lumber tubes and wireless message communication between nodes.

The focus for this Mod are:

* minimized server load and thus minimized server lags
* simple and intuitive usage for players
* simple API for programmers

Image

The mod provides:

* lumber tubes to connect 2 blocks
* a Pusher block to pull/push items through tubes
* a Distributor block with 4 output channels to sort incoming items
* a Blackhole block which lets all items disappear (example/template for programmers)
* a Button/switch block to send "switch on/off" messages
* a Lamp block as receiving example for message communication
* support for default blocks: furnace and chests

Code: LGPLv2.1+, textures: CC BY-SA 3.0
Dependencies: default
Last edited by joe7575 on Sun Mar 11, 2018 17:26, edited 7 times in total.
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance.
 

User avatar
azekill_DIABLO
Member
 
Posts: 7461
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [Mod] Minetest-Tubelib [tubelib]

by azekill_DIABLO » Tue Oct 03, 2017 16:46

The ancestor of mesecons and pipeworks? it's really sent from your commodore64 then :D

EDIT: seems simpler to use than them.
Last edited by azekill_DIABLO on Tue Oct 03, 2017 17:08, edited 1 time in total.
 

Chem871
Member
 
Posts: 871
Joined: Sat Aug 19, 2017 21:49
Location: SCP-2935
GitHub: Chemguy99
In-game: Nyx Serris

Re: [Mod] Minetest-Tubelib [tubelib]

by Chem871 » Tue Oct 03, 2017 16:53

Looks to be a promising alternative to pipeworks and technic
What is SCP-055 again? I forgot.
 

User avatar
cx384
Member
 
Posts: 492
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: [Mod] Minetest-Tubelib [tubelib]

by cx384 » Tue Oct 03, 2017 17:11

Pipeworks alternative, good job! ( I don't like the textures :/ )
Can your read this?
 

Chem871
Member
 
Posts: 871
Joined: Sat Aug 19, 2017 21:49
Location: SCP-2935
GitHub: Chemguy99
In-game: Nyx Serris
 

User avatar
azekill_DIABLO
Member
 
Posts: 7461
Joined: Wed Oct 29, 2014 20:05
Location: OMICRON
GitHub: azekillDIABLO
In-game: azekill_DIABLO

Re: [Mod] Minetest-Tubelib [tubelib]

by azekill_DIABLO » Tue Oct 03, 2017 19:09

cx384 wrote: I don't like the textures :/

well... they would fit well with HDX 32x32, i agree. 16 pixel textures with the default palette could be nice too. Unfortunatly i can't do them now.
 

User avatar
joe7575
Member
 
Posts: 253
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: [Mod] Minetest-Tubelib [tubelib]

by joe7575 » Tue Oct 03, 2017 19:39

The "retro rustic design" should help do distinguish the mod from others...
and it is unique, I guess.
But of course, it could be changed by means of any texture mod.

But is is not really the ancestor, because the message communication is wireless :D
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance.
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] Minetest-Tubelib [tubelib]

by Byakuren » Tue Oct 03, 2017 20:52

Can it transport through unloaded blocks like pipeworks can?
Every time a mod API is left undocumented, a koala dies.
 

User avatar
joe7575
Member
 
Posts: 253
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: [Mod] Minetest-Tubelib [tubelib]

by joe7575 » Wed Oct 04, 2017 08:02

Byakuren wrote:Can it transport through unloaded blocks like pipeworks can?


Theoretically YES, but it is unlikely that this happens, because the maximum tube length is currently limited to about 50 blocks. It was no objective to allow the construction of huge plants.
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance.
 

FaceDeer
Member
 
Posts: 267
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [Mod] Minetest-Tubelib [tubelib]

by FaceDeer » Wed Oct 04, 2017 17:14

Could you provide an example for how to enable a node with an inventory to be tubelib-compatible? I've created a lot of mods that provide inventory-bearing nodes and I'm willing to add compatibility to any of these sorts of mods that come along but a cheat sheet would be handy.
 

User avatar
joe7575
Member
 
Posts: 253
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: [Mod] Minetest-Tubelib [tubelib]

by joe7575 » Wed Oct 04, 2017 17:41

FaceDeer wrote:Could you provide an example for how to enable a node with an inventory to be tubelib-compatible? I've created a lot of mods that provide inventory-bearing nodes and I'm willing to add compatibility to any of these sorts of mods that come along but a cheat sheet would be handy. :)


Yes, of course. This is the code (from legacy_nodes.lua) to make a chest Tubelib compatible:

Code: Select all
tubelib.register_node("default:chest", {"default:chest_open"}, {
   on_pull_item = function(pos, side)
      local meta = minetest.get_meta(pos)
      return tubelib.get_item(meta, "main")
   end,
   on_push_item = function(pos, side, item)
      local meta = minetest.get_meta(pos)
      return tubelib.put_item(meta, "main", item)
   end,
   on_unpull_item = function(pos, side, item)
      local meta = minetest.get_meta(pos)
      return tubelib.put_item(meta, "main", item)
   end,
})   


You have to adapt the item name ("default:chest", ...) and the inventory list name ("main") to your needs and it should fly...
You will find the prototypes for this functions with parameter description in the file "command.lua".
If you need more help, please let me know.

PS: I removed the "on_recv_message" part, because this is not needed for pure item exchange via tubes.
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance.
 

FaceDeer
Member
 
Posts: 267
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [Mod] Minetest-Tubelib [tubelib]

by FaceDeer » Wed Oct 04, 2017 18:50

Thanks, looks straightforward. Might want to put this example into the api document, I'm sure this will be something that other modders will want too. I took a peek at command.lua and I take it that having one of those methods return false is how one "rejects" the attempt? Many of my nodes' inventories are picky about what gets put in them (eg, furnaces that only allow burnables to be put in the fuel slot or crafting tables that reject raw materials they don't have recipes to use).

Also, a suggestion; it would be good if those functions also had a "player" parameter to allow for node protection to determine whether a request comes from an authorized player. When I reworked the [hopper] mod a while back to give it a generalized API I made hopper nodes remember the identity of the player that placed them and passed a fake player object with that name as a parameter to the "allow X inventory operation" methods (see the get_placer function), you could perhaps do something similar. That way you could hook up a tube to a locked chest that you owned but not to a chest that someone else owned, and the tube would continue functioning with the correct restrictions after you'd logged off.
 

User avatar
ManElevation
Member
 
Posts: 895
Joined: Tue Aug 02, 2016 22:04
Location: Madrid,Spain
GitHub: ManElevation
IRC: ManElevation
In-game: ManElevation

Re: [Mod] Minetest-Tubelib [tubelib]

by ManElevation » Wed Oct 04, 2017 19:02

sounds like its a mix of basic_machines basic_robots and technic
+1
My Public Mods! Discord: Rottweiler Games#3368
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] Minetest-Tubelib [tubelib]

by Byakuren » Wed Oct 04, 2017 22:26

Don't take a player, take a player name so you don't need to hack about with fake players. Or at least take both.
Every time a mod API is left undocumented, a koala dies.
 

FaceDeer
Member
 
Posts: 267
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [Mod] Minetest-Tubelib [tubelib]

by FaceDeer » Wed Oct 04, 2017 23:35

You have to hack about with fake players if you're going to call allow_metadata_inventory_put, allow_metadata_inventory_take, or allow_metadata_inventory_move - those require player objects rather than player names. It's just a question of where you put the hackery, I suppose.
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] Minetest-Tubelib [tubelib]

by Byakuren » Thu Oct 05, 2017 03:03

Then define a different function for the tube interface. allow_metadata* is meant specifically to handle formspec moves by players.
Every time a mod API is left undocumented, a koala dies.
 

FaceDeer
Member
 
Posts: 267
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [Mod] Minetest-Tubelib [tubelib]

by FaceDeer » Thu Oct 05, 2017 05:08

That would require every mod that defines nodes with inventories to add a second duplicate player-permissions check to their node defs if they wanted to add pipeworks compatibility. It's rare enough that modders remember to add player-permissions checks to the existing allow_metadata* methods.

In an ideal world I agree, it's not correct to be creating fake player objects. It'd be nicer if you could get legit player objects for players who aren't logged in. But this is the world we are in now and it's not really all that big a hack in the grand scheme of things. Creating fake player objects works fine. If Tubelib passes a player name string rather than a fake player object that's fine, I'll make a fake player object myself when I do the allow_metadata* checks in my mods. I just think it's an unnecessary extra step to place on every modder who wants to do this.
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] Minetest-Tubelib [tubelib]

by Byakuren » Thu Oct 05, 2017 06:41

You shouldn't be able to get player objects for offline players because almost all the ObjectRef methods mean nothing if the player isn't really there. The only method that is really useful for offline players is get_player_name(), so you might as well just use the player name alone.
Every time a mod API is left undocumented, a koala dies.
 

Byakuren
Member
 
Posts: 816
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri
In-game: Raymoo + Clownpiece

Re: [Mod] Minetest-Tubelib [tubelib]

by Byakuren » Thu Oct 05, 2017 06:42

Also why not reuse the pipeworks interface?
Every time a mod API is left undocumented, a koala dies.
 

User avatar
joe7575
Member
 
Posts: 253
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: [Mod] Minetest-Tubelib [tubelib]

by joe7575 » Thu Oct 05, 2017 14:55

Perhaps I have a too simple picture in my mind, but why show I check the player rights for each item going through tubes?
If an item is moved from block A to block B my means of a tube, the placer of the tubes has to have the necessary rights to build the tube. This should always be true in protected areas.
But yes, if we have a locked chest in an unprotected area, it is currently possible to empty this chest by means of the tubelib.
But for this case, the placing of the tube/pusher should be restricted, which has to be done only once and not frequently like the item transfer, or?

Would it not be easier, if a tube/pusher is placed nearby a locked chest or any other locked node, to check the player name against the owner of the chest?
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance.
 

Chem871
Member
 
Posts: 871
Joined: Sat Aug 19, 2017 21:49
Location: SCP-2935
GitHub: Chemguy99
In-game: Nyx Serris

Re: [Mod] Minetest-Tubelib [tubelib]

by Chem871 » Thu Oct 05, 2017 15:29

Checking the owners of the pusher and the locked chest(s) together makes perfect sense.
What is SCP-055 again? I forgot.
 

FaceDeer
Member
 
Posts: 267
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [Mod] Minetest-Tubelib [tubelib]

by FaceDeer » Thu Oct 05, 2017 15:40

joe7575 wrote:Would it not be easier, if a tube/pusher is placed nearby a locked chest or any other locked node, to check the player name against the owner of the chest?


The idea is that by passing the player object (or player name, they can make their own player object from that if need be) as a parameter to the on_pull_item functions you give the target node the information it needs to figure out for itself whether it should be "protected" or not via its existing allow_metadata_inventory* methods. If you try to do the locked chest's work for it by using special-case code that specifically checks a default:locked_chest's owner then another mod that wants to add items with protected inventories will have to edit tubelib to add that protection check rather than adding it within their own code.

This allows the modder who's adding tubelib support to make it work right out of the box without having to touch tubelib's code. And it lets them do fancy stuff, like maybe they've created a chest that only allows people with names beginning with a certain letter to access it, or its locked state changes with the time of day, or whatever.
 

Downad
Member
 
Posts: 11
Joined: Tue Oct 03, 2017 08:54
Location: Germany
GitHub: downad
In-game: downad

Re: [Mod] Minetest-Tubelib [tubelib]

by Downad » Thu Oct 05, 2017 20:22

Hallo Joe7575,
i tried this and i am very happy.
but i can't fill an furnace with ore and coal
if i try to fill it, the ore or the coal is set in the smelt field.
the coal is not set in the fuel field

can you help me?
gruß
downad
 

Chem871
Member
 
Posts: 871
Joined: Sat Aug 19, 2017 21:49
Location: SCP-2935
GitHub: Chemguy99
In-game: Nyx Serris

Re: [Mod] Minetest-Tubelib [tubelib]

by Chem871 » Thu Oct 05, 2017 20:57

I think the tube carrying coal needs to be inserted into the bottom of the furnace.
What is SCP-055 again? I forgot.
 

User avatar
joe7575
Member
 
Posts: 253
Joined: Mon Apr 24, 2017 20:38
Location: Germany, in the deep south
GitHub: joe7575
In-game: JoSto

Re: [Mod] Minetest-Tubelib [tubelib]

by joe7575 » Thu Oct 05, 2017 21:34

The furnace adaptation has a table with valid fuels, so that it is independent from which side you push the items in. The "default:coal_lump" was missing.
But it should work now.
Sent from my Commodore 64. My Mods: TechPack, Hyperloop, Tower Crane, Lumberjack, Iron Age, Entrance.
 

Next

Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 5 guests