✅ Is there a way to add if statements and bools in a class?
is there a way or do i have to work around it?
16 Replies
What do you mean
$details
When you ask a question, make sure you include as much detail as possible. Such as code, the issue you are facing, and what you expect the result to be. Upload code here https://paste.mod.gg/ (see $code for more information on how to paste your code)
ok lets say we have a class
and there is a an int array wich can be turned off and on
What do you mean "turned off and on"
The class either has an array field/property, or it does not have that property
You can't toggle it
like interactable and not interactable
is there a way to add a new property by an if statement?
So... some sort of
?
No
As I said, a class either has the property, or it does not have this property
A car has a wheel count
A ceiling fan does not have a wheel count
Properties describe... the properties of the object
An object either has a given property, or it does not
There's nothing to be conditional here
btw do you wanna kow what im actually doing and why i am asking?
know
Sure, it does seem like an XY issue
basically im making a prototype script for operations of firearms
like if its open bolt
or auto or semi
an array for magazine(catridge)
Ah, then you would use inheritance
also some operation have a chamber and some dont(i want make it possible to turn it off or on)
That way, a
FullAutoGun
and a BoltActionGun
can have different properties
While still sharing some common properties of Gun
thanks
$close
Use the /close command to mark a forum thread as answered
You could do it with a constructor in the for the variable you wanted to toggle.
But inheritance is definitely the way to go.