Hunger manipulation

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Azternaut

Member
Feb 3, 2017
15
2
3
Category: Gameplay

Suggested name: SimpleHungerEdit

What I want:
Make hunger bar last longer, the purpose of the skript is for skywars/skyblock
decreasing but a little longer! :emoji_grinning:

Ideas for commands:
- none

Ideas for permissions:
- none

When I'd like it by: I think it will be a simple skript, if you're an expert you can make this only 5 minute or less :emoji_bow:
 
Category: Gameplay

Suggested name: SimpleHungerEdit

What I want:
Make hunger bar last longer, the purpose of the skript is for skywars/skyblock
decreasing but a little longer! :emoji_grinning:

Ideas for commands:
- none

Ideas for permissions:
- none

When I'd like it by: I think it will be a simple skript, if you're an expert you can make this only 5 minute or less :emoji_bow:
code_language.skript:
set the player's food level to 10

I think you can do the rest :emoji_wink:
 
here a simple code what you request, improve it by yourself.

code_language.skript:
on hunger meter change:
    if {FOOD::%player%} is false:
        cancel event
       
Every 30 second:
    set {FOOD::%player%} to true
    set set the player's food level to 9
    set {FOOD::%player%} to false
 
This should work well :emoji_slight_smile: with /hunger speed <number> you can change the speed of the hungering

0 = no hungering
0.1 = every 10 second one hunger less
1= 1 Hunger lose per second

code_language.skript:
Command /hunger [<text>] [<text>]
    Trigger:
        If arg 1 is "speed":
            Set {hunger.speed} to arg 2
            Message "Hunger speed set to %arg 2% on this server."
            Stop

Every second:
    Loop all players:
        Set {foodlvl.%loop-player%} to 10 - {hunger.speed}
        set the loop-player's food level to {_foodlvl}
 
This should work well :emoji_slight_smile: with /hunger speed <number> you can change the speed of the hungering

0 = no hungering
0.1 = every 10 second one hunger less
1= 1 Hunger lose per second

code_language.skript:
Command /hunger [<text>] [<text>]
    Trigger:
        If arg 1 is "speed":
            Set {hunger.speed} to arg 2
            Message "Hunger speed set to %arg 2% on this server."
            Stop

Every second:
    Loop all players:
        Set {foodlvl.%loop-player%} to 10 - {hunger.speed}
        set the loop-player's food level to {_foodlvl}

Ummm, what if player is do running or do something that spend hunger bar?
it would be unfair right?
 
Ummm, what if player is do running or do something that spend hunger bar?
it would be unfair right?

Use this condition
code_language.skript:
player is sprinting:

maybe like this,
code_language.skript:
Command /hunger [<text>] [<text>]
    Trigger:
        If arg 1 is "speed":
            Set {hunger.speed} to arg 2
            Message "Hunger speed set to %arg 2% on this server."
            Stop
        If arg 1 is "sprint"
            set {hunger.sprint} to arg 2
            message "Hunger sprint speed set to %arg 2% on this server."
            stop
 
Every second:
    Loop all players:
        Set {foodlvl.%loop-player%} to 10 - {hunger.speed}
        set the loop-player's food level to {_foodlvl}
        if player is sprinting:
            Set {foodlvl.%loop-player%} to 10 - {hunger.sprint}
            Set the loop-player's food level to {_foodlvl}
 
Use this condition
code_language.skript:
player is sprinting:

maybe like this,
code_language.skript:
Command /hunger [<text>] [<text>]
    Trigger:
        If arg 1 is "speed":
            Set {hunger.speed} to arg 2
            Message "Hunger speed set to %arg 2% on this server."
            Stop
        If arg 1 is "sprint"
            set {hunger.sprint} to arg 2
            message "Hunger sprint speed set to %arg 2% on this server."
            stop
 
