User Tag List

Results 1 to 8 of 8

Thread: How to do a "else"-statement?

  1. #1
    Clicker Fusion 2.5Android Export Module
    salmjak's Avatar
    Join Date
    Feb 2014
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to do a "else"-statement?

    So, I'm having this situation where I want my AI to either go left OR right (depending on which direction the AI is pointed at) when standing on the ground and not moving (both these conditions are handled by the "platform movement object"). I also add a "random condition" - 1 chance out of 2 random, this should mean 50% chance right?
    At the actions I make it move in the opposite direction by the "user input right/left key" aswell as changing the direction of the object to the appropriate one.

    The problem is, doing it the way below just make it wiggle back and forth about 1 pixel, so I think the only way I can solve this is by having an "else" statement at the "randomization"-part (50% chance at one action, otherwise, do the other).
    It should work anyway since I specify the direction, but when I don't have any probability added it just stands still. What I think is happening is that it switches back and forth between the two events because the direction change of the object is more instant that the moving is.

    Anyhow, it would be handy to know how to make something that resembles an "else"-statement in coding!

    This is how it looks:


    EDIT: I do realize the simplest "else"-statement is just have two events and one of them negated. But some conditions can't be negated. And I'm more curious in having an "else"-statement inside one event

  2. #2
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, there isn't an actual ELSE statement that you can do inside of a single event, but using the provided workaround you should be able to get the same results anyways:

    Above the two events, make an ALWAYS condition that sets a value (let's use Global Value A as an example) to 1.
    Then, if the first event is true (i.e it triggers based upon the conditions you set), set Global Value A to 0.
    Now, in the conditions for the second event, check if Global Value A = 1.

    So basically:

    -'Else' is set to 1
    -First event conditions. If true, Else is set to 0.
    -If Else = 1, do second event actions.

    Your enemy needs a timer to check when to change directions, by the way. Otherwise it will try to change direction every frame, making it wiggle back and forth. You don't actually need an ELSE event, but here's a quick example of what you're trying to do anyway, using the pseudo-else:
    https://www.dropbox.com/s/bhkpk3uvue...ple%20else.mfa

    and an example without else:
    https://www.dropbox.com/s/cqv405xyam...0direction.mfa

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Silly question, but whats wrong with using an 'OR' statement for something like this? Do they not work the same?

  4. #4
    Clicker Fusion 2.5Android Export Module
    salmjak's Avatar
    Join Date
    Feb 2014
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, thanks for the answers and the examples casleziro, going to check them out now! I'm not used to work around things I'm used to :P

    To me OR says "If any of these two conditions are true, execute the action" while an ELSE statement says "If the first condition is false, execute the second action". Basically, an ELSE statement works with several actions while an OR statement works with several conditions. Dunno if there is any difference to them in CTF2.5.

    EDIT: I might want to rephrase that: An else statement checks several conditions and execute different actions. An or statement checks several conditions but execute the same action.
    Since I want to move in different directions depending on the condition I don't think an OR statement would work.

    I do realize that an Event is a "if-statement" and an "else-statement" would basically be the same event but with negated conditions. But this is not available for all conditions (like collision). But I will go with the global variable+always work around in the future

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    N64Mario's Avatar
    Join Date
    Nov 2008
    Location
    USA
    Posts
    1,308
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Ah okay. That makes sense. I guess it would be nice to have ELSE statements. Isn't something like this in common programming languages like C+ anyway? Hmm..... Maybe it's something that can be considered for a future Fusion 3.0?

    Though if you want completely different actions anyway, I don't see whats wrong with having two different events/conditions.

  6. #6
    Clicker Fusion 2.5Android Export Module
    salmjak's Avatar
    Join Date
    Feb 2014
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's common in all programming languages Like I said, an else-statement would probably be the same as a negated condition :P So they should only add negated conditions for things like "collision" and other things that doesn't have it (there is also the difference in the order the computer works it out (I think), but on a high spec machine I don't think there would be a real difference with two if-statements and one of them with a negated condition)

    Example: There is a difference with having gravity enabled with the "always"-condition and the "Negated: collision with another object". Basically, you can either stop the movement when colliding and always keep the gravity (calculation that moves the object down) running, or you can start it whenever it is needed. I don't know how CTF2.5 run things though, so there might be no real difference in optimization :P
    Also, a built-in else-statement would just make the software more user-friendly (and the event editor less messy), altough there is no need for it in itself.

  7. #7
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,062
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    there are many work arounds for the "else" use.... you just have to use your brain
    failing that - there is an IFELSE object.
    http://www.jaffob.com/extensions/hosted/xinok.zip

  8. #8
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We've been asking for Else for years, but if I remember right they said it's on its way with MMF3. For now we deal with duplicated and negated events.

Similar Threads

  1. "Cannot load joystick2.mfx" when "Compress the runtime" unchecked. Fine when checked.
    By DistantJ in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 14th September 2013, 09:44 PM
  2. "Rendertarget ping/pong" and "Pixel shaders" Can TGF2 do this?
    By CloudExSolider in forum The Games Factory 2 - Technical Support
    Replies: 13
    Last Post: 7th April 2013, 08:21 PM
  3. "Bug" For Saving and Loading Frame Positions AND "Timer Glitch"?
    By Zarpo in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 27th March 2012, 12:40 PM
  4. Issues with "Clickteam Movement Controller" and "Runtime" Object
    By jimmyorpheus in forum iOS Export Module Version 2.0
    Replies: 1
    Last Post: 29th November 2011, 07:10 AM
  5. split strings and "switch" statement
    By cinderela in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 6th December 2010, 06:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •