variables

  1. 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 =...
  2. 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...
  3. 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 =...
  4. 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...
  5. 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...
  6. 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...
  7. 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...
  8. 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...
  9. 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 ^^
  10. 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...
  11. 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...
  12. 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...
  13. 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...
  14. 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...
  15. 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...
  16. 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...
  17. 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?
  18. NotTayyy

    GML Does it matter where I Create and update variables?

    So I Made an persistent inventory manager object and Inside it created a Data structure with all my Characters stats, Like the name, gold, Def, atk, Equipment slots, exp Etc... Then i want to make a Variable for each one so i can update them but i dont know where i should put them. So I Was...
  19. B

    Legacy GM [SOLVED] It's possible to leave a variable with no initial value?

    Is it possible to leave a worthless variable until a certain point in the game, even if its value grants a sprite_index a room-specific object? Or at least leave it with a default value that can later be changed by other values still in room_start? Well, whenever I start the game, I leave this...
  20. C

    GMS 2 Animation playing AFTER the sound file

    This is the most bizarre situation. I have an animation I want to play as long as a certain sound file is playing. Let me see if I can explain my programming in D&D. Create Event: Assign Variable: radio_channel = 0 Set Animation Speed = 0 Set Sprite: anim_radio = 1 Step Event: If audio is...
Top