#đ | image change when player takes damage
1 messages · Page 1 of 1 (latest)
You can do this by toggling which image is visible with a variable that gets flipped whenever the player takes damage.
-
Create two Image elements: one for normal state, one for âdamagedâ.
- Give each a loading requirement that checks a FM variable (e.g.,
damage_flash). The normal image shows whendamage_flashisfalse, the damage image shows when itâstrue. Use the Is Variable Value (FM Variable) requirement (docs: Variables ).
- Give each a loading requirement that checks a FM variable (e.g.,
-
Add a listener: open Customization â Manage Listeners (see Listeners docs) and make an On Damage Taken listener.
- In the action script, set
damage_flash:truewhen it fires. - Then use a Ticker (or another listener action) to wait ~0.5s and set
damage_flash:falseagain so the image goes back. You can use a Ticker element that resets the variable after a short delay (e.g., tick once, set variable false, stop).
- In the action script, set
That way the âdamagedâ image is only visible shortly after damage is taken while the normal image stays hidden during that time.
how to make the image changed for longer, let's say 3 seconds?
Use a timer to keep the âdamageâ image visible for 3 seconds. One easy way:
-
Variable logic: Keep what you already have â a variable like
damage_flashthat your two Image elements use as loading requirements (normal image shows when the variable isfalse, damaged image when itâstrue).- Docs: Variables
-
Listener + Ticker: Keep your On Damage Taken listener that sets
damage_flash:true.- After setting it to
true, also start a Ticker (set to tick once every 100 ms or so) that waits about 3 seconds and then setsdamage_flash:falseagain. - You can configure the Tickerâs action script to run something like:
after it has counted enough ticks (use the Tickerâs tick delay and mode to cover roughly 3 seconds).â¶ Set Variable Value (damage_flash:false) â¶ Stop Ticker - Docs: Listeners and Tickers via Action Scripts (add actions inside a Ticker).
- After setting it to
That keeps the damage image active for about 3 seconds before reverting back automatically.
wait, back to step 1 in previous message. I added "is variable value", put variable name as "damage"... and now do I put this true/false things in "variable value to check for", or somewhere else?
In the Is Variable Value (FM Variable) requirement you add to each Image:
- Set Variable Name to
damage(or whatever you named it). - Set Variable Value To Check For to either
trueorfalse, depending on which image should show:- Normal image: requirement checks for
falseâ it only draws whendamageis false. - Damage image: requirement checks for
trueâ it only draws whendamageis true.
- Normal image: requirement checks for
The listener and ticker will flip that variable (use the Set Variable Value action) when you take damage and after 3 seconds, so the correct image appears.
I made a listener, I'm a bit confused on how to set the damage_flash:true thing now
In your On Damage Taken listener you need to add an action that sets the variable.
- Open the listener and click Add Action â choose Set Variable Value (FM Variable).
- In the actionâs value input write
damage:true(ordamage_flash:truedepending on your variable name). - That action will run whenever the listener fires, so the variable becomes
trueand your âhurtâ image shows.
If you also want it to revert after 3 seconds, have a Ticker run after the listener (or inside the listener via a Start Ticker action) that waits 3 seconds and then runs damage:false with another Set Variable action.
See the docs for more on listeners and action scripts: Listeners and Action Scripts.
Okay...
On image A that's when I'm not taking damage I got a loading requirement "Is variable value" with variable name "Damage" and variable value to check for "false"
On image B that's when I'm taking damage I got a loading requirement "Is variable Value" with variable name "Damage" and variable value to check for "true"
In listeners I have "On damage taken", with Set Variable Value with action input being "Damage:true"
It doesn't seem to work, I only see image B, even if I'm not taking any damage, taking damage doesn't change anything
Two things to fix:
-
Make sure the variable actually starts as
false:- Go to Customization â Variables â Manage Variables, create
Damageif it doesnât exist, and set its value tofalse. - Without that, the requirement on Image A never passes so you always see Image B.
- Go to Customization â Variables â Manage Variables, create
-
Reset it after the hit:
- The listener setting
Damage:trueworks, but you also need to switch it back tofalseafter ~3 seconds. - Add a Ticker (tick delay 1000ms, tick mode âCustomâ) that runs every second and, after 3 ticks, executes
Set Variable Value: Damage:falseand stops itself. - Start that ticker from the listener (e.g., add an action after setting
Damage:truethat enables the ticker or use the ticker itself with a loading requirement tied to a helper variable). - Alternatively, inside the listener add a short action script (use the Calculator +
Sleepvia ticking) to delay before settingDamage:false, but ticking is easier.
- The listener setting
That way Image A is shown until Damage is flipped to true, Image B shows while the listener-triggered timer keeps it true, and after 3 seconds the ticker flips the variable back so Image A reappears.
Okay, setting variable Damage to False helped, now I get image A that changes permanently into image B after I take damage. How exactly do I add a ticker?
Nice, youâre almost done! To auto-reset Damage after ~3 seconds, add a Ticker that only runs while Damage is true and counts ticks until it flips the variable back:
Steps
-
Create a Ticker element
- Right-click the editor background â New Element â Ticker.
- Set Tick Delay to
1000(1 second) and Tick Mode toNormal(the ticker will run every second while itâs active).
-
Limit it to the damaged state
- Right-click the ticker â Loading Requirements â Is Variable Value (FM Variable)
- Variable name:
Damage - Value to check for:
true
This ensures the ticker only runs whileDamageis true (i.e., the hurt image is shown).
- Variable name:
- Right-click the ticker â Loading Requirements â Is Variable Value (FM Variable)
-
Give the ticker an action script
- Open Edit Action Script for the ticker.
- Add two actions:
- Set Variable Value
- Value:
damage_ticks:{"placeholder":"calc","values":{"expression":"{"placeholder":"getvariable","values":{"name":"damage_ticks"}} + 1","decimal":"false"}}
(This increments a helper variabledamage_ticksevery second.)
- Value:
- IF statement with requirement Is Number comparing
damage_ticksto3(usegetvariablethere again). Inside its block:Set Variable ValueâDamage:falseSet Variable Valueâdamage_ticks:0
- Set Variable Value
- That way, after the ticker runs three times (â3 seconds) it flips
Damageback tofalseand resets the counter. Since the tickerâs loading requirement now fails, it stops running until the next hit.
-
Create/initialize the helper variable
- Go to Customization â Variables â Manage Variables and add
damage_ticks, default value0. (It needs a starting value for the calc to work.)
- Go to Customization â Variables â Manage Variables and add
If you want, you can also use the same variable logic to show debug text or change other elements. For details on scripting and variables, see the docs: Action Scripts and Variables.
can you expand on the "IF statement with requirement ..." point?
so far I put "Number: damage_ticks", and "compare to number: 3", but I'm not sure if I didn't mess something up, not sure what to do with "getvariable" you're talking about
Sure! Hereâs how to build the IF block properly:
-
Add the IF statement inside the tickerâs action script (right-click ticker â Edit Action Script â Add âIF Statementâ).
-
Add the requirement to the IF block:
- Click the little âAdd Requirementâ button on the IF entry.
- Choose Is Number.
- Set:
- Number:
{"placeholder":"getvariable","values":{"name":"damage_ticks"}} - Compare With:
3 - Comparison Mode:
bigger-than-or-equals
This way the IF only runs oncedamage_ticksreaches 3.
- Number:
-
Inside the IF block, add two actions:
Set Variable ValueâDamage:falseSet Variable Valueâdamage_ticks:0
-
The tickerâs first action (before the IF) should increment the counter:
{"placeholder":"calc","values":{"expression":"{"placeholder":"getvariable","values":{"name":"damage_ticks"}} + 1","decimal":"false"}}Use that inside a Set Variable action with value
damage_ticks:<calc placeholder>.
So the ticker increments damage_ticks each second. Once it hits 3, the IF runs, resets the counter, and flips Damage back to false. Because the ticker only runs while Damage is true, it stops until you take damage again.
If you need a refresher on building action scripts or using placeholders, check the docs: Action Scripts and Variables.
I did evertyhing you said, but I'm stuck on 4th point, the first action (Set variable value) looks exactly like that, but I'm not sure where to place "Use that inside a Set Variable action" part exactly
The first action (before the IF) needs to be a Set Variable Value action that increments damage_ticks. Hereâs exactly how to fill it:
- Action type: Set Variable Value
- Value input:
damage_ticks:{"placeholder":"calc","values":{"expression":"{"placeholder":"getvariable","values":{"name":"damage_ticks"}} + 1","decimal":"false"}}
This means: take the current damage_ticks, add 1, and store it back into damage_ticks every tick. Make sure this action is above the IF block inside the tickerâs action script so the counter increases before the IF checks it.
So the full script order is:
- Set
damage_tickstodamage_ticks + 1(as shown above) - IF
damage_ticks >= 3â- Set
Damage:false - Set
damage_ticks:0
- Set
That makes the ticker count up to 3 seconds, then reset everything.
I did everything exactly like you said, and image B still doesn't change back to image A, no matter how long I wait
Letâs simplify it so the ticker does the timing for you instead of manually counting ticks:
-
Ticker setup
- Add a Ticker (right-click background â New Element â Ticker).
- Set Tick Delay to
3000(3 seconds). - Leave Tick Mode on âNormalâ.
- Give the ticker a Loading Requirement:
Is Variable Valueâ variableDamage, valuetrue. That means the ticker only starts ticking when the damaged image is active.
-
Ticker action script
- Open the tickerâs action script.
- Add a single action:
Set Variable Value Value: Damage:false - Optionally add another action to reset a counter if youâre still using one, but itâs not needed.
-
What happens
- When you take damage, the listener sets
Damage:trueâ Image B shows and the ticker becomes active. - After 3 seconds the ticker fires once, sets
Damage:false, and since the loading requirement now fails, the ticker stops automatically. - Image A shows again.
- When you take damage, the listener sets
Make sure the Damage variable starts as false in Customization â Variables â Manage Variables so you donât start stuck on Image B.
Docs you might need:
okay... that works, but now, no matter the tick delay, image changes basically imideatly after I stop taking damage
Right, that happens because tickers always fire their first action immediately when they become active â the Tick Delay only controls how long between subsequent ticks. So with your setup, the ticker sets Damage:false as soon as the hit ends, even if you set the delay to 3000.
To actually keep the hurt image visible for 3 seconds, make the ticker wait itself:
-
Ticker settings
- Tick Delay:
1000(1 second) - Tick Mode:
Normal - Loading Requirement:
Is Variable Valueâ variableDamage, valuetrue - (Create an FM variable
damage_ticksand set it to0in Customization â Variables â Manage Variables.)
- Tick Delay:
-
Action script
- First action:
Set Variable Valueâ
damage_ticks:{"placeholder":"calc","values":{"expression":"{"placeholder":"getvariable","values":{"name":"damage_ticks"}} + 1","decimal":"false"}} - Add an IF Statement with requirement Is Number:
- Number:
{"placeholder":"getvariable","values":{"name":"damage_ticks"}} - Compare With:
3 - Comparison Mode:
bigger-than-or-equals
- Number:
- Inside the IF block add:
Set Variable ValueâDamage:falseSet Variable Valueâdamage_ticks:0
- First action:
Each tick increments damage_ticks; only when it reaches 3 does the IF fire and reset Damage back to false. Because the IF only runs on the third tick, you get ~3 seconds of hurt image even though the tickerâs first action runs immediately.
didn't we try it earlier and it didn't work? image is stuck at B again, instead of changing back to A
Looks like the counting ticker still wasnât resetting because the IF never triggered (or damage_ticks stayed at 0). Letâs simplify:
Use a second listener instead of counting ticks
- Keep your On Damage Taken listener setting
Damage:true. - Add another listener: On Variable Updated (set to watch
Damage).- In its action script, add an IF that checks
$$new_valueequalstrue(use the listener variable$$new_valuewith an Is Text requirement or calc). - Inside that IF, add a Set Variable Value action
Damage:falsebut wrapped in a Delay using a Ticker-style timer (easiest: add a Ticker triggered by another helper variable, or have the listener start a 3-second timer via a Ticker action). - Another idea: use the Action script â Add âWait?â but there isnât a wait action, so you still need a ticker or a simpler helper variable that the ticker watches.
- In its action script, add an IF that checks
However, the simplest fix is the previous ticker with counter â the problem was the counter never reset when you toggled back to false. Make sure:
damage_ticksvariable exists and is reset to0wheneverDamageswitches tofalse(either in the tickerâs IF or in a separate action after the IF).- The tickerâs action order is: increment counter â IF counter â„ 3 â set
Damage:false, setdamage_ticks:0.
If the IF never fires, open the tickerâs action script and double-check the Is Number requirement is pointing at {"placeholder":"getvariable","values":{"name":"damage_ticks"}} and comparison is bigger-than-or-equals with 3.
Still stuck? I can walk through your current ticker script step by step if you paste the action list.
how do I set watch of that variable to damage?
In the Manage Listeners screen, add a new listener and choose On Variable Updated [FM Variable]. In the listener settings:
- Set Variable Name to Watch â
Damage(this tells FancyMenu to fire the listener whenever that variable changes). - In the listenerâs action script, you can now react to
Damageflipping betweentrue/false. - Use the provided listener variable
$$new_value(or$$old_value) inside requirements or actionsâjust treat them like placeholders (e.g., use an Is Text requirement checking if$$new_valueequalstruebefore starting your 3-second reset).
If you need the exact steps for the listener: see the Listeners documentation for the âOn Variable Updatedâ sectionâthereâs a short description and the runtime variables you can use.
ignore my last message, explain me again instructions on how to add that second listener
Sure! Hereâs how to add the second listener (the âOn Variable Updatedâ one) so it can react when Damage flips:
-
Open Manage Listeners
- Press
Ctrl+Alt+Câ Customization â Manage Listeners.
- Press
-
Add a new listener
- Click âNew Listenerâ â choose On Variable Updated [FM Variable] from the list.
-
Set the variable to watch
- In the listener settings set Variable Name to Watch â
Damage.
That tells FancyMenu to fire the listener whenever theDamagevariable changes.
- In the listener settings set Variable Name to Watch â
-
Add an IF so it only runs when it becomes true
- In the listenerâs action script, add an IF statement.
- Give that IF an Is Text requirement with:
- Text:
$$new_value - Comparison mode:
equals - Compare with:
true
(That makes the inner actions run only whenDamagejust turnedtrue.)
- Text:
-
Inside the IF, reset the timer
- Add actions like:
Set Variable Valueâdamage_ticks:0(if youâre using the counter)Set Variable ValueâDamage:falseafter your ticker finished (or set a helper variable that the ticker watches).- You can also use this listener to flip another helper variable that lets your timer/ticker run for 3 seconds.
- Add actions like:
-
Save the listener and test.
That listener fires the moment Damage changes, so you can start/stop whatever timer youâre using from there. The docs for this listener (and the $$new_value variable it exposes) are here: Listeners doc, On Variable Updated section.
Okay. I made a listener "on value updated". I don't have something like variable name to watch, I can only add actions or remove a listener
When you create the âOn Variable Updated [FM Variable]â listener, thereâs a small settings panel before the action list where you enter the variable name it should watch. If you already created the listener, just open it again and look at the top of that screenâit should show a field labeled âVariable Name to Watchâ (it might default to variable). Replace it with Damage.
If you canât find that field, close the listener and create a new one:
Customization â Manage Listeners â New Listener- Pick On Variable Updated [FM Variable]
- Right after picking it, the UI should show the âVariable Name to Watchâ inputâtype
Damagethere before adding any actions. - Then add your
IFaction / tick logic inside the action script.
Once thatâs set, the listener will fire whenever Damage changes. You can use the provided placeholder $$new_value inside your requirement to check whether it was set to true before starting the timer.
I don't have something like this
If the âVariable Name to Watchâ input never showed up, it probably got skipped when you created the listener. The field only appears immediately after you pick On Variable Updated [FM Variable] in the âNew Listenerâ dialogâbefore you add any actions. You canât edit it later, so the easiest fix is to:
- Delete the listener you just created.
- Click New Listener â On Variable Updated [FM Variable].
- In the very first screen that appears, type
Damageinto the âVariable Name to Watchâ field (thatâs the one you were looking for). - Then continue to add your action script (IF with
$$new_value, etc.).
If you still donât see that field, it might be scrolled off-screenâmake sure you scroll up while the listener dialog is open.
For reference, hereâs the listener doc section: Listeners (look for âOn Variable Updatedâ).
very first screen after I create it is "add actions" one... I Checked twice, there's NOTHING like variable name to watch there
Ah, I get itâSpiffyHUDâs dialog is a bit weird. When you hit New Listener â On Variable Updated [FM Variable], the first screen should have the âVariable Name to Watchâ field at the top before you ever add an action. Itâs easy to miss if you immediately click âAdd Actionâ because the UI scrolls down.
So try this:
- Open Manage Listeners and delete that listener.
- Click New Listener â On Variable Updated [FM Variable].
- Without clicking âAdd Actionâ yet, look at the top of the new listener screenâthereâs a text box labeled âVariable Name to Watchâ. Type
Damagethere. - Now you can scroll down and add your action script (the IF checking
$$new_valueetc.).
If you still donât see the field, it might be scrolled out of view. Scroll upâor resize the windowâbefore clicking âAdd Actionâ. Once the variable name is set there, it canât be changed later, so make sure itâs correct before adding actions.
Let me know if the field really isnât showing even before you add actions and Iâll figure out another workaround.
@jolly ether paused AI answers for this thread. The bot will stay quiet until resumed.
đ | image change when player takes damage
<@&1365490168563372113>
@jolly ether has requested human assistance.
A human moderator will help you as soon as possible. In the meantime, you can continue asking questions to the AI support bot if you'd like.
The support team has been notified.
...I give up, I think bot is too far gone 