Started by
thecutegard
on
Topic category: General discussion
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?
Topic category: General discussion
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?
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.
how do i detect if the entity is player?
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.