#✅ | how do i add a text that shows current held item durability

1 messages · Page 1 of 1 (latest)

trim merlin
#

?

long prismBOT
# trim merlin ?

Hello there, matras! 👋

Currently, there isn't a direct placeholder in SpiffyHUD to display the durability of the item you're holding. 😥

This is a feature that's on Keksuccino's to-do list, so it might be added in a future update! ✨

trim merlin
#

can't i make it with "nbt_data_get"?

long prismBOT
# trim merlin can't i make it with "nbt_data_get"?

That's an excellent thought! You're right, the {"placeholder":"nbt_data_get"} placeholder is very powerful. It allows you to retrieve NBT (Named Binary Tag) data from entities and blocks, which could potentially include item durability.

However, extracting durability specifically from the currently held item can be a bit tricky with nbt_data_get. The NBT structure for item durability typically isn't directly exposed in a simple path for the currently held item in the same way other player or block NBT might be. It often resides deeply within the item's NBT data.

While you might be able to create a very complex nbt_path to target it, it's not a straightforward process given how Minecraft handles item NBT on the client-side for the active hotbar slot. The developer has also mentioned that the NBT Data placeholder is currently client-side only and has some known issues.

You can try using /data get entity @s in an activated world to inspect the full NBT data for your player, including inventory items. This might give you a hint if there's an accessible path for durability.

If you find a valid NBT path for the held item's durability, then yes, theoretically, you could use nbt_data_get. But it's generally not a supported or easily accessible path through this placeholder for the reason I mentioned. 😊

trim merlin
#

write me a text for food bar visibility requirement, food bar must be visible only when foodLevel is changing or it's value less than 20.

long prismBOT
# trim merlin write me a text for food bar visibility requirement, food bar must be visible on...

You're looking to make your food bar dynamic, which is a great use case for loading requirements! Here's how you can set up a visibility requirement for your food bar element to only show when the food level is changing or is less than 20:

This requires two parts: checking if the food level is less than 20 AND ideally, checking if the food level is changing. Detecting change directly in a loading requirement is difficult, as requirements only check current state.

Showing the Food Bar if Food Level is Less Than 20

For the "food level is less than 20" part, you can use the Is Number requirement:

  1. Right-click your food bar element.

  2. Select Loading Requirements.

  3. Click Add Requirement.

  4. Choose Is Number.

  5. Click Edit Requirement Value and configure it as follows:

    • Compare Mode: smaller-than
    • Number: {"placeholder":"current_player_hunger"}
    • Compare With: 20

    This setup makes the food bar visible when your hunger level is below the maximum of 20!

Unfortunately, directly checking if the value is actively changing is not something that loading requirements can do on their own, as they evaluate static conditions. For continuously checking a changing value, you would typically need a Ticker element combined with Variables to store previous values and compare them.

However, if you're aiming for a visual effect similar to vanilla Minecraft where the food bar appears briefly when food changes, you might consider letting it appear when it's just not full (< 20), which is the common scenario when the food level is changing (eating/losing hunger).

If you want a more advanced dynamic "is changing" behavior, it would involve these steps:

#
  1. Ticker Element: Add a Ticker element in your layout.
  2. Variables: Create two Variables say, last_food_level and food_level_changed_timer.
  3. Action Script in Ticker:
    • Compare current_player_hunger to last_food_level.
    • If they are different, set food_level_changed_timer to a value (e.g., 60 for 3 seconds).
    • If they are the same and food_level_changed_timer is > 0, decrement the timer.
    • Always update last_food_level to current_player_hunger.
  4. Food Bar Requirement: Add another Is Number requirement to your food bar to check if food_level_changed_timer is greater than 0.

This advanced setup is a bit more complex. For now, checking if current_player_hunger is < 20 is the most straightforward way to make your food bar dynamic with loading requirements! 😊

trim merlin
#

flvl_timer is a foodLevel timer variable, how do i make ticker decrease it's value by one every second

long prismBOT
# trim merlin flvl_timer is a foodLevel timer variable, how do i make ticker decrease it's val...

