Navigation

    CreatiCode Scratch Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode

    Make a number negative (operators)

    Feedback
    4
    10
    479
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • The_True_Odst
      The True ODST Best Forum Helpers last edited by

      Since there is absolute value as an operator, there should be an option in the same block that lets you make a positive number negative

      ODST: Orbital Drop Ship Trooper
      (Halo Reference)

      mod.squadacademy Tyller_ jeffreyrb03-gmail 3 Replies Last reply Reply Quote 1
      • mod.squadacademy
        Mod. Squad Trainer @The_True_Odst last edited by

        @011830-0a42ef84 True, that would be handy. What would be cool is if that was part of a custom extension, because then it could be used in other mods such as Turbowarp.
        (We have mentioned the Idea to add support for custom extensions).

        In the meantime, that block can be created using this short code below. X represents the number you are working with.

        ((abs(X)*(-1))
        

        You know what block would also be cool to have? The to the power of block. It might look like this:

        (X^(Y))
        
        The_True_Odst Tyller_ 2 Replies Last reply Reply Quote 0
        • The_True_Odst
          The True ODST Best Forum Helpers @mod.squadacademy last edited by

          @mod-squadacademy-1bc96c56 They already have that block:
          2ad1582b-e803-478f-bf8a-f197a53404a8-image.png

          ODST: Orbital Drop Ship Trooper
          (Halo Reference)

          1 Reply Last reply Reply Quote 0
          • Tyller_
            Tyller_ Best Forum Helpers @The_True_Odst last edited by

            @011830-0a42ef84 the best way is 0-abs(number) or just 0-number

            <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
            </div>

            1 Reply Last reply Reply Quote 0
            • Tyller_
              Tyller_ Best Forum Helpers @mod.squadacademy last edited by

              @mod-squadacademy-1bc96c56 have you checked out hte editor? They have regex and url param stuff aswell

              <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
              </div>

              mod.squadacademy 1 Reply Last reply Reply Quote 0
              • mod.squadacademy
                Mod. Squad Trainer @Tyller_ last edited by

                @tyller_ Could you please clarify?

                Tyller_ 1 Reply Last reply Reply Quote 0
                • Tyller_
                  Tyller_ Best Forum Helpers @mod.squadacademy last edited by Tyller_

                  @mod-squadacademy-1bc96c56 The editor has blocks for regex support and reading url parameters among other things, there is so much stuff added to the categories it’s very easy to miss some very advanced/useful features.

                  Edit: I meant by checked out gone through it and really looked at all the blocks, I’ve assumed you skimmed through it a bit.

                  <div component="post/signature" data-uid="255" class="post-signature">Check out my chat room project so you ppl can not use forums as chat rooms! https://play.creaticode.com/projects/66f2e1dcd1be43d82b886fbd?version=1 <p dir="auto">
                  </div>

                  1 Reply Last reply Reply Quote 1
                  • jeffreyrb03-gmail
                    JaecadeJnight Mod Helper @The_True_Odst last edited by

                    @011830-0a42ef84 use absolute value, then ( join (-) (number) ) . That will just make the number negative because abs value makes it positive, and you can just turn a positive into a negative literally with the negative sign. You could also do a longer solution, where you check if the number starts with “-”, and if it does, then dont do anything, and if it doesnt, then the number is positive, and you can just join that number and “-”.

                    #LLJW
                    <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                    mod.squadacademy 1 Reply Last reply Reply Quote 0
                    • mod.squadacademy
                      Mod. Squad Trainer @jeffreyrb03-gmail last edited by

                      @jeffreyrb03-gmail
                      Surely this:

                      ((abs(X))*(-1))
                      

                      Would take up less space than this:

                      (join (-) ((abs(X)))
                      
                      jeffreyrb03-gmail 1 Reply Last reply Reply Quote 1
                      • jeffreyrb03-gmail
                        JaecadeJnight Mod Helper @mod.squadacademy last edited by

                        @mod-squadacademy-1bc96c56
                        You are right but technically, they take up the same amount of space in blocks.

                        (join(-)((abs(X)))
                        

                        has join()(), and abs(), takes up 2 blocks

                        ((abs(X))*(-1))
                        

                        has abs() and ()*() (multiplication), takes up 2 blocks.

                        In math, --2 =2, —2 = -2, and so on. I guess it’s more of preference on which method to use. Your method is nice since it works with numbers only, but mine mixes strings (the “-”) and numbers which may be a bit weird even though it’s still interpreted as a number (just a negative one).

                        #LLJW
                        <span style="color:white;background-image:linear-gradient(to right, lightblue, navy)">My name is Jeff</span>

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post