• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

variable

  1. E

    Gamemaker Local Variables

    I have this code where I want an instance to be created as long as the circumstances are met. This is the code: if(hAmount < hMax){ var spawnCounter = 0; spawnCounter += 1; if(spawnCounter >= 3*room_speed){ var sRange = irandom_range(65,80)...
  2. DevilKap

    SOLVED keyRun, hSpeed, and vSpeed are mysteryously "undefined" in PlayerStateFree

    The h and v speed are clearly defined in the player create event (seen below): and keyRun is also clearly defined in the player step event (seen below): However when I test my game, this happens: When I re-define keyRun in PlayerStateFree, this happens:
  3. jobjorgos

    Legacy GM How to send variable over from GM to online Javascript file with 'http_post_string'?

    I need instance variable online_players to be send over from GameMaker to players.js on my website Too bad with the code below there has not anything been updated yet in the players.js file. Alarm[0] Event: http_post_string("http://example.com/***/***/players.js"...
  4. ZacKow264

    SOLVED Variables no longer coloured or showing up in Code Completion

    There should be an image attached to show what I mean. Instance variables, local variables, and custom scripts no longer show up for me in their assigned colours. And yes, I checked my preferences, and nothing has changed there. Additionally, none of those show up in Code Completion either...
  5. jobjorgos

    SOLVED why does 'is_undefined' NOT prevent undefined variable crashs

    I simply have this code: if is_undefined( database[i, oPlayers] ) { //stop } and still the game crashes saying that is_undefined( database[i, oPlayers] ) is not set before reading it! I acctually USE is_undefined to PREVENT this error! Why does it not work?
  6. S

    GML How i can create and save a variable for every Instances of an objects in one room?

    Hello all. I were thinking about creating and saving (in hdd or etc) a variable for every instance of an object in one room. i have thought about using of id or instance_id but i couldn't make it working. So how i can create and save a variable for every Instances of an objects in one room? For...
  7. 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...
  8. 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...
  9. 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...
  10. 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.
  11. 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...
  12. 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...
  13. 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...
  14. 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 }
  15. 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...
  16. 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...
  17. 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 =...
  18. 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...
  19. 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)...
  20. 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 =...
Top