Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Multiply a variable by 10  (Read 6889 times)

0 Members and 1 Guest are viewing this topic.

gamerx365

    Topic Starter


    Adviser
  • Radda Radda!
  • Thanked: 1
    • Yes
    • Yes
  • Experience: Experienced
  • OS: Windows 10
Multiply a variable by 10
« on: November 20, 2008, 06:21:22 PM »
This is making me so mad. Working on Eternal Death Slayer, I'm trying to add alliance selection, which will either multiply your life or armor by 10. It will multiply my life by 10 if life value wasn't changed before the selection, but that's all it will do. any hints?

Code: [Select]
:allianceselect
CLS
ECHO Choose your alliance:
ECHO.
ECHO 1) Good
ECHO 2) Evil
ECHO.
set /p alliance=
ECHO alliance>%alliance%.alliance
ECHO alliance>alliance
IF '%class%'=='1' SET alliancename=Good
IF '%class%'=='2' SET alliancename=Evil
IF '%class%'=='1' SET /A life=10 * %life%
IF '%class%'=='2' SET /A armor=10 * %armor%
DEL *.life
DEL *.armor
ECHO life>%life%.life
ECHO armor>%armor%.armor
GOTO lobby

I've been working on it for an hour and I'm still confused lol.
« Last Edit: November 23, 2008, 02:20:48 PM by gamerx365 »

diablo416



    Hopeful
    Re: Multiple a variable by 10
    « Reply #1 on: November 20, 2008, 07:52:34 PM »
    I dont understand whats the question?

    gamerx365

      Topic Starter


      Adviser
    • Radda Radda!
    • Thanked: 1
      • Yes
      • Yes
    • Experience: Experienced
    • OS: Windows 10
    Re: Multiple a variable by 10
    « Reply #2 on: November 21, 2008, 04:53:22 AM »
    That's my code but it isn't working. For example, Before this the life is changed from its initial 100 to 600. Then it gets to this code which should multiply that by 10, but doesn't. It remains the same.

    If life is not changed to 600 before this code, then it does work and is changed to 1000.

    I want it to multiply life or armor by 10 regardless of what it already is.

    gpl



      Apprentice
    • Thanked: 27
      Re: Multiple a variable by 10
      « Reply #3 on: November 21, 2008, 05:58:41 AM »
      Think sideways
      to multiply by 10, just bung a '0' on the right hand side

      IF '%class%'=='2' SET armor=%armor%0

      Graham

      diablo416



        Hopeful
        Re: Multiple a variable by 10
        « Reply #4 on: November 21, 2008, 06:30:24 AM »
        gpls idea is a better idea
        its either you mistakenly set alliance and used class, or theres a space in the variables.

        IF '%class%'=='1' SET /A life=10 * %life%
        IF '%class%'=='2' SET /A armor=10 * %armor%

        should work , instead try

        IF '%class%'=='1 ' SET /A life=10 * %life%
        IF '%class%'=='2 ' SET /A armor=10 * %armor%

        johnsonbben



          Greenhorn

          Re: Multiple a variable by 10
          « Reply #5 on: November 22, 2008, 03:27:42 PM »
          If your trying to multiply a variable that is a number by 10 try

          set /a armor=%armor%*2

          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: Multiple a variable by 10
          « Reply #6 on: November 22, 2008, 03:30:06 PM »
          If your trying to multiply a variable that is a number by 10 try

          set /a armor=%armor%*2


          hmmm- to multiply by ten, we must multiply by two.

          is there some kind of parable-type lesson here? Because if so, I don't get it.
          I was trying to dereference Null Pointers before it was cool.

          Dias de verano

          • Guest
          Re: Multiple a variable by 10
          « Reply #7 on: November 22, 2008, 05:34:34 PM »
          If your trying to multiply a variable that is a number by 10 try

          set /a armor=%armor%*2


          hmmm- to multiply by ten, we must multiply by two.

          is there some kind of parable-type lesson here? Because if so, I don't get it.

          He says he's an "expert"...

          gamerx365

            Topic Starter


            Adviser
          • Radda Radda!
          • Thanked: 1
            • Yes
            • Yes
          • Experience: Experienced
          • OS: Windows 10
          Re: Multiple a variable by 10
          « Reply #8 on: November 23, 2008, 12:30:50 PM »
          ... should work , instead try

          IF '%class%'=='1 ' SET /A life=10 * %life%
          IF '%class%'=='2 ' SET /A armor=10 * %armor%
          nah, didn't work. I wouldn't think it has to do with the value in the variable because of the 2 lines before that. that part works fine.

          gpl's code would work, unless I decide to change the value to multiple by, which I probably will...

          maybe I should try to multiply by 2... lol

          Jacob



            Hopeful

            Thanked: 1
            • Experience: Expert
            • OS: Windows XP
            Re: Multiple a variable by 10
            « Reply #9 on: November 23, 2008, 01:25:33 PM »
            Code: [Select]
            set /a lifetemp=%life%*10
            set /a life=%lifetemp%
            :D

            devcom



              Apprentice

              Thanked: 37
              Re: Multiple a variable by 10
              « Reply #10 on: November 23, 2008, 01:43:47 PM »
              i dont know what you guys are trying to do but i always use
              Code: [Select]
              set /a life=%life%*10and it works  ::)
              Download: Choice.exe

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: Multiple a variable by 10
              « Reply #11 on: November 23, 2008, 01:57:26 PM »
              Aww, man, I wanted to see how long it would take...
              I was trying to dereference Null Pointers before it was cool.

              gamerx365

                Topic Starter


                Adviser
              • Radda Radda!
              • Thanked: 1
                • Yes
                • Yes
              • Experience: Experienced
              • OS: Windows 10
              Re: Multiple a variable by 10
              « Reply #12 on: November 23, 2008, 02:05:08 PM »
              nope. not working.

              i dont know what you guys are trying to do but i always use
              Code: [Select]
              set /a life=%life%*10and it works  ::)
              umm... thats the original code, you know, the one that didn't work...

              Dias de verano

              • Guest
              Re: Multiple a variable by 10
              « Reply #13 on: November 23, 2008, 02:08:47 PM »
              Aww, man, I wanted to see how long it would take...

              Are you supposing it matters which way around the variable and the number are? It doesn't on my system.

              Code: [Select]
              C:\>set value=5

              C:\>set /a value=10*%value%
              50
              C:\>set /a value=%value%*10
              500


              gamerx365

                Topic Starter


                Adviser
              • Radda Radda!
              • Thanked: 1
                • Yes
                • Yes
              • Experience: Experienced
              • OS: Windows 10
              Re: Multiple a variable by 10
              « Reply #14 on: November 23, 2008, 02:19:33 PM »
              Ive tried it both ways as well