[Mod] Mana [1.3.3] [mana]

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

[Mod] Mana [1.3.3] [mana]

by Wuzzy » Post

This mod provides a simple API for mana. And some simple HUD elements. This mod does not provide any actual gameplay on its own.

Mana is intended to be a secondary player attribute. In mfany RPGs mana is used as a resource for magical items or spells. Each time you use one of those, this reduces your mana reserves until you hit 0 eventually, at which point you cannot use these magical items anymore; you have to recharge your mana level somehow then.
In Minetest, it could be used for all kinds of special items and tools and what else you may think of.
Mana could also be used as a lazy measure to limit the uses of special items without destroying them, so the items do not neccessarily have to be magical.
That's the basic idea behind mana.

By default, all players start with 0/200 mana, and will regenerate 1 mana each fifth of a second. Note that the regeneration rate is the same for all players and can only be changed globally.
The values can be changed on a per-player basis with an API, the mod also recognizes a few server settings.

Here is a screenshot showing a HUD bar for the mana, using the optional dependency on HUD bars mod:
Image

Current API features:
  • Add and subtract mana from a player
  • Set/get the current and maximum mana of a player
  • Set/get the amount of mana regeneration of a player
Also, this mod is configurable with server settings (minetest.conf):
  • mana_default_max: Initial maximum mana for new players (default: 200)
  • mana_default_regen: The initial amount of mana a new player will generate (default: 1)
  • mana_regen_timer: Time in seconds all (!) players will generate mana (default: 0.2)
And that's basically it for now. The functions make sure the mana will never go out of bound, so the current mana is not allowed to be smaller than 0 or larger than the player's maximum.
Also, the maximum must not be smaller than 0 as well.

Download: https://codeberg.org/Wuzzy/minetest_man ... /1.3.3.zip
Version: 1.3.3 (This mod uses semantic versioning, as of 2.0.0 of the standard)
Works in Minetest 5.0.0 or later
License of mana icon: CC-BY 3.0 by Buch.
License of everything else: MIT License
Project page: https://codeberg.org/Wuzzy/minetest_mana

Optional dependencies: No mandatory dependencies.

Mods using this mod (partial list):
Attachments
screenshot_1449056383.png
screenshot_1449056383.png (23.06 KiB) Viewed 3429 times
Last edited by Wuzzy on Wed Apr 12, 2023 12:25, edited 23 times in total.

User avatar
Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

Re: [Mod] Mana [0.1.0] [mana]

by Minetestforfun » Post

Wow, very good idea and work, i hope it will be used on many mods, thank you ! :)

TG-MyinaWD
Member
Posts: 356
Joined: Thu May 08, 2014 21:22
GitHub: Maddie-Myina
IRC: Maddie-Myina
In-game: .
Location: Far Eden

Re: [Mod] Mana [0.1.0] [mana]

by TG-MyinaWD » Post

Sounds cool. I hope I can find a great use for it in my mods. I might can make it need mana to craft something. if can export it from players and use in crafting.

I will look into can do. but looks great so far.
I'm a Transgender no shame about it.
I prefer to be considered as a "Girl/Lady/Miss/Madam/Female" for now on.

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: [Mod] Mana [0.1.0] [mana]

by Krock » Post

I hope there will be mods using Mana. It has potential for a new type of gameplay!

EDIT: I would like to see your mods on GitHub :)
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Release 0.2.0

by Wuzzy » Post

I just released version 0.2.0 of this mod!

I have added the API documentation, and it is surprisingly short. It really just boils down to setter and getter functions, and addition and subtraction.
I have tweaked the adder and subtractor functions a bit. Now you can decide whether you allow “excess” amount (over the maximum or below 0) or if you want to abort the whole operation if a limit would be exceeded.

I.e. if player X has 40/50 mana and you want to add 20, you can either call mana.add, in which call the addition will fail and no mana will be added, or you can call mana.add_up_to, in which case 10 mana will be added (capped at 50), plus the function reports how much excess mana you had (in this case 10, obviously).
It is similar for subtraction.
I hope this little tweak makes using the API a bit more flexible to use.

*Probably* there is not much else in the way for a 1.0.0 release already, if you have ideas for new functions, please let me know. I will probably add the one or other convenience function.
But I want to have at least one real world example before I release 1.0.0, to be sure everything works fine.

@Krock:
I will not put this on GitHub, but I will put this on repo.or.cz whenever I feel like it, but certainly at the release of 1.0.0.

In the meanwhile, the Zip archive also contains the .git folder and thus the entire Git repository. ;-)

I now use Git for most of my mods and upload them to repo.or.cz, but I don't use Git at all for very simple mods like Galaxy Skybox.

User avatar
TenPlus1
Member
Posts: 3715
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: [Mod] Mana [0.2.0] [mana]

by TenPlus1 » Post

Great concept... Killing mobs could drop mana items, or even using special weapons or staffs could use mana to operate... so much potantial...

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Version 0.3.0 released!

by Wuzzy » Post

Version 0.3.0 released!

This version has been made for compability with the HUD bars mod 0.3.0. It is currently only compatible with this version, unless you decide to not install and activate HUD bars.
That's all, bye!

Edit: Version 0.4.0 of the HUD bars mod has been released. Mana 0.3.0 is also compatible with 0.4.0 of the HUD bars mod now.

Edit: Same for 1.0.0.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Version 0.4.0 released!

by Wuzzy » Post

Version 0.4.0 is released!
This version works with major version 1 of the HUD bars mod. Versions 0.3.0 and 0.4.0 are probably OK, too, but not supported.

Changelog:
  • Mana now is regenerated by players
  • By default, new players start with 0/200 mana and will regenerate 1 mana each fifth of a second
  • The mod recognizes now three minetest.conf settings / server settings, for configuring regeneration rate, default regeneration amount for new players and max. mana for new players
  • New API functions for regeneration: mana.getregen and mana.setregen
Regeneration can be easily disabled by setting the regeneration amount to 0. I added the support for minetest.conf settings mainly for subgame developers and server operators. This way, you have to change not a single file within the mana mod, only your minetest.conf to configure this mod. :-)

See also the first post, it is a bit more detailed on that. The README.txt file is the most detailed info.

I also uploaded the Git repository here:
http://repo.or.cz/w/minetest_mana.git

I also have decided which direction this mod will go: I will stay with mana only, so the aim is now not a generic mod to add generic attributes, etc.

Edit: I have released the first mod using the Mana mod: Mirror of Returning

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Version 1.0.0 released!

by Wuzzy » Post

Version 1.0.0 is released today!

I consider the API finished and stable, it should now be safe to use by other mods.

Changelog:
  • All input values will first be rounded before they are used. This ensures the mana mod only stores integer numbers for mana, so you can't have 2.342 mana, etc.
  • Add brief “general recommendations” section into API.md
  • A bit of refactoring
The following mods are currently using this mod and are compatible with major version 1 of this mana mod: Have fun!

User avatar
philipbenr
Member
Posts: 1897
Joined: Fri Jun 14, 2013 01:56
GitHub: philipbenr
IRC: philipbenr
In-game: robinspi
Location: United States

Re: [Mod] Mana [1.0.0] [mana]

by philipbenr » Post

Looks good Wuzzy.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Mana [1.0.1] [mana]

by Wuzzy » Post

Quick bugfix release 1.0.1:

The mana regeneration did not work well on slow servers, it was far slower than it should be. Now the mana regeneration is more stable so that it even works properly on slow servers, but the granularity of mana updates is still increased on slow servers.
If you have a slow server, consider increasing the mana tick (and, if desired, scale the default mana regeneration amount inversely proportional).

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

1.0.2

by Wuzzy » Post

New version 1.0.2 released.

This fixes the following bugs found by Jordach (thanks!):
  • The server crashed when a player left on a multiplayer server and HUD Bars mod was active, too
  • The player's mana values were reset to the default values when a player rejoined on a server

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: [Mod] Mana [1.0.2] [mana]

by Don » Post

Just a thought. What about a mana container or bottle that can store mana. That way people can go collect mana and store it. Then if their mana is low they can refill it similar to eating.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

User avatar
Ben
Member
Posts: 160
Joined: Tue Mar 31, 2015 20:09

Re: [Mod] Mana [1.0.2] [mana]

by Ben » Post

Nice mod! My first thought was "hey, what if mana regeneration only worked in sunlight?" This would add some importance to the time of day, and make spelunking more of a challenge.

Since the regen value is settable by player, one could easily write another mod that takes care of the regeneration rate. In fact, I think I'll try my hand at it myself ;-)

Two questions about some design decisions, though:

First, all values are stored and calculated as integers. What prompted this? I think you lose a lot of tunability and precision that way. You could always round the values just before output (HUD bars / text), if that was the reason.

Second, I see that negative regen values are not allowed. One idea would be to have biomes / blocks / mobs with a "mana sapping" effect, by setting a negative value.

User avatar
Minetestforfun
Member
Posts: 940
Joined: Tue Aug 05, 2014 14:09
GitHub: MinetestForFun
IRC: MinetestForFun
In-game: MinetestForFun
Location: On earth
Contact:

Re: [Mod] Mana [1.0.2] [mana]

by Minetestforfun » Post

Hi,

Because of your versionning system based on repo.or.cz, I post this here.

It's a modified and "improved" version of your mod, contains :
- Some crashfixs
- Add hud compatibility / support (with many different textures for potions, you can see alternative textures and xcf with calcs potions in the second folder)
- be carful, in our modified version, every 10 seconds the mana is increased by 10
- be carful, we don't have yet merged your latest improve wich save the mana if deconnection/reconnection
- Add a sound for the returnmirror teleportation (but we need to improve it...)
- One potion = 20 mana, they are 10 potions, so 10*20 = 200, and avery ten second, one half potion is filled

That's all, i think, Great mod Wuzzy, i hope it will help you :)

PS : license WTFPL for all
Attachments
Mana-MinetestForFun.7z
Mana mod modified for MinetestForFun
(32.19 KiB) Downloaded 147 times

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Mana [1.0.2] [mana]

by Wuzzy » Post

@Minetestforfun: First of all, my versioning is not based on repo.or.cz. My versioning system is Semantig Versioning 2.0.0, documented at http://www.semver.org.
Also, if you want to fork this mod, remember that the versioning of the new mod is now independent from the other mod. You could continue to use Semantic Versioning in that fork, but you could also choose to abandon Semantic Versioning for another versioning system for whatever reason.

You already changed a lot.

I do not want to apply these changes into this mod all at once. If you want to contribute, fork my repository and use Git and publish the repository somewhere (it does not matter much where). Alternatively, you could send me a patch file (if you know what this is).
I want to have a clean Git history. I don't want to have a super-commit like “Some random changes from Minetestforfun, I don't know exactly what has changes”. ;-)
My rule of thumb is: One change per commit.

Also, I will not add mana potions into this mod because I want to keep this mostly an API mod. However, I think it would be perfectly possible to implement mana potions in a seperate mod. I am to lazy to do it myselves, so you are on your own.

As for the crash fixes: Please tell me of which crashes you are talking about (in other words: report the bug). If you have a fix, that's great, but please post one patch/commit per bugfix.

I don't know what you mean with “sound for returnmirror teleportation”. It already has a sound, so what's the point? This is also off-topic, why don't you post in the returnmirror thread?

User avatar
Ben
Member
Posts: 160
Joined: Tue Mar 31, 2015 20:09

Re: [Mod] Mana [1.0.2] [mana]

by Ben » Post

Ben wrote:Since the regen value is settable by player, one could easily write another mod that takes care of the regeneration rate. In fact, I think I'll try my hand at it myself ;-)
And I just did: Solar Mana. I wouldn't count it as a mod that "uses the mana mod", though :-P

TeTpaAka
Member
Posts: 141
Joined: Sat Dec 28, 2013 21:54

Re: [Mod] Mana [1.0.2] [mana]

by TeTpaAka » Post

I just noticed that your fall back functions don't work properly. Instead of updating the displayed text, you update "number", which is the colour for a text HUD. So, instead of slowly increasing numbers, the colour of the HUD string changes.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Mana [1.1.0] [mana]

by Wuzzy » Post

I have released Mana version 1.1.0!

Changelog:
  • Regeneration can be negative now. This means, players lose mana over time.
  • Regeneration can also be a floating-point number. A number between 0 and 1 simply means that it takes longer than 1 mana tick (default: 0.2 s) to regenerate 1 mana. For instance, if mana regeneration is 0.5, it takes 2 mana ticks to regenerate 1 mana. (Note: The player's mana values are still strictly whole numbers, it is only the regeneration which has changed).
  • Update for the new HUD bars version 1.2.0 or later: Statbar background image added. This is only interesting if you use HUD bars with the “modern statbars” style. Otherwise, this has no effect.
  • I finally fixed the fallback text bug reported by TeTpaAka.

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Version 1.2.0

by Wuzzy » Post

I have release Mana version 1.2.0. This is a rather small update only.

Changelog:
  • Add intllib support
  • Add German translation
  • Update/fix readme file
  • Clean up / refactor code (undeclared globals, etc.)

User avatar
benedict424
Member
Posts: 29
Joined: Thu Oct 02, 2014 06:24
IRC: ostec
In-game: ostec

Re: [Mod] Mana [1.2.0] [mana]

by benedict424 » Post

I am going to use your API for an alchemy mod.
Terra, Aqua, Ignus, Air, Ather, and Incognitus.

User avatar
scottwolff
Member
Posts: 129
Joined: Sat Apr 30, 2016 06:15
In-game: scottwolff or some variant of iasiney
Location: Central Illinois

Re: [Mod] Mana [1.2.0] [mana]

by scottwolff » Post

Yes. Good mod. Used it a few times in the past.
I just wish it'd work with other mods. Magic during 4.13 seemed like such an odd implementation. Most folks now just have an rpg subgame or something.

Chem871
Member
Posts: 999
Joined: Sat Aug 19, 2017 21:49
GitHub: Chemguy99
In-game: Chem Nyx
Location: My Basement's Attic

Re: [Mod] Mana [1.2.0] [mana]

by Chem871 » Post

Minerdream uses this mod, scott.
What is SCP-055?

User avatar
SonosFuer
Member
Posts: 104
Joined: Sun Jul 09, 2017 00:32
GitHub: apachano
IRC: SonosFuer
In-game: SonosFuer

Re: [Mod] Mana [1.2.0] [mana]

by SonosFuer » Post

I am running into an issue with your rounding function. When I use mana.subtract and it rounds I get this in response.
Image
If I comment this line out it runs fine and subtracts the amount of mana when I make the call.

Code: Select all

value = mana.round(value)
Working on a content database for minetest mods, servers, and etc Check it out and give me feedback at viewtopic.php?f=14&t=18137

User avatar
Wuzzy
Member
Posts: 4786
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Mana [1.2.0] [mana]

by Wuzzy » Post

Can I get the full Lua backtrace, please?

Especially I need the code which calls mana.subtract.

Post Reply

Who is online

Users browsing this forum: No registered users and 20 guests