I need help with repeating a procedure

Started by varuniemcfruity on

Topic category: Help with MCreator software

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I need help with repeating a procedure

So I’m making a procedure where when you eat a food and you touch lava, you get fire resistance, and I got it working so that if you eat the food WHILE in lava you get fire resitance, but I wanted it so if you eat the food and then go in lava you get fire resistance, and if you leave, your fire resistance gets removed, basically if you go in lava you get fire resistance and if you leave it gets removed. I think I can do this if I find a way to repeat my procedure. How do i do this?

Last seen on 18:32, 15. Apr 2023
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I found out you can use…
Sat, 04/08/2023 - 03:28

I found out you can use while true do to do make it loop, but everytime I eat the food my game crashes. How do I fix this?

Last seen on 12:31, 22. Jan 2024
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i think that if you…
Thu, 05/25/2023 - 19:37

i think that if you constantly repeat the code to check for whether you're in lava, that might create too much unnecessary lag

here are two workarounds you could use:

1. create a status effect that is applied when the player eats the food. for every tick that the status effect is active, use a procedure to check if the player is in lava. if the player is in lava, remove the status effect and add fire resistance.

2. create a variable that's stored in the player (on the left side of your workspace, click on the "variables" tab, then click "add new variable", then make a new variable with the type "player_lifetime".) set this variable to true once the player eats the food (the procedure block is found in the entity section, set entity variable to etc), then when the player goes into lava, detect if the variable is true, and if so, apply fire resistance and set the variable to false. what this does is basically the variable is true if and only if the player has already eaten the food, but has not entered lava yet.

there are plenty other ways to solve this, but this is all i have so far

you can let me know if something goes wrong, but it's nice to try solving the problem on your own first because it will help you solve problems in the future