1. 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...
  2. Daniel Mallett


    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.
  3. 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...
  4. 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...
  5. 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 =...
  6. 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...
  7. 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...
  8. 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.
  9. E

    GML Global Variables not being updated

    Hey coders, I initialise all my global variables in my first page. When i move into a fight i want the if/else statements to allow for me to create a battle system but the global variables are not being updated. (Also to note the global.MonsterSpeed> global.Spd is always called even if Spd is...
  10. KyleRansford

    GMS 2 How to Assign a Mouse Click or Touch to a Variable [SOLVED]

    Hello, I'll try to explain what I mean, but I have a Input Object (o_input) that has all the controls for the character like: action_one_pressed_ = gamepad_button_check_pressed(xbox_controller, gp_face1) or keyboard_check_pressed(ord("D")); action_two_pressed_ =...
  11. M

    Variable referring to multiple objects?

    Hi! Long story short. My strategy game has multiple 'unit' objects stored under 3 parents: player1_par, player2_par, and cpu_par. The parents are all supposed to attack one another, so that player1_par's children objects attack player2_par and cpu_par, and so on. I can store both the player...
  12. Suzaku

    GMS 2 how to check if variable is declared

    I have a global variable that needs to get the value of other variable, but first it needs to check if that other variable is areadly declared or if it has any value. How can I do this? Thank you.
  13. Suzaku

    GMS 2 how to get a constant name?

    I have a enumerator with some constants inside, and I would like to show their names in my console, not their values, something like show_debug_message(getConstantName(parameterHere)); Is that possible? Thank you.
  14. P

    Assigning data from one object's variable onto another using "with"

    Hi guys, I'm making a space trading and top down simulation game similar along the lines of the Patrician series and somewhere along the code I've run into an issue I'm quite unable to solve by myself. Most of code structure is established by now and all it's left is to assign resource transfer...
  15. K

    Script that automatically prints the name of a variable

    Good day, how can I create a script that automatically prints the name of a variable and its respective value in the debug. I should just enter the variable in the script. sorry for the english i.e: if vsp = 4 scr_message (vsp); result; vsp = 4
  16. X

    Asset - Extension ActiveVars - Trigger Scripts on Value-Changes

    ActiveVars Marketplace: Category: Extensions Price: Free Description: ActiveVars allows you to link scripts and variables, so that when the variable changes the script is called. Common uses may include: * Settings (resolution changes...
  17. Joky

    GMS 2 [SOLVED] I'm kinda new and i'm not sure what to do here.

    I might sound pretty stupid asking this so sorry about that. But I'm trying to do this: Player obj walks to vault obj and presses z and it changes (escapedoorlocked = true) - (escapedoorlocked = false) But it doesn't work for me. So can someone help me? I'll post code if needed.
  18. D

    Comparing 3 or more variables.

    Hello, guys. I didn't found any info about it, so I ask it here. I have character, which can gaim genetic points of 3 types: red_gene, blue_gene, green_gene. I need to compare all three variables to find the highest of them in case to change color of the sprite to relative one. I know how to...
  19. O

    GMS 2 How do I make a variable hold it's current value in one instance and have it change in another?

    I'm having a script basically repeat itself to draw text in a certain way but when I try to have it run the text won't be placed right create _x[0-3] _X = 0 script draw_text(_x[_X], y, "text"); so what happens is the word goes flying across the screen or is stuck in a loop when I program _X...
  20. F

    Windows Problem with variable

    I´ve got a problem with variables. When i set global.enemyspeed = 2;, and then into the enemy object-step-alarm[2] = 300; Alarm2-global.enemyspeed +=2 alarm[2] = 300; But in the game, the speed is on +2 until next enemy spawns. When next enemy spawns the speed is again on 2. The game...