Page 1 of 1

[mod] Air tanks [airtanks]

PostPosted: Sun Mar 26, 2017 08:08
by FaceDeer
A simple mod for extending one's underwater excursion time.

Image

Air tanks are crafted from copper, steel, or bronze ingots and are wielded like tools. A compressor is crafted from steel, mese shard, and wood.

Place a compressor in world and click on it with an empty air tank to fill it. A compressor needs to have air adjacent to it for it to function. Compressors can also recharge partly-used tanks.

When running low on breath use a filled air tank to recharge your breath bar. One use will replenish 5 steps of breath (out of 10). By default a steel air tank will hold 30 uses, a bronze one holds 20, and a copper one holds 10 - these settings can be changed in the mod's section under Advanced Settings. Once a tank runs out of uses it turns into an empty tank, which can be recharged again with a compressor.

To automatically draw air from air tanks, craft a breathing tube and put it in your quick-use inventory row. When your breath bar drops below 5 steps it will automatically attempt to use an air tank from your quick-use inventory row to replenish it.

This mod supports the doc extension.

Links

Re: [mod] Air tanks [airtanks]

PostPosted: Sun Mar 26, 2017 11:41
by klunk
Hello
There is a problem with "metal_sound" wich can't be found because it is not in default, at line 124 of init.lua, maybe because I'm running MT 0.4.14.
Once this line comented, this is a great mod. I really like the sound of compressed air from the bottle !

Re: [mod] Air tanks [airtanks]

PostPosted: Sun Mar 26, 2017 14:17
by azekill_DIABLO
great! useful for under water expeditions!

Re: [mod] Air tanks [airtanks]

PostPosted: Sun Mar 26, 2017 15:44
by FaceDeer
klunk wrote:Hello
There is a problem with "metal_sound" wich can't be found because it is not in default, at line 124 of init.lua, maybe because I'm running MT 0.4.14.


Yeah, the metal sounds were added to default in 0.4.15. I'll add a fallback so it won't crash on older versions.

Re: [mod] Air tanks [airtanks]

PostPosted: Mon Mar 27, 2017 14:38
by texmex
Another high quality mod from FaceDeer! As this developer somehow is able to read my mind of what feature is needed next time and time again, I'll add this to my server asap.

I have a feature question right off the bat: Could an optional feature be made so that new breaths of air is supplied to the player automatically as long as the tank sits in the hotbar? As I understand the description the player has to wield the item to get some air, currently. Hotbar check routine is available from the orienteering mod.

Re: [mod] Air tanks [airtanks]

PostPosted: Mon Mar 27, 2017 15:02
by azekill_DIABLO
yeah but should need to craft something like a breating tub or something like a pipe.

Re: [mod] Air tanks [airtanks]

PostPosted: Mon Mar 27, 2017 15:16
by FaceDeer
Thanks. This mod was actually something I came up with last-minute when I went to post dfcaverns, since there are water-flooded caves in that mod and I wasn't able to find any good scuba mods with a cursory search. Figured this would be handy for exploring them. :)

Good ideas for new features, I will look into implementing them (both auto-breathing and requiring an extra accessory for auto-breathing). The tricky bit is not so much the checking of whether an item's in the hotbar, it's knowing when the player is out of breath. Just did some poking around in the code and it looks like there's an undocumented API called register_playerevent that sends a "breath_changed" event for players to a registered event handler, I think that might be the way to do it. It's what the built-in statbar code uses for updating the breath statbar so it's probably a stable part of the API.

Re: [mod] Air tanks [airtanks]

PostPosted: Mon Mar 27, 2017 20:21
by D00Med
Nice idea!
For some reason I thought this was going to be like the 'air sword'

Re: [mod] Air tanks [airtanks]

PostPosted: Mon Mar 27, 2017 20:58
by FaceDeer
I've updated the mod with a breathing tube. If the breathing tube is in your inventory quick-use slots, then when your breath bar goes below 5 you will automatically take a breath from any non-empty air tank that is also in your inventory quick-use slot. If there are no air tanks to get air from it'll generate a gasping sound to let the player know he's close to drowning and should either surface or swap fresh tanks into his quick-use slots.

Let me know what you think of the balance. The crafting recipe for the breathing tube is just something I threw together without much thought. In testing it took me quite a while to drain a steel air tank so if you've got 7 of them in your quick-use slots that could take a very long time indeed, so maybe I should reduce the default number of uses a bit.

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 01:59
by dawgdoc
FaceDeer wrote:... so maybe I should reduce the default number of uses a bit.