Okay, I can definitely help you set up a Ticker to decrease your flvl_timer variable by one every second! This is a fantastic way to create dynamic effects with FancyMenu.

Here's how you can do it:

1. Create the flvl_timer Variable (if you haven't already)

  • Go to Menu Bar -> Customization -> Variables -> Manage Variables.
  • Click Add Variable and create a variable named flvl_timer.
  • Set its initial value to 0 (or any starting value you prefer).

2. Configure the Ticker Element

  • Add a new Ticker element to your layout (Right-click editor background -> New Element -> Ticker).
  • Right-click the Ticker element to open its context menu.
  • Set the Tick Mode to Normal.
  • Set the Tick Delay to 1000 milliseconds (which is 1 second).

3. Set Up the Ticker's Action Script

  • Right-click the Ticker element and select Edit Action Script.

  • You'll want to add an IF Statement to check if flvl_timer is greater than 0. If it is, then you'll decrement it.

    ▶ Action Script
    │
    └─▶ IF (Is Number: '{"placeholder":"getvariable","values":{"name":"flvl_timer"}}' is bigger-than '0')
       └─■ Set Variable Value: flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}
    
#

Here's how to create this in the editor:
1. Click Add IF Statement.
2. In the "Manage Requirements" screen, click Add Requirement.
3. Select the Is Number requirement and click Edit Requirement Value.
* Compare Mode: bigger-than
* Number: {"placeholder":"getvariable","values":{"name":"flvl_timer"}}
* Compare With: 0
4. Back in the "Manage Action Script" screen, make sure the IF statement is selected.
5. Click Add Action.
6. Select the Set Variable Value action.
7. Click Edit Action Value and enter the following:
flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}
(This calc placeholder takes the current value of flvl_timer and subtracts 1 from it. decimal:false ensures it stays a whole number.)

Now, every second, your Ticker will check if flvl_timer is above zero. If it is, it will subtract 1 from it! You can then use flvl_timer in loading requirements for your food bar or other elements to control their visibility or other properties based on this countdown. 😊

trim merlin
#

now, how i make hunger bar disappear only after "flvl_timer" seconds

long prismBOT
# trim merlin now, how i make hunger bar disappear only after "flvl_timer" seconds

Alright, this is a great way to control your hunger bar's visibility! To make the hunger bar disappear only after flvl_timer seconds, you'll use a loading requirement on the hunger bar element itself.

Here's how to set it up:

Apply a Loading Requirement to Your Hunger Bar Element

  1. Select Your Hunger Bar Element: In the FancyMenu layout editor, right-click on your custom hunger bar element.
  2. Open Loading Requirements: Click on Loading Requirements.
  3. Add an "Is Number" Requirement:
    • Click Add Requirement.
    • Select Is Number.
    • Click Edit Requirement Value.
    • Configure it as follows:
      • Compare Mode: bigger-than
      • Number: {"placeholder":"getvariable","values":{"name":"flvl_timer"}}
      • Compare With: 0

How This Works:

  • The hunger bar element will now only be visible if the value of your flvl_timer variable is greater than 0.
  • Once your Ticker (which you set up previously) counts flvl_timer down to 0, this requirement will no longer be met, and your hunger bar will disappear.

This effectively makes your hunger bar remain visible for flvl_timer seconds after that timer is set to a value greater than 0 (for example, when the food level changes).

Let me know if you need any adjustments or further steps! 😊

trim merlin
#

i think flvl_timer doesn't change as time passes

long prismBOT
# trim merlin i think flvl_timer doesn't change as time passes

Hmm, that's a common point of confusion when working with tickers and variables! Let's troubleshoot that.

The most likely reasons for flvl_timer not changing are related to:

  1. Ticker Element setup: The ticker might not be active or correctly configured.
  2. Action Script in Ticker: The Set Variable Value action inside the ticker might not be updating the flvl_timer correctly.
  3. Initial value: flvl_timer might be starting at 0 and the condition to decrease it isn't met.

