• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

variable

  1. M

    referring to an instance stored in a variable

    Hey guys, Im trying to have my game pick a random instance of an object (enemypar) and then store that random instance to a variable. Then, I'd want to refer to that variable in this a statement, for example: <variable here>.distance_to_object(playerpar) < 100 So that the randomly picked...
  2. U

    GMS 2 Check all objects

    Hey, i was wondering if the is a way to check if one variable is equals to 1,for example, in all objects of one type: if(all of object one type.variablenamehere==1){ then do something }
  3. flyinian

    (SOLVED)Can't Assign variables to variables in the "Variable Definition" page of an object.

    I am trying to assign a variable to a variable in the variable definition on the object's page. EX: //Here is the variables in question. //I am assigning _object an object. I am then assigning _SpriteX & _SpriteY the variable of the _object's X & Y value which is determined through another...
  4. flyinian

    Design Questions about Delta time, lag with incremental/click based game.

    1. Is Delta timing good for a incremental/click based game? 2. If I have variables doing calculations per step, and the game lags, will it cause issues for me? Ex: if I had two variables relying to be in sync, and become out of sink due to lag. Or is that lag just voided steps and the...
  5. S

    GML How to put piece of code in a variable or argument?

    Hello, I am trying to put some code into an argument of a script how can I do it? This is how I want to call the script: change_script(1, 2, global.military_point = global.military_point + 3, global.economic_point = global.economic_point + 3); This is inside of the script: var unique_id =...
  6. CreativeBand124

    Triggered variable one time

    Hello guys! I got a problem. I make game similar to FTL and i need this for my crew members code. So... i got script for rooms and crew members which are cloned obj_crew. This is inside the room_script which are in draw event of gui_object. This code it's for slots on my room scripts for the...
  7. William Garrison

    GMS 2 Referencing drawn layers

    Okay so is it possible (and if so how to go about it properly) to draw sprite items and then reference or move them individually in game when something happens? For example, lets say I have this... draw_sprite(info here); // top layer draw_sprite(info here); // mid layer draw_sprite(info here)...
  8. Fleoh

    GMS 2 [SOLVED] Is there a way to adress a variable from a string ? (asset_get_index)

    Hello guys, I've got a question. In Game maker, there is a way to adress an object from a string with the function asset_get_index. Exemple : weapon = "pistol"; sprite_index = asset_get_index("spr_"+ weapon); Is there a way to do the same thing with a variable ? Exemple : sell_pistol =...
  9. Pompadour Dude

    GMS 2 (SOLVED) How to combine string variables?

    Hey guys, I am working on one of my games and I want characters to change clothing (head / body / legs) separately. I want to use three string variables. For example: headSlot = "some var" bodySlot = "some var" legsSlot = "some var" These variables can be equal to clothing type: bodySlot =...
  10. William Garrison

    GMS 2 if Toggle

    Why doesn't this work? var toggle = false; if keyboard_check_pressed(ord("1")) && (!toggle) { image_index = 1; toggle = true; } if keyboard_check_pressed(ord("1")) && (toggle) { image_index = 0; toggle =...
  11. K

    Drag And Drop always: 'variable not set'

    Hello! Always i have this problem. I don't know what to do to repair this bug. Please help.
  12. M

    'Variable not set before reading it' but it is set

    Dear people, I wonder if any of you can help me with the following. I have a game initiator object that will assign a value into a global variable. Then that same object will create a new instance of another object, which based on the previous value will be created in one or other way. The...
  13. Elgarion

    GMS 2 [Solved] ways to change variable inside an object

    Hello everybody ! I have a question about good practices in programing : when you want to change an object's variable, do you use "with" or "my_object.my_variable" ? the two ways seem to work : with(Obj_Player) { my_variable_health = 10 ; } ; or Obj_Player.my_variable_health = 10; Which...
  14. Daniel Mallett

    Debuging

    Is it possible to not only watch a variable for changes but when it does change, show you the line of code that caused it to change? This would be invaluable knowledge if it's possible. Thanks in advance.
  15. S

    GMS 2 How can I combine a string and integer, then use it as an object ID?

    (I'm only a few days into using GML, but I have other programming experience) Alright, basically I have a very simple button/door system. What I do is, I make a door's ID "door1", and corresponding button with "button1", which is fine. But apparently I can't use the same ID's between different...
  16. M

    GMS 2 Execute script with variable

    Hello everyone! I have a small problem in my mobile project. I created a button that should lead to the next level. All the level atributes are saved in scripts: scr_level1 , scr_level2 , scr_level 3 and so on. So in the button I added these lines: // this button is in rm_game //when button is...
  17. Divinik

    GMS 2 [SOLVED] Variable adding too many times in one step

    So I have a variable (shots_fired) that counts how many time a gun is fired, but for some reason it will continuously add to the variable, even with a condition check: if parent.image_index >= 1 { image_angle = 10; x =...
  18. M

    GMS 2 A variable that "Holds" another variables name

    Hello all :), I have been making some headway on my game and have been somewhat trying to polish/ fix up my code to be easily expanded on so that I can start adding "Content". My question, does something like this exist? variable_get_name() or maybe, reference_variable() I am simply trying...
  19. G

    GMS 2 (Solved+) How can I refer to a variable/array/etc using an asset name?

    I'm creating an array of variables to track progress for each area in my game like so: area_001_state=[0,0,0] area_002_state=[0,1,0] area_003_state=[1,0,1] ... The first array position for each area could indicate whether the lights are on to start with, for example. Then when I want to...
  20. Kaliam

    Bug, variable exists but these lines don't read it.

    So these variables aren't being recognized by the IDE for some reason, even though I am using them two lines afterward. I tried restarting the IDE and reloading the project but that didn't fix it unfortunately. My guess is that this is a bug related to the new warning system but i'm not sure.
Top