Need help making code with if and return functions.

Started by Onyx12133 on

Topic category: Help with Minecraft modding (Java Edition)

Active 3 years ago
Joined Oct 2021
Points:
553

User statistics:

  • Modifications: 0
  • Forum topics: 7
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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
Active 1 year ago
Joined Oct 2020
Points:
1618

User statistics:

  • Modifications: 0
  • Forum topics: 15
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1874
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 

Active 3 years ago
Joined Oct 2021
Points:
553

User statistics:

  • Modifications: 0
  • Forum topics: 7
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
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?

Active 1 year ago
Joined Oct 2020
Points:
1618

User statistics:

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

if event target entity has advancement unlocked = ADV

 do return true

return false

Active 1 year ago
Joined Aug 2022
Points:
411

User statistics:

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

Huh??

Active 1 year ago
Joined Aug 2022
Points:
411

User statistics:

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

That just returns false 

Active 3 hours ago
Joined Apr 2023
Points:
678

User statistics:

  • Modifications: 4
  • Forum topics: 23
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 545
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.

Active 1 year ago
Joined Aug 2022
Points:
411

User statistics:

  • Modifications: 0
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 21
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