Manual IF statements
![InLaNoche](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I am new to GCS (and using the Windows version), but not new to programing. I am currently working on a shooter type project, and was trying to manage the angle of my "homing" missles so they could not turn more that a set angle. Well I got it locked down, but didn't like the way I had to do it. First off, I cannot compare 2 equations without having to create an attribute (that I know of, stop me here and tell me how that is done and I'll be happy). It seems that the first part of the IF has to be an Attribute. In this first case that is fine since having an Attribute(variable) for a setting is not a bad idea. But I'm sure I am going to run into this more in the future.
Is there a way to manually enter the code for an IF statement?
Is there a way to manually enter the code for an IF statement?
Comments
In addition, there are many built in properties for actors like the missile that allow you to read or evaluate the angle, velocity, position, rotation speed, and so on. Use them when you can.
Perhaps if you can explain the specific problem with this example and suggestions can be made.
@InLaNoche
I'm not totally sure what you're asking for but for certain an IF statement is exactly the same as the When rule in GSC.
And you can compare attributes with it too:
When variableA =VariableB --- or doesn't equal to, or is less or more than
---do your stuff
Is that what you're after?
PS Maybe you also mean how to "switch on" an IF statement while running:
use a boolean as a toggle, so
When Switch is true
When variableA =VariableB --- or doesn't equal to, or is less or more than
---do your stuff
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Everything in the Rules in GSC is a sort of object-oriented programming with nice coding "chunks" already made for you (the Behaviours), easily used via drag and drop. THis is how GSC works and this aspect is what makes it so elegant, in my opinion; I guess there is a bit of "translation" required if you're used to actual coding in another programming environment.
The IF statement (When Rule) doesn't have to be tied to an attribute, it can be used for actor receiving events: mouse, touch, collide or keyboard. You don't necessarily need to use a When Rule at all either; just drag out a Behaviour, maybe tied in with a Timer.
I'm not sure why you have an aversion to attributes, they're only variables after all. So your example self.V1 - self.Delta1 < 35 is no problem in the When/If Rule, utilising your attributes (variables) V1 and Delta1 that you would have made.
Don't know what your previous programming environment was, but for certain, if you know anything about any of the BASIC programming environments, you'll get to grips with the way GSC ruling works in no time.
Here's an answer I gave to something similar which might help you:
http://forums.gamesalad.com/discussion/comment/332363/#Comment_332363
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Glad you've come to a sort of a compromise that works.
I'm certain it'll be no time at all for when your "Coding brain" suddenly clicks to the "Ruling brain" without any translation. And I'm sure you'll discover soon that as relatively simple GSC is to program via Rules and Behaviours, it has hidden depth and can be surprising as to what it can be made to do! Best of luck with all your future apps. :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps