# Executing if text reads 1 or more / Removing one from a number that is stored as text

**URL:** <https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [May 11, 2024, 12:12am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392 "2024-05-11T00:12:16Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 11, 2024, 12:12am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/1 "2024-05-11T00:12:17Z")

</div>

Hi all, I want to create a condition where a text box contains a number of items collected. The condition is to execute the function IF the number in this text box is 1 or more. I then want to remove one from that number after the function has executed. Is this how I would do this?

 ![HasOneOrMore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/3/283ba3fac8dd3bcc8df64b4968128b0a550ad511.png)  
 ![RemoveOne](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/1/6/616b77001356a8aeaf3869da9b28ac33a792355d.png)

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 11, 2024, 1:15am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/2 "2024-05-11T01:15:46Z")

</div>

Hey @JasonDiesALot!

You should be able to just use that code above and work it into the “X” pressed.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/e/2/de241fb4640f026ee610ab723a89b3e08b40d2b0.jpeg)

Let us know if we can help further! 🙂

---

<div class="post-metadata">

**Author:** ![jwatte](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jwatte/32/744941_2.png) [@jwatte](https://forums.unrealengine.com/u/jwatte)\
**Post date:** [May 11, 2024, 2:30am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/3 "2024-05-11T02:30:23Z")

</div>

A much better way to do this, is to store the number of items collected as an integer, and convert to string only for display.

---

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 11, 2024, 3:37am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/4 "2024-05-11T03:37:44Z")

</div>

So, this is how I’m deriving the number in the text box - I’m just not sure how to get it from this calculation to a number I can use in the example. There are probably much better ways of doing this, but this is my workaround as no inventory tutorials I tried worked for what I was trying to do.

 ![CalculateItems](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/c/27cc0b07b07f1ba77967fd07ed73f1eb1fb46d42.png)

---

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 11, 2024, 3:38am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/5 "2024-05-11T03:38:53Z")

</div>

Thank you - could you possibly elaborate?

---

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 11, 2024, 3:51am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/6 "2024-05-11T03:51:20Z")

</div>

Also, while this works, I need to have **two** items before it works, AND I have to press X twice as well, which makes no sense to me.

 ![TwoApplesWhy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/6/a/a6a8e2a2c05827a479bfb15c5690b48225fc2e46.png)

---

<div class="post-metadata">

**Author:** ![Mind-Brain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mind-brain/32/906573_2.png) [@Mind-Brain](https://forums.unrealengine.com/u/Mind-Brain)\
**Post date:** [May 13, 2024, 5:27pm UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/7 "2024-05-13T17:27:21Z")

</div>

Hey, @JasonDiesALot, Sorry for the late reply.

Okay you’ve made some good moves here. We need to know the rest of the code to figure out why one is not removed, though. There’s no code shown for that.

But I will say that with the current setup of your “Get Apple Count Text” you’re never going to see it go down with the code you have. It only actively uses THAT total, no matter what you do to it, because it is bound to “Total items minus items left.” The only way I could see this being added to would be "Health Boost Total Items - Health Boost Items Left - _Health Boost Items Used_ and then have a third variable for that on the game mode, which you would then “++” on the heal code.

You can also just remove those variables and have an integer for “Apples” that goes “++” when you pick one up and “-1” when you use one. Whatever you change it to, the HUD should update. 🙂

---

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 15, 2024, 4:24am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/8 "2024-05-15T04:24:24Z")

</div>

Thanks for coming back to me. I’ve tried a few things and I’m not sure exactly how to do this. I can see why the way I’m deriving the count isn’t going to work. Duh.

I tried creating a variable that would hold the value of the items as an integer, but I don’t think I’ve done it right, as I can pick it up, but it doesn’t count up on the HUD.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/7/e675315b5382e77dec4f0b7d06d560208e085d98.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/2/7f23398623d8220e46e29d242500d2a28220b434.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/0/8/7087953d2e87b08b13f1ca0536750c14bfc81b35.jpeg)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/2/6/226c4266c5091ad37d2e31a2b1e050a6348121eb.jpeg)

---

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 19, 2024, 4:08am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/9 "2024-05-19T04:08:15Z")

</div>

So, I figured out how to make most of it work after a bit of head scratching. The only issue I have left now is that when I add a condition ‘if holding 1 or more’, I get an error that says I’m holding none, even though I’m holding several. This is how I’m setting the variables in the game mode, but I’m getting errors saying ‘accessed none’ on each of these variables I’ve created.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/3/1/f3113cec2dbee394bae546da48517a0fa95228fc.png)

I then get an error on the character blueprint for the gamemode ref itself. Will keep working on this, but if anyone has any thoughts, appreciate it.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/b/d/5bd5d5c9013a016240764bfa3bd17abeb26b3c87.png)

---

<div class="post-metadata">

**Author:** ![JasonDiesALot](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonDiesALot](https://forums.unrealengine.com/u/JasonDiesALot)\
**Post date:** [May 19, 2024, 4:12am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/10 "2024-05-19T04:12:53Z")

</div>

Okay, solved that too. It’s probably a messy af solution, but cast to the game instance for the condition and it all now works as expected. 🙂

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/4/a/14aaed2b24538806f992f6999336608af1fdbcef.png)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 18, 2024, 4:13am UTC](https://forums.unrealengine.com/t/executing-if-text-reads-1-or-more-removing-one-from-a-number-that-is-stored-as-text/1850392/11 "2024-06-18T04:13:28Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
