Need help making code with if and return functions.

Started by Onyx12133 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Need help making code with if and return functions.
Sun, 10/31/2021 - 20:09 (edited)

I'm trying to make a procedure that returns true if a they have completed a specific advancement and have it return false if they haven't, but I can't save the code because of an error. The error states that "Procedure that uses return value must always end with a valid return block." Does anyone know how I can use an if else statement and return at the same time?

My code so far is:

Event trigger- Player joins world

If Has target entity completed achievement: (Custom advancement)

Do: Return (True)

Else: Return (False)

Edited by Onyx12133 on Sun, 10/31/2021 - 20:09
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
don't put else, just put it…
Sun, 10/31/2021 - 20:51

don't put else, just put it outside of the if statement 

Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If I do that then it always…
Sun, 10/31/2021 - 21:18

If I do that then it always returns false, do you know how I could code it so if they have unlocked the advancement it returns true?

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if event target entity has…
Sun, 10/31/2021 - 21:59

if event target entity has advancement unlocked = ADV

 do return true

return false

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That just returns false 
Sun, 07/02/2023 - 16:05

That just returns false 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
no, if it returns anything,…
Sun, 07/02/2023 - 16:33

no, if it returns anything, it will stop the procedure and therefore will not get to return:false, in other words:

If true

do return true

return false

 

will result in return true, switch out the true in if and it will only return true if your condition is met.

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Aaah okay, but for some…
Sun, 07/02/2023 - 19:44

Aaah okay, but for some reason my overlay is not showing up.. i cant figure out the problem