Closed Paracosm-Daemon closed 3 weeks ago
Hi, this is intentional. The Powerlang compiler has no clue by itself what value a variable might have, and it relies on the RetroStudio runtime to determine that. As the and
keyword directly translates to the AND block, it's up to RetroStudio to handle that.
A workaround for this is to use two nested IF directives. If this feature is heavily requested by other members of the community, I might re-implement the way logic gates are handled.
As the
and
keyword directly translates to the AND block, it's up to RetroStudio to handle that.
Noted! If it's not mentioned in the docs, I would prefer it is as this is a direct contradiction to how these conditions work in Lua
Unlike most programming languages, using
and
in anif
statement will cause an error to be thrown if the second part of the operator relies on the first. As an example, here is the bug I encountered while cleaning up connections:01:59:14 - Game.Players.Paracosm_Daemon.PlayerGui.JointEditor.$Runtime.PowerlangImported:instop-471: Expected event, got table
I traced this error back to this particular
if
statement:Originally, I chalked this up to an error in how RetroStudio handles
nil
values, but when I looked closer, I realized that both conditions were being checked at once, despite the rig connection not being of the typeRBXScriptConnection
, thus causing this exception to pop up.This is likely also the case for
or
, where both sides will be compiled simultaneously, rather than going in order of which is the last condition to check. This distinction is very important, given it can complicate seemingly basic code, e.g the following: