Started by
Brilliant Moves
on
Topic category: Help with modding (Java Edition)
Want to make a variable increase when the player kills a certain mob. to do this i have set up a variable as number and GLOBAL_MAP. i set this precedure for when the entity dies: https://imgur.com/58Y2olm. it doesnt work. help?
For one thing, you do not want a GLOBAL_MAP variable, you want a Player Persistant variable. A global variable is permanent for the entire world; meaning in multiplayer, the variable would increase whenever any player killed a mob. You have the right idea though!
The imgur link is broken, but I assume the problem either has to deal with the trigger or the way you're incrementing the variable.
For the trigger, you want to use 'When Entity dies' as the global trigger, and then check if the source entity, (the one who killed the event/target entity), is a player. You could also check that the event/target entity, (the dead one), is of a desired type or tag, so the player can't just repeatedly 'kill' a boat or armor stand to increase the variable. You want to use the global tag, as I'm not totally sure the 'entity dies' procedure trigger provides a source entity.
Then, just make sure when you're incrementing the variable, you're setting the variable to itself plus one, not just one, or it won't ever increase. MCreator doesn't have a dedicated += function, so you wanna keep that in mind when doing variable stuff.