Every second:
    Loop all players:
        Set {foodlvl.%loop-player%} to 10 - {hunger.speed}
        set the loop-player's food level to {_foodlvl}
        if player is sprinting:
            Set {foodlvl.%loop-player%} to 10 - {hunger.sprint}
            Set the loop-player's food level to {_foodlvl}

Maybe you can just double it while sprinting:

code_language.skript:
Command /hunger [<text>]
    Trigger:
        If arg 1 is set:
            Set {hunger.speed} to arg 1
            Message "Hunger speed set to %{hunger.speed}% Hunger levels per second on this server."
            Stop
        Else:
            Message "Use /hunger <amount> to set the hunger speed on this server (in hunger levels per second)" 
            Stop

Every second:
    Loop all players:
        Set {cfoodlvl.%loop-player%} to player's food level
        Set {foodlvl.%loop-player%} to  {cfoodlvl.%loop-player%} - {hunger.speed}
        If player is sprinting:
            set the loop-player's food level to {foodlvl.%loop-player%} - {hunger.speed}
        Else:
            Set the loop-player's food level to {foodlvl.%loop-player%}

On Hunger meter Change:
    Cancel event

But there are plenty of problems:
- effect hunger doesn't effect the hunger level of player
- make its blocking itself because of the on hunger meter change
 
Maybe you can just double it while sprinting:

code_language.skript:
Command /hunger [<text>]
    Trigger:
        If arg 1 is set:
            Set {hunger.speed} to arg 1
            Message "Hunger speed set to %{hunger.speed}% Hunger levels per second on this server."
            Stop
        Else:
            Message "Use /hunger <amount> to set the hunger speed on this server (in hunger levels per second)"
            Stop

Every second:
    Loop all players:
        Set {cfoodlvl.%loop-player%} to player's food level
        Set {foodlvl.%loop-player%} to  {cfoodlvl.%loop-player%} - {hunger.speed}
        If player is sprinting:
            set the loop-player's food level to {foodlvl.%loop-player%} - {hunger.speed}
        Else:
            Set the loop-player's food level to {foodlvl.%loop-player%}

On Hunger meter Change:
    Cancel event

But there are plenty of problems:
- effect hunger doesn't effect the hunger level of player
- make its blocking itself because of the on hunger meter change

may can make own hunger effect?

code_language.skript:
damage player by 1 hearts
 
Or with a bit of basic math you could do the following:
code_language.skript:
options:
    scale: 100 #A scale of 100 instead of 20

on hunger meter change:
    set player's food level to (player's food level*2) / 20 * {@scale}
 
Or with a bit of basic math you could do the following:
code_language.skript:
options:
    scale: 100 #A scale of 100 instead of 20

on hunger meter change:
    set player's food level to (player's food level*2) / 20 * {@scale}

Ok now lets imagine the player has a food level of 10:

(10*2) / 20*100 = 0.02

So the player has now got 0.02 hunger bars? Or am I wrong?
 
Ok now lets imagine the player has a food level of 10:

(10*2) / 20*100 = 0.02

So the player has now got 0.02 hunger bars? Or am I wrong?
The Skript food level (and some others) expression returns the a number in a scale of 10 and that's why I am multiplying it. So, if the player has 10 of health as you said then it should be:
Code:
(5 * 2) / 20 * 100 =>
10 / 20 * 100 =>
0.5 * 100 = 50
 
The Skript food level (and some others) expression returns the a number in a scale of 10 and that's why I am multiplying it. So, if the player has 10 of health as you said then it should be:
Code:
(5 * 2) / 20 * 100 =>
10 / 20 * 100 =>
0.5 * 100 = 50
I fucked up the math....
 
I fucked up the math....
I did something wrong though, as the hunger cannot be greater than 20 the hunger will never change
Here the fixed code:
code_language.skript:
options:
    scale: 100

on join:
    {hungerScale::%player%} isn't set
    set {hungerScale::%player%} to {@scale}

on hunger meter change:
    set {hungerScale::%player%} to player's food level / 10 * {@scale}
    set player's food level to {hungerScale::%player%}