You do that and all of the characters will be like I was when I first learned to scuba dive.
I had an instructor call me and "Air Sucking Dog" ;-D

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 08:27
by texmex
dawgdoc wrote:You do that and all of the characters will be like I was when I first learned to scuba dive.
I had an instructor call me and "Air Sucking Dog" ;-D

Cash fan perhaps? ;)

FaceDeer wrote:I've updated the mod with a breathing tube. If the breathing tube is in your inventory quick-use slots, then when your breath bar goes below 5 you will automatically take a breath from any non-empty air tank that is also in your inventory quick-use slot. If there are no air tanks to get air from it'll generate a gasping sound to let the player know he's close to drowning and should either surface or swap fresh tanks into his quick-use slots.

Great! The only objection i have is that now players have to have one more item in the already crowded hotbar, but that could also be intentional (that it should be "expensive" to use"). In another case I imagine a craft recipe with some sticks and the tank in order to make the new item "tank with tube", or similar.

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 09:03
by dawgdoc
texmex wrote:
dawgdoc wrote:You do that and all of the characters will be like I was when I first learned to scuba dive.
I had an instructor call me and "Air Sucking Dog" ;-D

Cash fan perhaps? ;)

I would have said yes, but then I realized I wasn't familiar with that song.

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 13:43
by FaceDeer
texmex wrote:Great! The only objection i have is that now players have to have one more item in the already crowded hotbar, but that could also be intentional (that it should be "expensive" to use"). In another case I imagine a craft recipe with some sticks and the tank in order to make the new item "tank with tube", or similar.


Exactly, it's a tradeoff. I had originally considered some kind of special inventory slot system like the armor mod has, but this way is much simpler (both for player and for the poor overwhelmed coder :) and makes extended underwater adventures something you need to plan for.

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 14:47
by texmex
FaceDeer wrote:Exactly, it's a tradeoff. I had originally considered some kind of special inventory slot system like the armor mod has, but this way is much simpler (both for player and for the poor overwhelmed coder :) and makes extended underwater adventures something you need to plan for.

Sounds good. Luckily my hotbar is 16 slots big. :)

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 17:22
by texmex
I tried it out, it works well. I love the audible refill sound. A few ideas more, of course:

  • A visible wear level on the tank would be good, just like any other tool has. However, I see you put a badge on empty ones, perhaps you want it that way, that it's not so precise how much air is left.
  • The instant refill from the compressor feels a bit to quick and spammy. It would be neat if you had to mount the tank on the compressor and let it sit for 10 seconds or so before it was filled back up.
  • All tanks have the same color, shouldn't they differ?
  • Bronze level tank have (config.steel_uses + config.copper_uses)/2 number of uses, but bronze tools are better than steel tools and require more material. I propose (config.steel_uses + config.copper_uses) number of uses. :)

Thanks for this mod!

Re: [mod] Air tanks [airtanks]

PostPosted: Tue Mar 28, 2017 19:44
by FaceDeer
Okay, I got home and tested airtanks with a 0.4.15 release build of Minetest, and sure enough the [multiply: modifier was the culprit. As a temporary measure until 0.4.16 comes out I've switched over to a colorize-and-mask approach that looks a bit more garish but that at least clearly distinguishes the metal types.

I was able to see the wear-down bar, so that's not a result of a version incompatibility. TexMex, perhaps you were in creative mode when you were using the air tanks? I decided to follow the pattern of other tools and have them not wear out in creative mode. Perhaps these air tanks should behave differently, though, they're not exactly "tools" in the usual sense. I'll make them wear out in creative mode and add a configuration option to disable that if desired.

Anyway, the other points.

  • Bronze. Ugh, I hate the metallurgy of the default minetest-game. I'd forgotten that the standard recipe is "1 copper + 1 steel = 1 bronze." I'll adjust the number of uses, though I must protest at how "gamey" this feels and some day when I do further work to bring further Dwarf Fortress elements into Minetest I'm going to fix that. :)
  • Adding a waiting period to fill tanks. I have nothing against this, but I think I'll probably put it off for the time being. I'm mainly focused on polishing dfcaverns right now, and I unexpectedly committed to upgrading hopper with new functionality, so it seems like a low-reward-high-cost thing to do right now. But I'll keep it in mind, maybe add an interface like my anvil mod when I've got spare time and no bigger ideas to fill it.