Manual IF statements

InLaNocheInLaNoche Member Posts: 20
edited July 2012 in Working with GS (Mac)
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?

Comments

  • heathccheathcc Member Posts: 113
    Currently, you can only leverage the expression editor to build logic checks with Rules. You should be able to add a Rule with multiple checks against a value/attribute/event as well as nest them.

    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.
  • tabelortabelor Member Posts: 114
    hey guys sorry to post here this but the hole forum have changed since the last time i've entered (two months ago) and now i can't open a thread. Anyone can help please? thanks and sorrry again
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited July 2012

    @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

  • InLaNocheInLaNoche Member Posts: 20
    edited July 2012
    What I am looking for is an IF statement that is not directly tied to an attribute. To create (as I have found so far) an IF statement, the first element of the IF must be an Attribute. Kind of a constraint, but worse, I cannot make an equaiton on that site (such as self.V1 - self.Delta1 < 35. Yes I can put the 35 on the other side, but it must be stored in an Attribute. Just never ran into this kind of constraint before. Also, even though the interface is nice, it would be great to just be able to type the command you want... I have coded in several other languges before, but this is new to me... The spaces say you can type a command, but I have yet to get it to work...
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited July 2012

    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

  • InLaNocheInLaNoche Member Posts: 20
    I can deal with it. I guess I just have to be more flexable with how I want my conditions worked out. I ran into a problem when I wanted to do an equation on the left side, but I can just reverse the > to a < and swap the hard number to the left (and it can be made an attribute), and have the equation on the right. To me it's just a constraint on my initial idea of the code, which slows me down a bit... Not a game breaker. Thanks.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    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

Sign In or Register to comment.