[Mod] Sprint w. hudbars, hunger, monoids support [hbsprint]

turducken
Member
Posts: 23
Joined: Fri Feb 02, 2018 01:43

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by turducken » Post

texmex wrote:Good spotting, turducken. This relates to the the walkable check, correct. It was mainly implemented with water in mind, so that you can't sprint run in or on the water surface which you can do with the other sprint mods available. I suppose I could check for walkable or air nodes instead of just walkables.
decrease the stamina by dtime in global step, but is dtime variable, as that would throw a wrench into reducing hunger in predictable ways
I agree, stamina should be independent of dtime, with its own timer. I'll se if I can get around to it.
That was actually another thought of mine reading the code about swimming. While I don't think it should be a Jesus mod of walking on water, I think some kind of "boost" while in water would be acceptable. For example, in my worlds I'm frequently attacked by sharks. One should be able to go from a leisurely swim to SHTF mode to get to shore.

I'm obviously not sure how that would be checked as I'm new to the minetest mod api. I assume the other mods check the ground you're on, and somehow you "jump" up a node so that you're not "on" water anymore. Perhaps checking two nodes down? Perhaps a "was in water now in air" check?

Another thought I had, somewhat related, is jumping using up stamina and hunger. I know that hbhunger already takes into account placing and removing nodes, but as far as I can tell from the code it doesn't account for walking or other movement (I suppose this is best brought up in that forum.) Perhaps hbsprint should set a "stamina" or "hunger" factor as a multiplier in monoids. Regular walking, jumping uses normal hunger, while hurried running and jumping uses up more. A slow-down effect while eating my also help.

Again, how these interrelate with hbhunger I'm not sure, but they obviously need to interact (possibly though that monoids api.)

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by texmex » Post

turducken wrote:Perhaps checking two nodes down? Perhaps a "was in water now in air" check?
You're right, I should be able to check whether the player is attempting "Jesus walk" or if he's mortal "human being swimming".
turducken wrote:Another thought I had, somewhat related, is jumping using up stamina and hunger. I know that hbhunger already takes into account placing and removing nodes, but as far as I can tell from the code it doesn't account for walking or other movement (I suppose this is best brought up in that forum.) Perhaps hbsprint should set a "stamina" or "hunger" factor as a multiplier in monoids. Regular walking, jumping uses normal hunger, while hurried running and jumping uses up more. A slow-down effect while eating my also help.

Again, how these interrelate with hbhunger I'm not sure, but they obviously need to interact (possibly though that monoids api.)
That's a good idea: a hunger mod using monoids. Eating would immediately (or slowly) increment hunger in absolute numbers while sprinting and other physical activities would increase or decrease the multiplier. I want to write that mod!

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

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by Byakuren » Post

I think the values of such a monoid should add together rather than multiply, because different activities should exhaust you independently. It could still be a multiplier, but maybe the values would be the portion above 1. For example, 0.2 would mean 1.2 times hunger rate, and if you had another mod add a 0.4 multiplier, you would get a 1 + 0.2 + 0.4 = 1.6 multiplier.
Every time a mod API is left undocumented, a koala dies.

turducken
Member
Posts: 23
Joined: Fri Feb 02, 2018 01:43

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by turducken » Post

Byakuren wrote:I think the values of such a monoid should add together rather than multiply, because different activities should exhaust you independently. It could still be a multiplier, but maybe the values would be the portion above 1. For example, 0.2 would mean 1.2 times hunger rate, and if you had another mod add a 0.4 multiplier, you would get a 1 + 0.2 + 0.4 = 1.6 multiplier.
Perhaps. I was thinking in terms of "this potion makes you 20% faster", eg 1.2. Then you have armor that makes you 2% faster, or 1.02. 1.2*1.02=1.224.

I'm not sure the correct version. I suppose it depends on if you want to change the base rate only (additive) or whatever the current value is (multiplicative.) Perhaps there should be a setting?!

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

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by Byakuren » Post

turducken wrote:
Byakuren wrote:I think the values of such a monoid should add together rather than multiply, because different activities should exhaust you independently. It could still be a multiplier, but maybe the values would be the portion above 1. For example, 0.2 would mean 1.2 times hunger rate, and if you had another mod add a 0.4 multiplier, you would get a 1 + 0.2 + 0.4 = 1.6 multiplier.
Perhaps. I was thinking in terms of "this potion makes you 20% faster", eg 1.2. Then you have armor that makes you 2% faster, or 1.02. 1.2*1.02=1.224.

