Feature request | Switch function and operators in if statements

My code gets really lengthy just for checking if the player is on a certain tile, and I need to repeat this in a lot of room and it gets hard to read and maintain.

If possible it would help to be able to use and/or operators in IF statements:

if (varA==0) or (varA==1 and varB==3) then

and also have a switch funtion to test multiple values (useful for branching dialogues):

Switch var
0 : do this
1 : do that

A quick solution would be to allow LUA code snippets, it would also be the most powerful and easiest to use(probably)

As a workaround in some situations you might be able to assign a new variable with string formatting of your other variables and then do one conditional against that. An example:

combined = "{varA}{varB}{varC}"
if combined=="013" then
  // do whatever
end
3 Likes

Wow! Thank you!
I guess this works for "and" operators but not for "or" right?

Though for booleans the following would be an OR operator probably...
if combined>0
Oh no this is a string (>_<

Right, it only really works as an "and".

For booleans specifically you can do an "or" by summing the booleans like:

sum = bool1
sum += bool2
sum += bool3
if sum>0 then
  // do something
end

which I think is where you were going with that!

1 Like

Wow wonderful! It helps a bunch!!! It will shorten my code so much, trying it right away!