Cycling through weapons?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I know how much you all love helping out with problems so I've another question for you.

    My brother is making a game where you walk around picking up weapons which you can use in the game. If you press "1" then it selects weapon 1, pressing "2" selects weapon 2 and so on.

    Well he wants to create it so if you press a button (eg "+") then it will cycle through the weapons and pick the next one. This would be easy(ish) if you started the game with all the weapons but as you pick them up along the way then you might not have them all.

    So you have weapons 1, 3 and 4. "1" is currently selected. When you press "+" it should check and realise you don't have "2" so it should set the weapon to "3". How can we do this?

    With my limited knowledge I can create it but it requires massive amounts of code. Is there a way it can be done using loops or something like that requiring only a few lines of code, and if so how would I do it?

    Thanks!

    You should never say anything to a woman that even remotely suggests you think she's pregnant unless you can see an actual baby emerging from her at that moment.

  • Create global values for each Weapon as Ammo Counters like AmmoWeapon1,AmmoWeapon2 etc and add "CurrentWeapon"

    add

    "+" is pressed --> add 1 to global value CurrentWeapon

    and then add

    + CurrentWeapon = 1
    + AmmoWeapon1 = 0
    ----> Add1 to global value CurrentWeapon

    Repeat for all weapons. You can use a loop as well.

    Project in Development
    Please login to see this link.
    Please login to see this link.

  • A counter works too, but internal or global values is better.

    "+" is pressed ->Add 1 to counter.
    "-" is pressed ->subtract 1
    Counter=1 set weapon to srifle
    Counter=2 set weapon to pistol.

    But use maVados it's better.

    Please login to see this link.

  • That takes too long.

    That would mean I'd need an individual piece of code for each weapon and another bit to check if you have the next weapon.

    That's like 20 pieces of code if you have 5 weapons. He's planning on having about 8 or 9 which is about 72 different conditions.

    Isn't there some way of having it so it'll check it and pick the next available one in a few lines of code? Or am I in over my head to be trying to do this?

    You should never say anything to a woman that even remotely suggests you think she's pregnant unless you can see an actual baby emerging from her at that moment.

  • You would be going about it the wrong way by cycling through and checking for the "next" available weapon on each individual condition.

    Instead, you could have some form of data storage object (I find the List handy for things like this, with the "hide on start" set to true so that it doesn't interfere with the game) and keep the available weapons in that, then have the +/- keys change the selected item in the list and update the selected weapon depending on the contents of the selected row.

    As the hidden List won't display anything itself, you would also need to have a separate display on the screen that updates depending on what the list object contains and which row is highlighted.

    Please login to see this link.
    Please login to see this link.

  • Is Please login to see this link. what you are asking? I do not have the key-specific items in that file, but you would just use "Upon pressing one and Alterable Value B is greater or equal to 0: Set Alterable Value A to one" and then change the number for each item. Also, I did not use a "Skip item if it is empty" feature that is common in first-person shooters. If you want to cycle through only items that have content, then change "Greater or equal to 0" to just "Greater than 0" as that represents the amount. If the amount is lower than 0, then it means that item is unavailable.

    Good luck,

    -Snail

  • Snail, that is spot on perfect.

    Thank you so much! (Now to figure out how you did it :P)

    You should never say anything to a woman that even remotely suggests you think she's pregnant unless you can see an actual baby emerging from her at that moment.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!