I'm not sure the correct version. I suppose it depends on if you want to change the base rate only (additive) or whatever the current value is (multiplicative.) Perhaps there should be a setting?!
Sorry, I thought that you meant a monoid for how quickly saturation drains. For speed, I think player_monoids comes with a multiplicative speed monoid. In general though it's possible to combine approaches: instead of having a monoid directly change something, make it add a value to another monoid. For example, an additive speed monoid that uses its total multiplier to apply a value in the multiplicative speed monoid, which in turn actually applies the speed to a player.
Every time a mod API is left undocumented, a koala dies.

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by texmex » Post

Yes, there's talk of monodial hunger in addition to stamina. But hunger/saturation is another mod completely and
is OT except in the sense that hbSprint could have a soft dependancy on a future monodial hunger mod.

User avatar
LMD
Member
Posts: 1396
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by LMD » Post

Created an issue : https://github.com/minetest-mods/hbsprint/issues/12
(more of an PR)
My stuff: Projects - Mods - Website

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by texmex » Post

Though I appreciate the contribution, the solution has already been found. Use player_monoids.

User avatar
LMD
Member
Posts: 1396
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by LMD » Post

Yeah, but then you should say so explicitly. Else people wonder why their jump potion stopped working ;D
Plus, thru my solution u are independent of that mod.
My stuff: Projects - Mods - Website

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by texmex » Post

I think I express clear support for monoids, look at the title for instance. I can’t take responsibility for mods that isn’t written with any interoperatibility in mind.

That said, here’s a potions mod that does play nice: https://github.com/tacotexmex/herbs

User avatar
LMD
Member
Posts: 1396
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by LMD » Post

Making something pretty similar ATM :)
My stuff: Projects - Mods - Website

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by texmex » Post

LMD wrote:Making something pretty similar ATM :)
For the love of mese, WHY would you want to spend lifetime on that? There’s already two different solutions available.

User avatar
LMD
Member
Posts: 1396
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by LMD » Post

Umm, well, mine adds statbars 4 how long the player still posesses it. Also I have my custom API, so I can easily register a - physics effect potion (antigravity, jump etc) - normal potion (effect, delete effect function) using a color. It is for our new magic CTF. Potions have tiers (yellow stripes on image) which show potion strength, and levels (grey stripes) = duration. It will be nice, I hope :)
My stuff: Projects - Mods - Website

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by texmex » Post

LMD wrote:Umm, well, mine adds statbars 4 how long the player still posesses it. Also I have my custom API, so I can easily register a - physics effect potion (antigravity, jump etc) - normal potion (effect, delete effect function) using a color. It is for our new magic CTF. Potions have tiers (yellow stripes on image) which show potion strength, and levels (grey stripes) = duration. It will be nice, I hope :)
That sounds nice, though more of an alternative to playereffects, not this.

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

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by Byakuren » Post

LMD wrote:Umm, well, mine adds statbars 4 how long the player still posesses it. Also I have my custom API, so I can easily register a - physics effect potion (antigravity, jump etc) - normal potion (effect, delete effect function) using a color. It is for our new magic CTF. Potions have tiers (yellow stripes on image) which show potion strength, and levels (grey stripes) = duration. It will be nice, I hope :)
You could keep your custom effect code, but use monoids to actually apply the final physics effects to players. Then you can have your more complex system and still have compatibility with player_monoids-compatible mods.
Every time a mod API is left undocumented, a koala dies.

User avatar
LMD
Member
Posts: 1396
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by LMD » Post

player_monoids may be useful, but it REALLY isn't THAT HARD to just modify player physics yourself. I prefer to change 10 lines of code without needing another dependency.
My stuff: Projects - Mods - Website

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

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by Byakuren » Post

LMD wrote:player_monoids may be useful, but it REALLY isn't THAT HARD to just modify player physics yourself. I prefer to change 10 lines of code without needing another dependency.
First, note that you can just have a soft dependency and fall back to your current way if player_monoids is not installed. It would be easy to swap between the two implementations if you make function definitions for "apply effect" and "cancel effect" that are dependent on whether player_monoids is around.

If you are talking about multiplying by a modifier and then dividing by it, that doesn't work when you want to use a multiplier of 0 to stop player movement / jumping (I responded to this in the github issue that was linked earlier).

It also doesn't work if you want to mix multiplication and addition. For example:
- Player starts at 1 speed
- Mod A applies an effect that adds 0.2 speed. The player now has 1.2 speed.
- Mod B applies an effect that doubles speed. The player now has 2.4 speed.
- Mod A's effect wears off. The player now has 2.2 speed (because mod A "undid" the effect by subtracting 0.2)
- Mod B's effect wears off. The player now has 1.1 speed (because mod B "undid" the effect by dividing by 2)