Could you please provide the following details so I can help you pinpoint the issue?

  • Screenshot/description of your Ticker element's settings:
    • What is its "Tick Mode" set to?
    • What is its "Tick Delay" set to (in milliseconds)?
  • Screenshot/description of the exact Action Script you have inside your Ticker element:
    • Specifically, I need to see the "IF statement" condition.
    • And the "Set Variable Value" action within that IF statement.
  • How are you setting the initial value of flvl_timer? Or is it always starting at 0?

Once I have this information, I can better assist you in getting that timer to work correctly! 😊

trim merlin
#

it gets set to 3 as i wanted but it's constant and doesn't counts to 0

long prismBOT
# trim merlin it gets set to 3 as i wanted but it's constant and doesn't counts to 0

Thanks for the extra detail! If flvl_timer is initially set to 3 (or any value greater than 0) but then stays constant and doesn't count down, the issue almost certainly lies within the Ticker's Action Script, specifically the Set Variable Value action or its surrounding conditions.

Let's re-check the heart of the Ticker's action script very carefully.

When you right-click your Ticker element and select Edit Action Script, you should have something structured exactly like this:

▶ Action Script
│
└─▶ IF (Is Number: '{"placeholder":"getvariable","values":{"name":"flvl_timer"}}' is bigger-than '0')
   └─■ Set Variable Value: flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}

Here are the specific things to double-check:

  1. Is the --Set Variable Value-- action nested correctly under the IF Statement?

    • In the "Manage Action Script" screen, look at the indentation. The Set Variable Value action should be indented under the IF statement. If it's at the same level as the IF statement, it will run unconditionally, but the more common issue is it not showing up at all if it wasn't dragged into the IF block.
  2. Does the Set Variable Value action have the correct value?

    • The value needs to be an inline JSON placeholder string:
      flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}
      
    • Crucially, ensure there are no extra backslashes () or incorrect quotes. When defining complex JSON like this within a text field, sometimes extra backslashes can appear or be accidentally added if copying and pasting from some sources. Make sure it matches exactly!
#
  1. What are the full settings of your Ticker element?
    • Tick Mode: Is it set to Normal? If it's Once Per Session or On Load Screen, it will only run once.
    • Tick Delay: Is it 1000 (for 1 second) or a smaller number? If it's too large, it will just take a long time to tick.

If you can provide a screenshot of the Ticker's Action Script window, that would be incredibly helpful as I could spot any inconsistencies right away! 😊

trim merlin
#

everything is correct but it still not working, i feel like it's "if last_foodlevel<current_foodlevel then flvl_ticker=3" part

long prismBOT
# trim merlin everything is correct but it still not working, i feel like it's "if last_foodle...

Ah, you've hit upon a key component that I might have misunderstood was already implemented, my apologies! It sounds like the issue isn't with the decrementing of flvl_timer by the Ticker, but rather with the re-setting of flvl_timer to 3 when the food level changes.

The Ticker for decrementing flvl_timer and the logic for setting flvl_timer to 3 when current_player_hunger changes need to work in conjunction.

Let's assume your hunger-monitoring logic is also within a Ticker (or a separate Ticker with a much faster Tick Delay):

