"If" and "Return" doesn't work together... and that messes up any specific triggering to overlays

Started by Toma400 on

Topic category: Help with modding (Java Edition)

"If" and "Return" doesn't work together... and that messes up any specific triggering to overlays
Tue, 04/27/2021 - 09:47 (edited)

Hello,

Today I updated MCreator from 2020.3 to 2020.5, and after that I finally saw why I had bug of everlasting overlay in my mod - overlays, previously triggered by its own set of triggers, now supports only procedures. Which is great, but...

I see no way of returning "true" value with any "if" conditions. Let's say that, for example, I want to add potion (I used that for overlay durations) and trigger overlay only when potion is active, I have to place return block AFTER "if" condition.
From my small programming knowledge, it means that "if" won't be used, and procedure will be still everlastingly returning "true" value.

Maybe it's weird and tiring month for me, so I don't see obvious ways to solve this due to my messed up brain.
Or maybe it's indeed that kind of thing, which changed from extremely easy, to something requiring more brain cells than I actually have :D

Anyway, I would be so grateful if someone explains me that.


[dunno]

(don't mind "on player tick update" trigger, it's exactly the same no matter if it's empty or if it has something - there's still that warning/error on bottom, solved only with adding "return" after "if")

Edited by Toma400 on Tue, 04/27/2021 - 09:47
I just wrote that I have to…
Tue, 04/27/2021 - 11:48

I just wrote that I have to add another return block for procedure to work - but that mean returning "true" always, from what I understand... :c and I need it to return "true" only when potion is active

Tried to do that with else, but error was still there

I found the solution though; but it's really annoying that instead of simple trigger from 2020.3, newer versions requires additional ~3 separate procedures for that (and as I use two overlays for player messaging, that means 5 new procedures).

What I found is that you need to make global variable "player_persistent", with default value of false.
Then, anytime you start potion effect, you need to change it to true - and also everytime potion effect expires, you need to change it back to false (2 separate procedures, with potion triggers).
Therefore you can use another procedure, bond with overlay this time, returning the value of global variable, therefore no "if" is needed:

[2020.5, weird]

I hope that helps anyone who come across this topic.