User Tag List

Results 1 to 10 of 10

Thread: Reloading Var Help

  1. #1
    Clicker Multimedia Fusion 2
    Pixzel's Avatar
    Join Date
    Jul 2010
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Reloading Var Help

    Okay here's the scenario.
    Say I have a pistol, it's maximum capacity is 10. My current ammunition is 6. So it's 6 / 10. So I have an extra 50 bullets in storage. What could I do so if it's 6/10 bullets, it will reload back to 10/10 and then 50 will subtract by 4. So it will appear like 10/10 - 46. This also applies to 4/10, 3/10, 8/10, etc.
    Also how can I do this easier because I will have weapons that have like 100/200 bullets and 500 extra ammunition in storage.

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    The only way I can think of, if you don't want to store a value somewhere, is to do a fast loop.

    For example do a fastloop 10-curAmmo times.

    On fastloop, add 1 to ammo, subtract 1 from storage.

    I'm sure you can figure out the conditionals to make sure you don't use up ammo you don't have.

    -Eliyahu

  3. #3
    Clicker Multimedia Fusion 2
    Pixzel's Avatar
    Join Date
    Jul 2010
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    Sorry mate, but that didn't work out so well. When I do the fast loop, it will exceed the ammo limit if I do that even.

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    You'll need 2-3 stored values, either alterable or global. I'll call them LoadedAmmo, StoredAmmo, and Capacity. Then on reload, subtract (Capacity - LoadedAmmo) from StoredAmmo and then set LoadedAmmo to Capacity. Hope that helps.

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    Personally, I'd use an array rather than global/alterable values. That makes it much easier to keep track of multiple weapons.

    My shooting example includes a frame with ammo/reloading/etc:
    http://www.create-games.com/download.asp?id=8261

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    Why not just do a fast loop? It'd probably look much cleaner in code. It definitely would work, it was probably just a mistake on your end. Shall I make an example?

    I mean Jaffob's way would work, I just know I prefer not having all these temporary values.

  7. #7
    Clicker Multimedia Fusion 2
    Pixzel's Avatar
    Join Date
    Jul 2010
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    This may be a stupid reply, but can you say it how MMF2 says it because I don't know if I'm doing this right.

    E.g.

    Upon pressing "R" >
    Set LoadedAmmo to Capacity

    etc.

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    Upon Pressing 'R'
    ~Run Fast Loop 'reload' maxCapacity-curAmmo times

    On Fast Loop 'reload'
    If storage <= 0
    ~Stop loop 'reload'

    On Fast Loop 'reload'
    ~Add 1 to curAmmo
    ~Subtract 1 from storage

  9. #9
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    Ah, I see the problem with my code. You will need one more alterable value or whatever you decide to use, I'll call it ToReload. So Upon Pressing R, you would have to:

    Set ToReload to Min(Capacity - LoadedAmmo, StoredAmmo)
    Add ToReload to LoadedAmmo
    Subtract ToReload from StoredAmmo

    I just find that this method would be easier than multiple lines for fastloops. But Pixzel, you can use whichever method suits you.

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Eliyahu's Avatar
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Reloading Var Help

    Well it's all preference. When you're programming, you can do whatever you want ^_^ That's the fun part!

Similar Threads

  1. Surface Object Question - 'Erasing and reloading'
    By RobertRule in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 10th October 2011, 10:18 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
  •