variable

  1. K

    Help me please! Game Maker

    I'm still working on my game. But ANOTHER PROBLEM arose. What happens is that I have two GLOBAL VARIABLESl. Score and another global. HiScore. The latter supposedly has to show the highest score obtained, and above all, when the score is lower, it must stop adding until it exceeds it. That's...
  2. XenonMax

    GML Save page and color in 1 variable

    Hello, I want to program something like a Launchpad light show painter(this thing with buttons/music/light). Now I try to save the current buttoncolor in a variable on the right page! Like --> ( If I have page 2 change color(or image_index) to red(or 2) ) (I can't create 100000 variables for...
  3. Lens

    SOLVED Having problems to identify multiple objects with a collision rectangle

    Hello, good morning/afternoon/evening! I'm using a collision rectangle to identify other object instances around the room, and, while there is any of those specific objects touching/being inside the rectangle, the main character (whose posseses the collision rectangle) will change a variable...
  4. K

    GML About variables and global variables

    I wanna know about the difference between them, is that variables are attached to the object only, and you can't use it in another object and global variables are available across all objects? I don't know if I am right.
  5. Lens

    SOLVED Problems identifying specific object and thus changing its variables.

    Good morning/afternoon/evening! :potato: I have many instances in a game called oBomber. Also I have an object called oTank, which has a range (collision rectangle). Once oBomber gets inside the oTank's collision rectangle, it should lose HP (to make it simpler, as for testing, now it just...
  6. M

    if the variable for nearest instance = 1: stuff happens

    Hey, basically, I want to make it so that if an enemy object with a certain variable (effect) set to 1 comes near enough to another enemy object whose var is still 0, then that enemy object's var 'effect' also becomes 1. Sort of that the effect spreads to all nearby enemies from each other. I...
  7. 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...
  8. 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 }
  9. 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...
  10. 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...
  11. 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 =...
  12. 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...
  13. 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)...
  14. 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 =...
  15. 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 =...
  16. 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 =...
  17. 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.
  18. 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...
  19. 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...
  20. 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.
Top