Need help making code with if and return functions.

Started by Onyx12133 on

Topic category: Help with modding (Java Edition)

Last seen on 00:48, 15. Nov 2021
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
Last seen on 04:28, 26. Jan 2024
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 

Last seen on 00:48, 15. Nov 2021
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?

Last seen on 04:28, 26. Jan 2024
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

Last seen on 11:11, 6. Jul 2023
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Huh??
Sun, 07/02/2023 - 16:03

Huh??

Last seen on 11:11, 6. Jul 2023
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 

Last seen on 12:45, 25. Apr 2024
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.

Last seen on 11:11, 6. Jul 2023
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