variables

  1. S

    Variable doesn't seem to change even though I'm using "variable -= otherVariable"

    My code is supposed to draw a white rectangle and an orange rectangle on top. The white rectangle is supposed to get bigger in the y-direction when you hover over it, and go back to normal when you stop hovering over it. But when not hovering over the rectangles, the white rectangle doesn't seem...
  2. William Garrison

    GMS 2.3+ Variable not working?

    So simple enough. I am trying to make a parent asset that utilizes the in room variable for what object is being controlled and/or called. But the game doesn't seem to be recognizing it. So here is the setup... Inside the Step Event if (triggered = 1) { instance_create_layer(oHero.x+150...
  3. FoxyOfJungle

    SOLVED How to get many values from 3d array? (or multi?)

    Hello! First time trying to use 3D arrays, it may seem a little stupid but you learn by making mistakes. 😅 I have this situation: array[0][spr_sprite][2] = "Text 1"; // [index] [sprite] [sprite_subimage] = "Text"; array[1][spr_sprite][3] = "Text 2"; array[2][spr_sprite][4] = "Text 3"...
  4. Gigicom

    GMS 2 Use code in json file

    Hey, I‘m trying to figure out how to use pre-defined json files for some item data in my game. Before, I simply assigned all values to variables and assigned those to a ds_map like this: constantData = item.apple; name = „Apple“; graphic = spr_ItemApple; list = ds_list_create(); listVal =...
  5. paulog

    SOLVED Instances acting differently

    Hello! I'm making a game in GM1.4 but I'm facing some issues. I really hope somene can help me out. In the game some objects have to jump to another position if the player clicks a button. I made two variables, "global.rot" and "global.oldrot". They both have the value of 1 when the room...
  6. G

    Instance_nearest and Variables

    I'm making an Insaniquarium Spiritual successor in game maker studio 2 and I'm looking to have the Piranha seek out the nearest fish with a size equal to 1. it works fine until any of the fish no longer have a size of 1. if (instance_exists(Fish) && (Fish.size = 1) ){ Target =...
  7. flyinian

    SOLVED Is there a way to null a variable from being used?

    I am using the parenting system for my navigation system in my project. Some buttons will go to a room when clicked and others will create instances. If I use the below code with the buttons that don't go to a room, it will give an error. Is there a way to have a variable return a value to...
  8. flyinian

    SOLVED Assistance with code help

    I am trying to add randomization to my combat system and experimenting with different code styles. When I use "var enemy" or "totalcounttarget" directly to adjust the value of "Count 1", it doesn't work. If I use the "Count 1" directly, it works but, I lose the randomization for my combat...
  9. flyinian

    Assistance w/ adding a value per value.

    I have a time system in my game. Minutes, Days, months, years. What are ways that I could add a value(lets say 100) for every day that passes in game? I know I could go: if (day == 1 || day == 2 || ect.) { value += 1; }; That will only add 1 if day is equal to 1. Are there better ways of...
  10. S

    GML Use variables of one instance in another

    I've been looking for a more code-efficient way to pull instance variables from one instance to be used in another. My current code is this: Target = id; // Instance id of another object is passed here. var a; with (Target) { a = CharacterName; // Instance variable created in the create...
  11. flyinian

    (SOLVED)Total exp count not calculating correctly with large numbers.

    I am currently developing a leveling system. So far, everything seems to work fine besides the total exp which calculates how much exp is gained on achieved levels(exp gain isn't calculated for not achieved levels). The issue I am having is that the total exp(_SkillTotalExp) is calculated...
  12. josyanf1

    GMS 2 [SOLVED] Discover 'direction' with hspeed and vspeed positions

    Hello! I am trying to discover the direction variable having the hspeed and vspeed positions. Since if you use hspeed or vspeed the direction variable gives 0. I'm a little lost, can someone help me? :S Thanks in advance ^^
  13. pumblerak

    GML [Solved!] Finding a variable of an instance outside of the current room?

    Running GMS:2 Version 2.2.3.436. Hello everyone! I've been on GM for a number of years now, and I've encountered a problem that I can hardly even begin to solve. I have an object named obj_musicmanager. obj_musicmanager fades the currently playing music between rooms, changes music as need be...
  14. FoxyOfJungle

    SOLVED Stop running a part of the step event?

    Hi, I'm making a Clock and in some part I need to "stop" executing a part of the code, note below, every dn_phase == "anything", I need to execute what is inside only once, because the "clock_bg_fade_alpha" needs to be at "1" only once. I've tried using boolean, but I couldn't do it efficiently...
  15. ChaoticNeutral

    Store statements in variables

    I have a statement stored within an array like this: choices = array_create(5, 0) choices[0] = event_perform(ev_other, ev_user0) choices[1] = event_perform(ev_other, ev_user1) ect. I then called it like this: if keyboard_check_pressed(ord("Z")) { choices[selection] } It gave me a red...
  16. R

    Question - IDE #No auto search/suggestion popup

    Not sure if I'm doing something wrong or if it's a bug in the editor, but local or limited scope declared variables (var Somevariable=a value or Somevariable=a value) don't seem to recognised by the editor in scripts where they are declared. It does work in objects. Global declared variables...
  17. samspade

    GML Coding Fundamentals in GML Tutorial Series

    GM Version: GMS 2.2.5 and 2.3 Target Platform: All Download: Github Repository 2.2 and Github Repository 2.3 Links: YouTube Playlist Summary: A GML tutorial series focused on the basics of coding in (unsurprisingly) GML. It is updated for 2.3 (almost). All of the videos will be posted below but...
  18. MartinK12

    GML [SOLVED] Multiple show_debug_message but show each only once?

    Currently I have this and it’s working fine. In create event: debug_msg_1 = true; debug_msg_2 = true; ... debug_msg_n = true; In any other event, ie. step event I use this: //do some stuff if (debug_msg_1) { show_debug_message(“whatever”); debug_msg_1 = false; } //do some stuff if...
  19. Smenkare

    Creating from, picking random and adding to ds_map

    Let me explain my problem in this example. i have variables for each object objvar1 = 1 obj1disable = false objvar2 = 1 obj2disable = true objvar3 = 3 obj3disable = false objvar4 = 1 obj4disable = false one empty ds_map and i have 4 objects...
  20. N

    Need help with a variable

    So I have a variable (global.coins) and I want it to be the same value as before i restarted the game. I have a initialization room that sets the global.coins value to 0. How to fix this?
Top