Announcement

Collapse
No announcement yet.

Variable mathematics

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Variable mathematics

    I'm wondering if I'm just blind or if there's actually an event code able to add, subtract, multiply, and divide variables?

    I figured out a way to do limited variable addition, multiplication, and subtraction (And maybe division), but it's a memory whore like nobody's business!

    #2
    Re: Variable mathematics

    No such code exists.

    I'd be interested in your Memory Whore though. Is she available?

    Post her for me if you can (if she's one of those big beautiful ones, a description will do).

    I imagine she only does small numbers. But I'm curious how you got her working.

    Peace.

    MOO!




    Comment


      #3
      Re: Variable mathematics

      So far all I've got is a simple do until loop using two events/characters.

      Let's say you want to add Shared Variable 1 (S1) and Shared Variable 2 (S2) together.

      Event 1 is coded like so:
      Val-Conditional Branch 2 options
      Branch 1: If S2 is >= 1
      Add 1 to S1 (or subtract 1 from S1)
      Subtract 1 from S2
      Take over Event 2
      End Branch 1
      Branch 2: If S2 = 0
      End Branch 2

      Event 2 just has a take over event 1 code.

      As such, it can only add fairly small numbers together (After so many loops, I think 10-15, the system assumes it's caught in an infinite loop and crashes). I'm going to test with using a couple of models for making larger numbers calculable (Adding in branches which add 5, 10, or 50 depending on S2's value).

      I think it's also possible to use auto events, as they repeat until either the mode is changed or the requirements are no longer met. Maybe it'll even allow breeching the 10-15 repetition limit.

      Multiplication means adding the following code to branch 2 of event 1.
      S3: Number you are multiplying by -1
      S4: Stored value of S1

      Val Conditional Branch: 2 options
      Branch 1: If S3 is >=1
      Copy S4 to S2
      Subtract 1 from S3
      Take over Event 2
      End Branch
      Branch 2A: If S3 = 0
      End Branch

      The multiplication method I'm using has trouble with 4 x 4 so far. Since I'm not really looking terribly much into multiplication, as no current project I'm working on uses it, I'm probably going to leave it at that for now.

      Comment


        #4
        Re: Variable mathematics

        Sorry about the double-post, but I think it's worth the bump.

        In the addition example above, if you replace 5 as the requirement for branch 1 and 1 as the requirement for branch 2, you add considerably to the values for S2 that don't crash the system. With a little creative coding you should be able to go all the way to 9999 with the addition (I think that's the highest variable value).

        Also, auto-events do NOT work. The loop detection thing catches on even quicker.

        Comment


          #5
          Re: Variable mathematics

          I like the idea, but was just curious.

          I do not need any math the way I set up my game. I made it based on 3's limits and so figured I'd not be able to do that.

          Nice work though!

          If I ever bring myself to pick this game back up once the game I'm making is done, I'll consider this.

          Sadly, I expect 3 to be a "One Game Wonder" for me.

          Peace.

          MOO!




          Comment


            #6
            Re: Variable mathematics

            Come now Rodak, one of the FEW handy tools of RM3 and your aren't going to use it? I must have one of those on everything in my game.

            Comment


              #7
              Re: Variable mathematics

              RPG Maker 2 does a better job at variables. In 3, variables are better left to "collection" events, where the least work is needed.

              I don't use any long code because of the tedium 3 makes with creating multiple events.
              Last edited by Crimson Knight; 01-21-2006, 02:53 AM.
              Quote of the moment - "When you cut down a tree, don't stand near it."

              Comment

              Working...
              X