Minecraft Maps / Educational

[1.12.1] Mcfunction conditional roundabout

  • 801 views, 1 today
  • 2
  • 1
RobhieMattz's Avatar RobhieMattz
Level 26 : Expert Engineer
46
Hi this is a sample of code I learned from my research earlier. I asked myself why not share it you guys as well just in case you're facing the same problem I did.

Some stuffs to remember before reading the code:
  • Anything with # in the start of the line will not work (It's mainly used for comments)
  • I added 2 different methods to suit what you need
  • The commands below are mcfunction ready (It means you can copy paste it right away to see how it works)
  • I added important comments for each line to help you out on understanding it
  • I learned this from a certain youtube video. Kudos to the author: https://www.youtube.com/watch?v=-2F0_w3E8Us&t=107s

###################################################
#Make a dummy objective for stats #This is outside of the function

#/scoreboard objectives add Success dummy

#enable the stats by setting the objective to 0, If this objective doesn't have any value then it won't update
scoreboard players set @a Success 0

#enable the /stats to the entity you want in this case @a everyone
execute @a ~ ~ ~ /stats entity @s set SuccessCount @s Success

#put conditional event here including your target
execute @a testfor ~ ~ ~

#if the above condition is met then you may target them
say @a[score_Success=1,score_Success_min=1] made it work!

###################################################
#To make it one time event (impulse) then just add some tags here's an example:

#Make a dummy objective for stats #This is outside of the function
#/scoreboard objectives add Success dummy

#enable the stats by setting the objective to 0, If this objective doesn't have any value then it won't update
scoreboard players set @a[tag=!loop] Success 0

#enable the /stats to the entity you want in this case @a everyone
execute @a[tag=!loop] ~ ~ ~ /stats entity @s[tag=!loop] set SuccessCount @s[tag=!loop] Success

#put conditional event here including your target
execute @a[tag=!loop] testfor ~ ~ ~

#if the above condition is met then you may target them
say @a[score_Success=1,score_Success_min=1,tag=!loop] made it work!

#the loop killer
execute @a[score_Success=1,score_Success_min=1,tag=!loop] ~ ~ ~ /scoreboard players tag @s add loop

#to renable the loop just do this manually
#/scoreboard players tag @a remove loop
###################################################


Tell me if you have better solution by commenting below, Or leave some diamond if you like the tutorial
Credithttps://www.youtube.com/watch?v=-2F0_w3E8Us&t=107s
Progress100% complete
Tags

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome