JayMCee80's Forum Posts

  • 4 posts
  • There's also the specific "contains value" condition

    > Contains value

    >Searches the entire array to check if any of the elements contains the given value. For example, you can use this to test if the string "sword" is stored anywhere in the array.

    I tried that initially, but I couldn't figure out how to get it to NOT insert "cow" if it was already there. Wouldn't I need some kind of ELSE statement of some sort? Basically it would be "If array contains value "cow", do nothing, ELSE insert "cow"" though I'm not familiar enough with Construct yet to know how to code that.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Add a second condition to the event:

    System compare two values: Array.indexOf("cow")<0

    That worked, thank you.

    Just so that I can understand what's actually happening, this works because each element in an array is numbered, starting at 0. Initially there is no "cow", so the button works because "cow" is less than 0 meaning it's not there at all.

    Once the button is pressed and "cow" is created, it now has a value greater than 0 and so the action to create the "cow" element is not initiated.

    Is this correct?

  • I'm messing around with the "Arrays for Beginners" tutorial and I'm at the section where I create a button to add "cow" into the array. I've got it so that all the values of the array are displayed, so every time that button is pressed, the word "cow" shows up.

    How do I prevent the button from working if "cow" is already in the array?

    Here is the relevant line of code:

    Here is the output when I press the button more than once:

  • I'm going through the beginner's guide right now and I'm at the part where you create the condition and action to make your player fire the gun. Instead of clicking the left button though, I'd rather make it so that the left button only needs to be held down. When I do this though, it just creates a constant stream of bullet objects.

    Is there a way I can set a time limit between when objects are created?

  • 4 posts