• Hey! Register here to create your account, engage with the community, and talk about what is new!

How do I keep players at full hunger (no saturation)

Fghj240

Active member
Joined
Jun 5, 2021
Messages
53
Reaction score
8
I tried giving them steak but they can eat it to restore health. I don't want them to heal, I just want them to be full on hunger. Preferably without having to eat food.
 
Solution
First, you need to make this Code:

Player Join Event -> Call Process: Loop

Then you go to a new code line and make this code:

1. Number: 20
Process: Loop -> Control: Wait -> Call Process: Loop -> Player Action: Set Hunger

Finally you go to another code line and make this code:

1. Game Value: Heal Event Cause
2. Text: natural
Player Heal event -> If Variable: = ( Game Action: Cancel Event)

Afterwards, you should have a result that you like.
If you plan to set the hunger bar below 17, you don't need to make the third Code, just remember that if the hunger is 6 or below, the player won't be able to sprint.

Maskcraft_

Member
Overlord
Joined
Oct 24, 2020
Messages
30
Reaction score
6
First, you need to make this Code:

Player Join Event -> Call Process: Loop

Then you go to a new code line and make this code:

1. Number: 20
Process: Loop -> Control: Wait -> Call Process: Loop -> Player Action: Set Hunger

Finally you go to another code line and make this code:

1. Game Value: Heal Event Cause
2. Text: natural
Player Heal event -> If Variable: = ( Game Action: Cancel Event)

Afterwards, you should have a result that you like.
If you plan to set the hunger bar below 17, you don't need to make the third Code, just remember that if the hunger is 6 or below, the player won't be able to sprint.
 
Solution

Fghj240

Active member
Joined
Jun 5, 2021
Messages
53
Reaction score
8
First, you need to make this Code:

Player Join Event -> Call Process: Loop

Then you go to a new code line and make this code:

1. Number: 20
Process: Loop -> Control: Wait -> Call Process: Loop -> Player Action: Set Hunger

Finally you go to another code line and make this code:

1. Game Value: Heal Event Cause
2. Text: natural
Player Heal event -> If Variable: = ( Game Action: Cancel Event)

Afterwards, you should have a result that you like.
If you plan to set the hunger bar below 17, you don't need to make the third Code, just remember that if the hunger is 6 or below, the player won't be able to sprint.
Thanks :D Actually I'll leave in the natural regen because that 3rd line looks like it'll cancel other healing too and players are gonna heal a bunch so natural regen isn't bad anyways. I set it to 19 and it works well, healing slowly.

One question: What's the difference between a process and a function? And couldn't you do what you just did inside a repeat forever block?
 

Maskcraft_

Member
Overlord
Joined
Oct 24, 2020
Messages
30
Reaction score
6
Okay three things here:

First, due to the if variable statement the healing only gets canceld if it is natural healing (so splash pots and golden apples still do work, only regening with hunger doesn't)

Second, the difference between a process and a function is very important. if you call a function, all of the code inside the function gets triggered before the rest of the code is triggered, while call process can be imagined like a switch that activates the process, but (usually) doesn't interact with the rest of the code. So when making a loop, you would want to use a process since if you use a function, the code after the function would not trigger.

Third, yes, you totally could use a repeater block, though its just personal preference. Just keep in mind: if you want to use one, make sure to use it inside a process.
 
Top Bottom