# Trying to count steps for a hidden food stat.

#### tomexplodes

##### Veteran
I'm going for an Ultima VII style food system, where over time (or steps in this case) your character's food bar, which isn't shown, will degrade. At certain intervals, say 75/50/25% of the food value, your character will remark that they are peckish/hungry/famished/starving/whatever.

I'm having real trouble getting this going because I can't figure out how to count steps with a common event, or at all. Know that I have some experience with this program, but I also have MS so sometimes simple stuff goes over my head. I'm looking for a very straightforward explanation of what I need to do to implement this system. Sorry, that sounded demanding, I totally didn't mean it to! If anyone has the time/inclination to help, I'd super appreciate it! Thanks in advance,

#### Andar

##### Veteran
control variable - game data gives you access to a lot of different numbers, and one of them is the number of steps taken since game start.

then you just use the modulo operation on the current number of steps to decide if you need to reduce food or not (a conditional branch with steps modulo 30 = 0 would be true every 30 steps for example).

#### tomexplodes

##### Veteran
I'm very sorry, could you sort of type it to me in game terms so I know where/what to reference? I have trouble with this stuff, I'm super sorry about that. (EDIT: Probably makes you wonder why I'm trying to use complicated formulas for things if I can't even grasp basic concepts right away, haha)
control variable - game data gives you access to a lot of different numbers, and one of them is the number of steps taken since game start.

then you just use the modulo operation on the current number of steps to decide if you need to reduce food or not (a conditional branch with steps modulo 30 = 0 would be true every 30 steps for example).

I should also elaborate on what I fully want to happen.

Food starts at 100. Every, say, 15 steps, it ticks down by 1. At 75%, the character says they are feeling peckish. At 50%, they say they are hungry. At 25%, they say they are famished. At 10 or 15%, they say they're starving. And at 0, I want to start ticking down their health by one point, once the food bar runs out. Also some sort of indicator that they're taking damage would be nice. I'm beating my head against the program trying to accomplish this. I even tried Frog's health plugin, but somehow it broke combat for me, and I want the calculations to happen in the background anyway.

EDIT AGAIN: Also if it's possible for them to remark this without stopping the game with a text box, that'd be cool, but isn't a necessity by any means.

Last edited:

#### Trihan

##### Speedy Scripter
I'm very sorry, could you sort of type it to me in game terms so I know where/what to reference? I have trouble with this stuff, I'm super sorry about that. (EDIT: Probably makes you wonder why I'm trying to use complicated formulas for things if I can't even grasp basic concepts right away, haha)

I should also elaborate on what I fully want to happen.

Food starts at 100. Every, say, 15 steps, it ticks down by 1. At 75%, the character says they are feeling peckish. At 50%, they say they are hungry. At 25%, they say they are famished. At 10 or 15%, they say they're starving. And at 0, I want to start ticking down their health by one point, once the food bar runs out. Also some sort of indicator that they're taking damage would be nice. I'm beating my head against the program trying to accomplish this. I even tried Frog's health plugin, but somehow it broke combat for me, and I want the calculations to happen in the background anyway.

EDIT AGAIN: Also if it's possible for them to remark this without stopping the game with a text box, that'd be cool, but isn't a necessity by any means.

If you have access to the YEP plugins, you can use Gab Window to have the message "in the background" and not require player input.

#### tomexplodes

##### Veteran
Thank you very much! This works, unfortunately every 15 steps I get a message, I only wanted the amount to go down by 1 for every 15 steps, not 25. How do I fix this?

EDIT: I mean that I want it to count down 1 from 100 every 15 steps, but at this point it seems to count down 25 every 15 steps. Sorry, just wanted to clarify.

I also added the bottom line there, to keep it from going over 100. Will that work? And the other picture is a common event called by a Bread item to replenish health. Will that also work?

#### Attachments

• 1.png
104.1 KB · Views: 3
• 2.png
87 KB · Views: 3
Last edited:

#### Trihan

##### Speedy Scripter
Thank you very much! This works, unfortunately every 15 steps I get a message, I only wanted the amount to go down by 1 for every 15 steps, not 25. How do I fix this?

EDIT: I mean that I want it to count down 1 from 100 every 15 steps, but at this point it seems to count down 25 every 15 steps. Sorry, just wanted to clarify.

I also added the bottom line there, to keep it from going over 100. Will that work? And the other picture is a common event called by a Bread item to replenish health. Will that also work?
Doh! Sorry about that. I put the update to last steps in the wrong place. There should just be a single set for it after deducting 1 from food, you can take the other ones out.

