If statements in a variable/module script?

I wanna check a bunch of statements, for example:

if stunned = true and running = false and db = false and iframes = false and endlag = false and punching = true

and just put it in a single variable that I can re-use across multiple scripts, like so:

statements = {
stunned = true
running = false
db = false
iframes = false
endlag = false
punching = true
}

is there any way to do something like this?

(UPDATE: I figured out a good way to organize the statements for anyone that wants to know.)

statements = {
	lightcombo = Values.Combos.LightCombo,
	stunned = Values.Status.Stunned,
	endlag = Values.Status.Endlag,
	iframes = Values.Status.IFrames,
	dashing = Values.Status.Dashing
}

if statements.lightcombo.Value == true and 
	statements.stunned.Value ~= true and 
	statements.endlag.Value ~= true
then

*run script*
1 Like

I actually have a game just like this where I have to check A LOT of variables constantly. I personally don’t think there’s any other way, like using loops, that would probably make the code longer and slower, too.

You should just stick with what you have. Try using some indents to organize it further, or put your evaluation into another variable and then pass that variable into the if statement.

2 Likes

So say I need to check the same statements just with different answers across a bunch of scripts, I just have to copy and paste them and change the answer?

Yes, because the time and location to reference them may be different. I don’t see any other way.

Unless you put them all into a folder, and have an external script update them, and simultaneously check if they are all the desired values, then update ANOTHER value (isTrue) based on that case.

This way you could simply put:

if isTrue.Value then

Just an idea, you can try it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.