how do i make a procedure run once when a item is picked up?

Started by thecutegard on

Topic category: General discussion

Last seen on 21:05, 9. Oct 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how do i make a procedure run once when a item is picked up?

i have a procedure that congratulates a player when they get a item. how can i make it only run on the first time they pickup the item?

Last seen on 10:38, 22. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Add a player-persistent…
Sat, 10/07/2023 - 18:24

Add a player-persistent logic variable that defaults to true, (there's a 'variables' tab in your workspace). Then, make a procedure with the 'when entity picks up item' global trigger. Use an if bracket to check if that entity is a player, and, if they are, then checks if the variable is true. Inside the bracket, congratulate the player, and set the variable to false. As long as the variable is player-persistent, (that is, it doesn't reset on death), the player will only be congratulated the first time they pick up the item.

Last seen on 21:05, 9. Oct 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how do i detect if the…
Mon, 10/09/2023 - 19:02

how do i detect if the entity is player?

Last seen on 10:38, 22. Apr 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Use an 'if' bracket. Then,…
Mon, 10/09/2023 - 19:07

Use an 'if' bracket. Then, look in the logic tab, and use the 'is entity subtype of...' function. If the event/target entity that picked up the item is a subtype of 'player,' you know the entity is a player. (This way if mobs pick stuff up it doesn't try to give them advancements.) 

You'll need more than one if statement, or one if statement and some 'and' conditions. You need to check if the entity is a player, if the provided item is your custom item, and if the player's variable is still false.