The bread event should work fine; technically so will the food = 100 check, but...why put that in a parallel process event in the first place? Nothing is automatically *raising* food, so you only really need to check its value going above 100 in cases where the player has actively raised it.

Last edited:

#### tomexplodes

##### Veteran
Doh! Sorry about that. I put the update to last steps in the wrong place. There should just be a single set for it after deducting 1 from food, you can take the other ones out.

The bread event should work fine; technically so will the food = 100 check, but...why put that in a parallel process event in the first place? Nothing is automatically *raising* food, so you only really need to check its value going above 100 in cases where the player has actively raised it.
Oh, duh. I was just going whole hog on it, but you're right! As long as I put the same check in every food item, it'll be fine. Thanks! One other thing, the screen goes red, it doesn't go away, and very shortly thereafter I die. Have I done something incorrectly? Everything else works great after the alteration, though. I can't thank you enough for doing this for me, it's fantastic. You're my hero.

#### Trihan

##### Speedy Scripter
Oh, duh. I was just going whole hog on it, but you're right! As long as I put the same check in every food item, it'll be fine. Thanks! One other thing, the screen goes red, it doesn't go away, and very shortly thereafter I die. Have I done something incorrectly? Everything else works great after the alteration, though. I can't thank you enough for doing this for me, it's fantastic. You're my hero.
Yeah, we needed to have the last step setting after the other branches, my bad. Here's how it should look.

Last edited:

#### tomexplodes

##### Veteran
Perfect! Thanks so much!
EDIT: I changed it to 1 step just to go through the whole shebang quickly and make sure it worked right, and it does.

#### Trihan

##### Speedy Scripter
Haha I did the same thing.

I had considered doing a lot more of this with script to save on conditional branch requirements, but I figured that might make it a bit too complex for you to follow and that would kind of defeat the purpose of the exercise.

#### tomexplodes

##### Veteran
Well thank you so much for doing this, and in a way that I can look at everything and understand how it works together. It'll take me awhile, but in the long run, I'm learning something. Super appreciated.

#### tomexplodes

##### Veteran
EDIT: Crap, didn't realize this was a double post. It won't happen again!

So I have another related question about it for you! I'd like to make it so when you rest, you lose an amount of your food bar. That's easy enough to do, no problem there. The problem is, if you fall below one of the indicator numbers, the game doesn't tell you where you're at on that scale. Do you know any way to adjust it so it'll give you a one time announcement if you're in between two of the prompts on the scale?
Haha I did the same thing.

I had considered doing a lot more of this with script to save on conditional branch requirements, but I figured that might make it a bit too complex for you to follow and that would kind of defeat the purpose of the exercise.

#### Trihan

##### Speedy Scripter
Why not just put a similar check in the rest event to the one in the common event?

#### tomexplodes

##### Veteran
I tried that, but I don't appear to have done it right. Here's a picture of the event:
Why not just put a similar check in the rest event to the one in the common event?

It'll tell me I'm feeling peckish the first time, but if I then rent the room again, I don't get another message telling me I'm the next one down, UNTIL it gets past that step to the next one by walking around more, from the common event. So I've obviously done SOMETHING wrong.

#### Trihan

##### Speedy Scripter
Well let's run through it. Let's say food is currently at 80. Staying at the inn reduces it by 35, so we're on 45.

If food < 76 is true, so we go into that branch. It's not > 50 though, so now...nothing, because that branch doesn't have an else.

I think you may have nested your elses a level too far out.

#### tomexplodes

##### Veteran
Well let's run through it. Let's say food is currently at 80. Staying at the inn reduces it by 35, so we're on 45.

If food < 76 is true, so we go into that branch. It's not > 50 though, so now...nothing, because that branch doesn't have an else.

I think you may have nested your elses a level too far out.

Yup! That was it! And I understand why, you're a very good teacher here. Thanks again!

### Latest Profile Posts

Manafinder got featured in an Upcoming Indie RPGs video alongside other great RPG Maker (and not RPG Maker) games!

Hey bro, hmu if you're around...I really need your help. >.<
Working hard to keep master @ImaginaryVillain 's sparkles on stock!

Hopefully this will please him enough to give us our beds back...
My mom is finally coming home tonight! In the meantime, Wishful Wanda is back in production.
Zombie is not the only thing people turned into in this town. There is also something else here. Something has many different names in history, the plague, the black oil, the purity, the filth. And now, it's called the shade.
(Maybe too much X-File reference. )

113,620
Messages
1,076,266
Members
147,632
Latest member
lfxfire2