User Tag List

Results 1 to 8 of 8

Thread: Flipping negative and positive without conditions

  1. #1
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Flipping negative and positive without conditions

    Hello. I've been playing around with fusion and was wondering if anyone had a solution to this problem.

    Let's say I have Alterable Value A, this can equal either -1, 0 or 1. I want to be able to flip this value to its positive/negative counterpart. Now normally I would use the following equation:

    A = -A

    In fusion however I have tried to use the following expressions, without much luck.

    Set Alterable Value A = -Alterable Value A("Object")
    Syntax Error

    Set Alterable Value A = Val( "-" + Str$( Alterable Value A( "Object" ) ) )
    -1 = 0 (should be 1)
    0 = 0
    1 = -1

    Trying to add the additional - sign to an existing number doesn't seem possible, unless I am missing something glaringly obvious here. Val() appears to read --1 as 0, however the regular integer equation of --1 returns 1 as it should.

    Like I said, I am trying to achieve this without the use of conditional statements as I am using timed loops using the ForEach object and I don't want things getting too kludged. The actual value of Alterable Value A is a randomly generated number to determine the direction of an NPC. So:

    DISTANCE * Alterable Value A = Left or right for X axis depending on -1 or 1.

    Appreciate any help you can give me

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Let's say you want to invert Alterable Value A for an object called "Active":
    0 - Alterable Value A("Active")

    Does that work? I didn't test it to make sure, but in theory, it should work...

  3. #3
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glaringly obvious but 100% effective. Thanks so much, and really appreciate the quick response as well!

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You're welcome! Glad I could help!

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module

    Join Date
    Feb 2014
    Posts
    1,055
    Mentioned
    29 Post(s)
    Tagged
    1 Thread(s)
    i think the equation u were lookin for was...

    A = A *-1

  6. #6
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, that equation converts A in to a negative value only. I am trying to dynamically convert a positive to a negative AND negative to a positive in the same line. So if A equals the following values then the corresponding values would be the output.

    A = +1 THEN A = -+1 (or -1)
    A = -1 THEN A = --1 (or +1)
    A = 0 THEN A = -0 (or 0)

  7. #7
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator Pro
    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
    Jul 2006
    Posts
    574
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    A = A *-1 doesn't convert to just a negative value. If you are using calc to test it may do that. but if you multiply any value by -1 in code it will toggle the sign.

    Its a common calculation used in custom bouncing ball movements.

  8. #8
    No Products Registered

    Join Date
    May 2016
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a useful tip actually. I've been programming for 20 years and didn't realise that. Thanks for the advice

Similar Threads

  1. Getting a random number between a negative and positive number
    By D_Light in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 9th January 2013, 10:51 PM
  2. Convert a negative value into a positive
    By Sevennemesis in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 12th November 2012, 02:09 PM
  3. Random ranging from floating negative to positive?
    By oldkliker in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 21st September 2011, 01:08 AM
  4. [Request/Idea] Flipping AOs with negative scales
    By xyzzy in forum Hardware Accelerated Runtime
    Replies: 7
    Last Post: 18th December 2008, 06:22 PM
  5. Positive And Negative Randomize
    By Atom in forum File Archive
    Replies: 1
    Last Post: 1st November 2008, 02:44 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
  •