The player ends up having a non-1 neutral speed.

Lastly, rounding errors in floating point arithmetic will cause the player physics override to drift slowly. This is not likely to be a problem in practice but does feel unclean.

player_monoids handles the first issue by explicitly keeping track of the list of active player physics modifiers, so that information isn't lost when using a multiplier of 0. It also avoids drift from floating point rounding because it does not use the player physics override like an accumulator value.

It handles the second issue by making it possible for mods to combine effects in their own way before applying them through player_monoids. So for example, a mod that wants to subtract / add speed modifiers could set up its own monoid (or some other way of combining effects), and then use that final value as input to the player_monoids-provided speed monoid.

Just doing / undoing with multiplication and division is fine and coherent if you don't want to stop movement, use addition / subtraction, or be compatible with any mods that want to do those two things, but it is not a universal solution.
Every time a mod API is left undocumented, a koala dies.

User avatar
LMD
Member
Posts: 1396
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by LMD » Post

You are right.
However, as I'm doing it for a subgame, it isnt really required to work with other mods.
My stuff: Projects - Mods - Website

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

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbspri

by Byakuren » Post

LMD wrote:You are right.
However, as I'm doing it for a subgame, it isnt really required to work with other mods.
Fair enough.
Every time a mod API is left undocumented, a koala dies.

bard
New member
Posts: 7
Joined: Sun Jul 22, 2018 23:21
GitHub: Soundtoxin
IRC: bdju
In-game: bard

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbsprint]

by bard » Post

Does this mod work with unified_inventory? I added a few mods to my server, and suddenly hunger and sprinting stopped working.

edit: Nevermind, unified_inventory is not the problem. It's something among these I think:

Code: Select all

load_mod_youngtrees = true
load_mod_vines = true
load_mod_poisonivy = true
load_mod_nature_classic = true
load_mod_flowers_plus = true
load_mod_ferns = true
load_mod_cavestuff = true
load_mod_bushes_classic = true
load_mod_bushes = true
load_mod_3dmushrooms = true
load_mod_woodsoils = true
load_mod_trunks = true
load_mod_moretrees = true
load_mod_wildlife = true
load_mod_molehills = true
load_mod_along_shore = true
load_mod_dryplants = true
load_mod_junglegrass = true
edit2: I was missing mobkit for wildlife and biome_lib for moretrees. The errors weren't very good so I just enabled/disabled mods and checked if the hunger bar showed or not to see if the enabled mods contained the bad one(s). Everything is enabled and working now.

User avatar
duckgo
Member
Posts: 205
Joined: Sun Sep 20, 2020 08:01
In-game: duckgo
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbsprint]

by duckgo » Post

hello, I wonder if anyone knows how to solve this
suddenly the doll no longer runs even pressing the button to run, but it still consumes my energy, even the doll without running .. if someone can give me a tip, thanks in advance, and thanks for the Mod :)

ronoaldo
Member
Posts: 177
Joined: Mon Dec 07, 2020 01:04
GitHub: ronoaldo
IRC: ronoaldo
In-game: RonoaldoKakashi
Location: São Paulo, Brasil
Contact:

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbsprint]

by ronoaldo » Post

Hi! Is it possible to get this PR reviewed and potentially merged? It will keep other physics overrides that were in place before the start sprint method is called.

https://github.com/minetest-mods/hbsprint/pull/31

Thanks!
Servers: Mercurio | Tools: ContentDB CLI | Mods: minenews

Hoffscore
New member
Posts: 7
Joined: Fri Sep 02, 2016 04:41
IRC: Hoffscore or csisdustin
In-game: Hoff
Location: University Heights, Calgary, AB, Canada

Re: [Mod] Sprint w. hudbars, hunger, monoids support [hbsprint]

by Hoffscore » Post

HBSprint says no dependancies, but requires hunger value? runs in Jaunchi game which has no hunger value...

AsyncErr: Lua: Runtime error from mod '' in callback environment_Step(): ...-5.5.0-win64\bin\..\games\juanchi\mods\hbsprint\init.lua:232: attempt to index global 'hbhunger' (a nil value)
stack traceback:
...-5.5.0-win64\bin\..\games\juanchi\mods\hbsprint\init.lua:232: in function 'sprint_step'
...-5.5.0-win64\bin\..\games\juanchi\mods\hbsprint\init.lua:257: in function <...-5.5.0-win64\bin\..\games\juanchi\mods\hbsprint\init.lua:253>
...st\minetest-5.5.0-win64\bin\..\builtin\game\register.lua:425: in function <...st\minetest-5.5.0-win64\bin\..\builtin\game\register.lua:409>

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 15 guests