for loop

  1. mmmmmmmmmmmmm

    [SOLVED] Loop not creating array or list of arrays as expected

    I'm trying to use a for loop to create an array of arrays and I have no clue why it doesn't work. The same problem is encountered if I try to use a DS list of arrays. A reproduction of my code is: var k = 4; var array; var list = ds_list_create(); for (var i=0; i<k; ++i) { var t...
  2. G

    GMS 2.3+ How do I loop over an array?

    Dear GMS2-community, I'm trying to loop over an array using the following bit of code: Click event object Q: a[0] = 0; a[1] = 3; a[2] = 5; for(i = 0; i < 3; ++i; ) if(instance_number(global.obj_target[a[0]])=0){ instance_create_layer( xx, yy, "Instances", global.obj_target[a]) } But for...
  3. D

    GMS 2.3+ For Loop not working

    Just updated to the most recent version (2.3.1) and my For loops have suddenly stopped working and I don't know why. I found it odd that the new one I did wasn't working, even though I had one running perfectly fine last week or two, but even that one is broken right now. Checked the usual...
  4. I

    Solved - Drawing Rectangle over time in GUI

    Hi, I have some semi-working code in my project that runs a script when the player clicks on certain tiles in-game. I'm struggling with slowing things down to get a smooth look! What I want to happen is: The player clicks the tile. A small blue bar appears in the tile below and fills from...
  5. K

    change multiple variables value in a for loop

    hello everyone. i'm new to coding in general and i was wondering if you can help me with this problem: i have this variables global.StatLvl1 = 2 global.StatLvl2 = 2 global.StatLvl3 = 2 global.StatLvl4 = 2 global.StatLvl5 = 2 global.StatLvl6 = 2 global.StatLvl7 = 2 global.StatLvl8 = 2...
  6. C

    GML [Resolved] Difficulty with arrays and for loops

    I'm trying to code a basic turn-based battle system where each character has a variable called "time," which, when it hits 0, allows that character to select a move (think ATB system in Final Fantasy in reverse?) I made a ds_map for each character, and then, for the battle system, made...
  7. Z

    (SOLVED) Changing a group of instances with the same pre-condition

    Hi everyone! I have an object that is spread across a room, meaning there are many instances of that object. In the instances creation code (not in the object create event, but in the instances creation code in the room editor) I gave "groups" of these instances a specific value. Some of these...
  8. T

    Objects Id connected to draw sprite

    Hello everyone. Have a cool person who used pseudo code to help me understand. I'm pretty sure im getting it but something isnt working right and Im not sure. Been reading in on for loops, with statements and ds_list for days. Been on this issue a little long and think it's time to ask for...
  9. C

    GMS 2 Does GMS2 use multithreaded for?

    DIfferent programming languages like C# or C++ offer the option to use a for loop that runs in parallel creating different threads wich is faster than the regular and other languages like Java use this type of for as their standard one. Do any of the compilers for Game Maker Studio 2 use...
  10. E

    GML Getting Weird Behavior in a Widget

    I've been staring at this code for an hour and I need a fresh set of eyes. I made a color-picker widget for a thing. It looks like this, and it works by clicking on the number you want to change and dragging either left or right. It all works too, except for this one weird bug I can't figure...
  11. M

    GML Help with FOR LOOPS

    Hi All, I am making a game. The player has no hp at the start, but with each 3 hearts that he gathers, one hp is added. I tried with if statement, with do... until, and I tried a for loop, but nothing seems to work. It either adds just one hp and stops there, or keeps adding infinite number of...
  12. Edwin

    Legacy GM [SOLVED] "for" statement for arrays malfunction

    Hello, fellas. I have a small problem with using “for” statement to set all the arrays to 0 by subtracting them while they are not smaller or equal to 0. So when all my arrays are smaller or equal to 0, the object needs to be destroyed. But it does not work as I expected: object is destroying...
  13. A

    GMS 2 Iterating through DS List Works when Debugging only [Solved]

    I have encountered a bug in my code when I attempt to iterate over a ds_list containing objects returned from a json file. When the application runs normally this error appears, as well as when I debug the code and hit F5 to move to the break point after the for loop (the error on line 23...
  14. F

    painting with a for loop

    Hi there I am building a paint-like program and I've run into some trouble. I have a brush size manager called scalemanager which let's say has its scale variable set to 5, it should be creating 5 rows of black boxes 1 pixel in width in height but instead after reaching the end of the second or...
  15. W

    Legacy GM Drawing Object sprites from a ds_list[solved]

    I need to draw the sprites of objects I store in a list but every time I try for some reason my inventory object draws my sprite above the object writing the code no matter where I put the y value. I'm just doing a loop and drawing whatever's in the array at the checked position if there's...
  16. Edwin

    GML I cannot undestand how to use for loop.

    I am very dumb russian gopnik, so even after looking at the tutorials and manuals, i did not understood anything :(. Could you please explain it for me, how stupid it would not sound, like for child? This is from russian manual translated: for loop first executes command 1, then checks the...
  17. C

    GMS 2 How do I assign a variable to an instance when I create it?

    Hello, First time posting here. Let me know if this isn't the right place! I'm creating a small board-like game where two players can move around on platforms and attack each other. I create the platforms with this for loop: for (i = 16; i < 160; i += 16 ) { instance_create_depth(240 +...
  18. Jenthura

    GML Having issues drawing a grid with arrays that start at 0

    Here's the code in my Draw event: var i_x=0; var i_y=0; grid_spacing=32; repeat(grid_width) { repeat (grid_height) { if i_x>=grid_width { i_x=0; } else {...
  19. G

    GML [ANSWERED] how to use 'for' loops & arrays)

    hi yall, i've always gone through arrays like this: for(var i = 0; i < n; i++) { Array[@ i] = -1; } however, upon reading this thread am i understanding correctly that this is more efficient: for(var i = 0; i < n; ++i) { Array[@ i] = -1; } ? this is how i do my menus, or at least the part where...
  20. S

    GMS 2 [SOLVED] Adding the results of a For loop together

    I have the following code. Just for reference, ds_grid_get(playerInventory, 65, i) is the status of the object, and ds_grid_get(playerInventory, 0, i) is the name of the object. for (i = 0; i < ds_grid_get_height(playerInventory); i++) { if ds_grid_get(playerInventory, 65, i) == "Equipped" {...
Top