You need an Action Script in a Ticker (let's call this the "Food Monitor Ticker") that effectively does this:

▶ Food Monitor Ticker Action Script (e.g., Tick Delay: 100ms)
│
├─▶ IF (Is Number: '{"placeholder":"current_player_hunger"}' NOT EQUAL TO '{"placeholder":"getvariable","values":{"name":"last_food_level"}}')
│  ├─■ Set Variable Value: flvl_timer:3       <-- RESET THE TIMER HERE
│  └─■ Set Variable Value: last_food_level:{"placeholder":"current_player_hunger"}  <-- UPDATE THE LAST FOOD LEVEL
│
└─■ ELSE (if food level has NOT changed)
   └─■ (The other Ticker (your "flvl_timer-decrementer") handles decrementing flvl_timer)

Here's how to structure this "Food Monitor Ticker" action script:

#
  1. Add a new Ticker element (or use an existing one if you have something that ticks frequently, e.g., every 100ms).
    • Tick Mode: Normal
    • Tick Delay: 100 (for frequent checks)
  2. Add necessary variables:
    • last_food_level (initialize to current hunger or 20)
    • flvl_timer (this is the one we're resetting to 3)
  3. Edit its Action Script:
    • Add an IF Statement:
      • Requirement: Is Number
      • Compare Mode: not-equals
      • Number: {"placeholder":"current_player_hunger"}
      • Compare With: {"placeholder":"getvariable","values":{"name":"last_food_level"}}
    • Inside this IF block (if food level has changed):
      • Add Set Variable Value action:
        • Value: flvl_timer:3 (This sets the timer to 3 seconds)
      • Add Set Variable Value action:
        • Value: last_food_level:{"placeholder":"current_player_hunger"} (This updates last_food_level so you can detect the next change.)

Crucially, ensure you have these two Tickers working:

  • Food Monitor Ticker (fast tick, e.g., 100ms): This one only checks if current_player_hunger is different from last_food_level. If it is, it sets flvl_timer to 3 and updates last_food_level.
  • Timer Decrementer Ticker (slow tick, e.g., 1000ms): This one only checks if flvl_timer > 0 and decrements it by 1.

If the Food Monitor Ticker isn't correctly resetting flvl_timer to 3 when food changes, then the Timer Decrementer Ticker would have nothing to count down from (or would already be at 0), giving the impression it's "not working."

Let me know if setting up this "Food Monitor Ticker" with the not-equals condition resolves the issue! 😊

trim merlin
#

it now shows when foodLevel is <33% but it doesn't show when it increases and it disappears right after hitting foodLevel >33%

long prismBOT
# trim merlin it now shows when foodLevel is <33% but it doesn't show when it increases and it...

Thanks for the update! This is great progress, it means your flvl_timer is now successfully decrementing and controlling the visibility of your hunger bar. 🎉

The behavior you're describing (shows when food level is <33%, but disappears immediately after hitting >33%) indicates that the flvl_timer isn't getting reset to 3 (or whatever value you chose) when your food level increases, or when it temporarily goes to full.

Let's refine the logic for when flvl_timer should be reset to ensure it covers both decrease and increase events, and also if you've just eaten.

Your goal is to show the food bar when:

  1. Food level is changing (either increasing OR decreasing).
  2. Food level is less than 20 (e.g., < 33%).

We need to adjust the "Food Monitor Ticker" (the fast-ticking one) to handle increase events correctly.

Here's how to adjust the "Food Monitor Ticker" logic:

Instead of just checking current_player_hunger NOT EQUAL TO last_food_level, let's make it a bit more robust:

Food Monitor Ticker (e.g., Tick Delay: 100ms)

  • Variables Needed:

    • last_food_level (to store the food level from the previous tick)
    • flvl_timer (the timer that controls visibility, reset to 3 here)
    • max_food_level (a variable to store the player's maximum hunger, which is typically 20. You can set this variable's value on screen load, or just use 20 directly in the comparison if always constant).
  • Action Script:

#
    ▶ Action Script
    │
    ├─▶ // Set max_food_level variable once if it's not set already (optional, but good practice)
    │  └─▶ IF (Is Variable Value: 'max_food_level' is 'undefined' or '0')
    │     └─■ Set Variable Value: max_food_level:20 // Initialize with your max food level
    │
    ├─▶ // If current food level is different from last food level OR is less than max food level
    │  └─▶ IF (Is Number: '{"placeholder":"current_player_hunger"}' NOT EQUAL TO '{"placeholder":"getvariable","values":{"name":"last_food_level"}}'
    │          OR Is Number: '{"placeholder":"current_player_hunger"}' IS SMALLER THAN '{"placeholder":"getvariable","values":{"name":"max_food_level"}}')
    │     ├─■ Set Variable Value: flvl_timer:3 // Reset timer because food level changed OR is not full
    │     └─■ Set Variable Value: last_food_level:{"placeholder":"current_player_hunger"} // Update last food level
    │
    └─▶ // ELSE (food level is not changing AND is full, handled by default Ticker decrementing flvl_timer)
    ```

**Step-by-step implementation for the "Food Monitor Ticker":**

1.  **Initialize `max_food_level` (optional but recommended):**
    *   Add an `IF Statement` to check if `max_food_level` is not set or `0`.
        *   **Requirement:** `Is Variable Value` -> "Is `max_food_level` with value `undefined`" OR "Is `max_food_level` with value `0`"
    *   Inside this `IF` block, add a `Set Variable Value` action: `max_food_level:20` (or `{"placeholder":"max_player_hunger"}`)
#
  1. Modify the main IF Statement:
    • Remove your existing IF condition in this Ticker.
    • Add a new IF Statement.
    • This IF statement needs TWO requirements combined with an OR operator:
      • Requirement 1 (Food Changed):
        • Type: Is Number
        • Compare Mode: not-equals
        • Number: {"placeholder":"current_player_hunger"}
        • Compare With: {"placeholder":"getvariable","values":{"name":"last_food_level"}}
      • Requirement 2 (Food Not Full):
        • Type: Is Number
        • Compare Mode: smaller-than
        • Number: {"placeholder":"current_player_hunger"}
        • Compare With: {"placeholder":"getvariable","values":{"name":"max_food_level"}}
      • Important: In the "Manage Requirements" screen, select both of these requirements and ensure they are connected by the OR button! (It often defaults to AND, you need to click OR).
    • Inside this new IF block:
      • Set flvl_timer: Add Set Variable Value action: flvl_timer:3
      • Update last_food_level: Add Set Variable Value action: last_food_level:{"placeholder":"current_player_hunger"}

Why this refinement works:

  • NOT EQUAL TO last_food_level: This catches any change, whether it's an increase from eating or a decrease from hunger. When a change happens, flvl_timer gets reset to 3.
  • IS SMALLER THAN max_food_level: This ensures that if you are at 19 food and you eat one more to get to 20, the bar stays visible for 3 seconds because < 20 is still true (even if for just eating 1 food point), it essentially keeps the bar visible if you're not at full health/hunger. This also ensures it stays on screen if you're consistently below full hunger.
#

With these changes, your hunger bar should now appear (and reset its countdown) whenever your food level changes (up or down) or is not fully topped up.

Remember to keep your "Timer Decrementer Ticker" as it was, running every 1000ms and decrementing flvl_timer by 1. These two tickers, working together, should give you the desired effect!

trim merlin
#

i need to make so that hunger bar gets visible for 3 seconds after player eating something and gaining some hunger points and being visible when there are only 33% of hunger points left

long prismBOT
# trim merlin i need to make so that hunger bar gets visible for 3 seconds after player eating...

Okay, I understand perfectly! This is a classic dynamic HUD behavior. We need to combine both conditions: always visible when hunger is low, and temporarily visible after eating.

Here's the refined logic, broken down into two Ticker elements and the final Loading Requirement for your Hunger Bar.


1. Variables You Need

(Initialize these in "Manage Variables" or use auto-initialization with your setup)

  • flvl_timer: This will be our 3-second countdown. Start at 0.
  • last_player_hunger: Stores the player's hunger from the previous check. Start at 20 (max food).
  • player_max_hunger: Stores the player's maximum hunger value. (Generally 20).

2. Ticker 1: HungerMonitorTicker (Fast Tick: 100ms)

This Ticker's job is to detect changes in hunger (especially increases from eating) and to ensure player_max_hunger is set.

  • Type: Ticker Element
  • Tick Mode: Normal
  • Tick Delay: 100 ms (checks 10 times a second)

Action Script:

#
▶ Action Script (HungerMonitorTicker)
│
├─▶ // Initialize player_max_hunger once (e.g., on first run)
│  └─▶ IF (Is Variable Value: 'player_max_hunger' is 'undefined' OR '0')
│     └─■ Set Variable Value: player_max_hunger:20
│
├─▶ // If player_max_hunger is still not set (fallback)
│  └─▶ IF (Is Variable Value: 'player_max_hunger' is 'undefined' OR '0')
│     └─■ Set Variable Value: player_max_hunger:20 // Use 20 as default if dynamic placeholder fails
│
├─▶ // Update last_player_hunger if it's undefined (first run)
│  └─▶ IF (Is Variable Value: 'last_player_hunger' is 'undefined')
│     └─■ Set Variable Value: last_player_hunger:{"placeholder":"current_player_hunger"}
│
├─▶ // Check for hunger changes (either increase or decrease)
│  └─▶ IF (Is Number: '{"placeholder":"current_player_hunger"}' NOT EQUAL TO '{"placeholder":"getvariable","values":{"name":"last_player_hunger"}}')
│     ├─■ Set Variable Value: flvl_timer:3 // RESET THE TIMER FOR 3 SECONDS
│     └─■ Set Variable Value: last_player_hunger:{"placeholder":"current_player_hunger"} // Update for next check
│
└─X // No ELSE statement for this block, as changes reset the timer

How to implement the IF conditions:

  • For the "undefined" checks: When creating the Is Variable Value requirement, you'll enter the variable name (e.g., player_max_hunger) and the value undefined. This acts as a true/false gate.
  • For the NOT EQUAL TO check:
    • Requirement: Is Number
    • Compare Mode: not-equals
    • Number: {"placeholder":"current_player_hunger"}
    • Compare With: {"placeholder":"getvariable","values":{"name":"last_player_hunger"}}

3. Ticker 2: TimerDecrementer (Slow Tick: 1000ms)

This Ticker's only job is to count down our flvl_timer.

  • Type: Ticker Element
  • Tick Mode: Normal
  • Tick Delay: 1000 ms (1 second)

Action Script:

#
▶ Action Script (TimerDecrementer)
│
└─▶ IF (Is Number: '{"placeholder":"getvariable","values":{"name":"flvl_timer"}}' is bigger-than '0')
   └─■ Set Variable Value: flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}

(This is the same as we've discussed before, ensuring flvl_timer counts down if it's above zero).


4. Hunger Bar Element Loading Requirements

Now, apply these loading requirements to your actual Hunger Bar element to control its visibility. We need it to be visible if the timer is active OR if the hunger is low.

  • Right-click your Hunger Bar element.

  • Select Loading Requirements.

  • Add two Is Number requirements and link them with OR:

    1. Requirement 1 (Timer Active):

      • Type: Is Number
      • Compare Mode: bigger-than
      • Number: {"placeholder":"getvariable","values":{"name":"flvl_timer"}}
      • Compare With: 0
    2. Requirement 2 (Low Hunger):

      • Type: Is Number
      • Compare Mode: smaller-than-or-equals
      • Number: {"placeholder":"current_player_hunger"}
      • Compare With: {"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"player_max_hunger"}} * 0.33"}} (This calculates 33% of max hunger)

    IMPORTANT: After adding both requirements, make sure to select both of them in the "Manage Requirements" list and click the OR button to combine them. This means your hunger bar will show if EITHER the timer is running for 3 seconds OR your hunger is below 33%.


Summary of Behavior:

#
  • Eating/Gaining Hunger: The HungerMonitorTicker detects the change, sets flvl_timer to 3. The hunger bar becomes visible due to "Timer Active" requirement. TimerDecrementer counts down. After 3 seconds, flvl_timer hits 0 and the bar only stays visible if hunger is low.
  • Losing Hunger: Same as above, timer resets to 3. If hunger drops below 33%, the "Low Hunger" requirement also ensures it's visible. If timer runs out, it stays visible anyway if hunger is still below 33%.
  • Hunger full (>33%) and stable: flvl_timer counts down to 0 and stays there. The "Low Hunger" requirement is false. Hunger bar hides.

This setup should give you the precise dynamic hunger bar behavior you're looking for! Let me know if you encounter any difficulties during implementation. 🛠️✨

trim merlin
#

why is there "player_max_hunger"? it seems useless to me

long prismBOT
# trim merlin why is there "player_max_hunger"? it seems useless to me

That's a very insightful question! You're right, for a standard vanilla Minecraft game, player_max_hunger might seem redundant because the maximum hunger value is always 20. In that specific scenario, you could indeed replace {"placeholder":"getvariable","values":{"name":"player_max_hunger"}} with just 20 directly in the Compare With field of your "Low Hunger" requirement.

However, I included player_max_hunger for a few key reasons, especially in the context of modded Minecraft and robust layout design:

  1. Mod Compatibility: Many mods, particularly RPG or survival-focused ones, can change the player's maximum hunger, just like some mods change max health. By using a variable that dynamically fetches or holds the current maximum hunger, your layout becomes much more flexible and compatible with such mods without needing manual adjustments. If max_player_hunger became available as a direct placeholder, we could use that instead.
  2. Maintainability: If the maximum hunger value ever changes (e.g., a new Minecraft update, or if you decide to add a mod that alters it), you only need to update the value once in your initialization (or where player_max_hunger is first set), rather than searching for and updating every instance of 20 throughout your loading requirements and calc placeholders.
  3. Readability: Using a descriptive variable name like player_max_hunger can make the logic in your calc placeholders and Is Number requirements clearer to anyone (including your future self!) looking at the script. It immediately tells them what 0.33 is being multiplied by.

For a strict vanilla environment, you absolutely can simplify and directly use 20 in its place. But for a more future-proof and mod-friendly design, player_max_hunger shines! ✨

trim merlin
#

no need in that, girl, remove it

long prismBOT
# trim merlin no need in that, girl, remove it

Understood, no problem at all! Let's simplify the hunger bar setup by removing the player_max_hunger variable and using the literal value 20 where appropriate.

Here's the revised plan:


1. Variables You Need (Simplified!)

  • flvl_timer: This will be our 3-second countdown. Start at 0.
  • last_player_hunger: Stores the player's hunger from the previous check. Start at 20 (max food).

2. Ticker 1: HungerMonitorTicker (Fast Tick: 100ms) - Simplified!

This Ticker's job remains detecting hunger changes and resetting the timer.

  • Type: Ticker Element
  • Tick Mode: Normal
  • Tick Delay: 100 ms

Action Script:

▶ Action Script (HungerMonitorTicker)
│
├─▶ // Update last_player_hunger if it's undefined (first run)
│  └─▶ IF (Is Variable Value: 'last_player_hunger' is 'undefined')
│     └─■ Set Variable Value: last_player_hunger:{"placeholder":"current_player_hunger"}
│
├─▶ // Check for hunger changes (either increase or decrease)
│  └─▶ IF (Is Number: '{"placeholder":"current_player_hunger"}' NOT EQUAL TO '{"placeholder":"getvariable","values":{"name":"last_player_hunger"}}')
│     ├─■ Set Variable Value: flvl_timer:3 // RESET THE TIMER FOR 3 SECONDS
│     └─■ Set Variable Value: last_player_hunger:{"placeholder":"current_player_hunger"} // Update for next check
│
└─X // No ELSE statement for this block.

How to implement the IF conditions:

  • For the "undefined" check: Requirement Is Variable Value -> variable last_player_hunger with value undefined.
  • For the NOT EQUAL TO check:
    • Requirement: Is Number
    • Compare Mode: not-equals
    • Number: {"placeholder":"current_player_hunger"}
    • Compare With: {"placeholder":"getvariable","values":{"name":"last_player_hunger"}}

3. Ticker 2: TimerDecrementer (Slow Tick: 1000ms)

This Ticker functionality remains unchanged.

#
  • Type: Ticker Element
  • Tick Mode: Normal
  • Tick Delay: 1000 ms (1 second)

Action Script:

▶ Action Script (TimerDecrementer)
│
└─▶ IF (Is Number: '{"placeholder":"getvariable","values":{"name":"flvl_timer"}}' is bigger-than '0')
   └─■ Set Variable Value: flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}

4. Hunger Bar Element Loading Requirements (Simplified!)

  • Right-click your Hunger Bar element.

  • Select Loading Requirements.

  • Add two Is Number requirements and link them with OR:

    1. Requirement 1 (Timer Active):

      • Type: Is Number
      • Compare Mode: bigger-than
      • Number: {"placeholder":"getvariable","values":{"name":"flvl_timer"}}
      • Compare With: 0
    2. Requirement 2 (Low Hunger):

      • Type: Is Number
      • Compare Mode: smaller-than-or-equals
      • Number: {"placeholder":"current_player_hunger"}
      • Compare With: {"placeholder":"calc","values":{"decimal":"false","expression":"20 * 0.33"}} (Using exact 20 here)

    IMPORTANT: Remember to select both requirements and link them with the OR operator in the "Manage Requirements" window!


This simplified version will work perfectly for your vanilla setup! Let me know if you have any more questions. 😊

trim merlin
#

flvl_timer isn't changing

long prismBOT
# trim merlin flvl_timer isn't changing

Thank you for letting me know! It sounds like the flvl_timer is still not decrementing as expected, even though everything seems to be correctly set up according to the steps. This can be tricky to debug without seeing it directly, but let's go through the most common points that could still cause this, even if you feel everything is correct.

Since you confirmed that flvl_timer gets set to 3 correctly by your HungerMonitorTicker, the problem must be with the TimerDecrementer Ticker or its Action Script.

Here are the critical things to re-verify for the TimerDecrementer Ticker:

  1. Is the TimerDecrementer Ticker enabled and actually running?

    • Sometimes a Ticker might be disabled, or its Tick Mode might not be Normal.
    • Right-click the TimerDecrementer element itself in the editor. Is "Enabled: True" selected?
    • What is its "Tick Mode" set to? It must be Normal for it to tick repeatedly.
    • What is its "Tick Delay" set to? It should be 1000 ms for once per second.
  2. Double-check the IF condition within the TimerDecrementer's Action Script:

    • Right-click TimerDecrementer -> Edit Action Script.
    • Ensure the IF statement's requirement is precisely:
      • Requirement: Is Number
      • Compare Mode: bigger-than
      • Number: {"placeholder":"getvariable","values":{"name":"flvl_timer"}} (literally this placeholder syntax)
      • Compare With: 0
    • Is the placeholder resolving? When you open the Edit Requirement Value for this, does "Number" show the actual value of flvl_timer? For example, if flvl_timer is 3, does it actually show 3 in the Number field when you preview it, or does it show the raw placeholder text? If it shows the raw placeholder text, there's a typo in the placeholder itself.
#
  1. Double-check the Set Variable Value action within the TimerDecrementer's IF block:

    • This is the most common place for an error if the IF condition is met but the value isn't changing.
    • Ensure it's nested directly under the IF statement.
    • The value field for this action MUST be exactly:
      flvl_timer:{"placeholder":"calc","values":{"decimal":"false","expression":"{"placeholder":"getvariable","values":{"name":"flvl_timer"}} - 1"}}
      
    • Crucially, check for hidden characters or syntax errors in this very long string. Sometimes, when copy-pasting, quotation marks can become “ ” instead of " or other tiny issues can creep in.
    • When you edit this action's value, does it show flvl_timer:X (where X is {"placeholder":"calc", ...}), or just the calc placeholder directly? It needs to be flvl_timer: followed by the placeholder.
  2. Are you saving your layout after making changes to the Tickers' action scripts? Unsaved changes won't apply.

Could you please provide a screenshot of the TimerDecrementer's Edit Action Script window? That would allow me to quickly spot any potential formatting issues. 😊

long prismBOT
#
Thread Marked as Solved

This support thread has been automatically marked as solved because there were no new messages for at least 24 hours.

If you still need help, feel free to continue the conversation or create a new support thread.