global variable

  1. Corey

    (Fixed)Global variable/Alarm/instance_create issue

    Edit: Disregard. I fixed my problem by adding a Step event with global.enemyCounter = currentEnemies; to check the counter every frame and switched my Alarm event code to check conditions before spawning an enemy. Hello all. I have tried countless times to fix my problem. I am somewhat...
  2. HanNic3197

    GMS 2 (SOLVED)Issue with setting local variable to (global variable value - amount)

    Hello, I keep getting the following error: when trying to do the following code: new_total_coins = old_total_coins - global.costume_price if(draw_coin_amount > new_total_coins) { switch(draw_coin_amount) { case 0: draw_coin_amount= global.coins_totalcollected...
  3. N

    Discussion can we have function like variable_global_get_name()

    Can we have variable_global_get_name() *function that gets name of all exist global variable in the room as an array of string I am trying to make debugger and already work around another similar function like variable_instance_exit /get_name /get /set which goes pretty well but when work around...
  4. P

    Keyboard_Check_Pressed(ord())

    For some reason when I input this code, instead of just activating key_z when the z key is pressed, it activates at any button pressed. Any ideas why? global.key_z = keyboard_check_pressed(ord(“Z”));
  5. Guitarmike

    Single-instance objects referenced by global variables

    Hi, I'm new to GML but not to programming. I'd like a little advice on best practices. I have a couple of objects in my game for which there is only a single instance and which need to be accessible from many other places around the game. For example, the obj_player and the obj_clock...
  6. V

    Global variables not working

    Hello, I am trying to make a game where the player falls from the top of the screen, collecting letters along the way. I have a text set up in the corner where I'm trying to have a fraction display the amount of letters collected/left. I'm using the following code inside a spawner object's draw...
  7. W

    Reading global variable

    My save/load system was planned with a few functions extra to make the game interaction more interesting, one of this functions is to variate the main menu background when a global variable has reached a certain value. I coded all the fuctions in the creation code of the main menu room, but...
  8. B

    Collision counter

    Hi there! I want to make a collision counter. I set to the object's create event to: global.collision = 0; And the collision event to: global.collision += 1; It counts constantly when it's overlapping, but I need just one point / collision. I have no idea, how can I do it.
  9. L

    Legacy GM Upgrade System Help

    I'm working on adding an upgrade system to my game where after the level timer runs out, it brings the player to an upgrade menu where you can spend points. I'm having trouble with a player movement speed upgrade at the moment. The idea is that selecting the upgrade option runs a script that...
  10. M

    GMS 2 Which is faster?

    I have a persistent invisible object called obj_game that controls most everything about my game: Which button is pressed, whether or not we're in a cutscene, how far we've gone along in the story, and whether or not the game is paused. [for example, if the variable global.paused = 1, the game...
  11. M

    GML crazy way to tincker with variables??

    I didn't know what to put in the title for this so I apologize for the click bate ish title My question is can there be two separate objects both programed with the same global.variable but that variable changes it's name based off of some state or position in the room?
  12. M

    Legacy GM detecting objects in seperate rooms?

    I'm wanting to check and see if there is an object already at a (x,y) position. Is there a way to do this when in a different room? I can provide some of my code to help with the context if need be/if asked but I don't see the necessity in that. Would it be more effective to use a global...
  13. P

    Legacy GM [Solved] Avoiding Memory Leaks With Particle Systems

    The manual recommends destroying Particle Systems when not in use as to avoid a memory leak, I gather in case different objects keep making unique systems and they pile up in memory. I was just wondering, if I store the particle system, particle type and emitter in global variables that all...
  14. P

    Tutorials and Global Variables

    Hello. So let me start by saying I am slowly learning more and more. One of the things I have learned is the potential disaster that is Global Variables. I have been following a tutorial on RTS Turn based games. However this tutorial, while teaching me a lot, left me in a hole I can't dig...
  15. H

    Legacy GM check for player using an item

    How can I check if a player is using an item and when the item is used it makes a global signal that can be used in an if statement
  16. Nathan Laing

    Legacy GM Which is slower, accessing global vars || another object's vars?

    Assuming one had to repeatedly access/assign a variable that exists outside of the object doing the accessing/assigning, Which would be slower; accessing/assigning a global variable or accessing/assigning another object's variable?
  17. J

    Confused by what this error means?[Solved]

    ERROR!!! :: ############################################################################################ FATAL ERROR in action number 1 of Create Event for object obj_player: global variable <unknown built-in variable>(-1610512733, -2147483648) not set before reading it. at...
  18. R

    How to work variables

    Hello, I'm currently working on a university project and have been advised to use variables to achieve the goals I want for my project. However, the problem is that I don't know how to set them up or how to work them. For my game, I want my character to possess certain abilities when he...
  19. A

    GML Other checkpoints disappear when I collide with specific one

    When I touch obj_checkpoint it is set to change its sprite when it's activated (collide with player). But when the checkpoint I collided with changes its sprite, the other checkpoints disappear. The reasoning behind this code I got from this video by Shaun Spalding. I'm not sure what the...
  20. B

    Changing variables based off rooms

    I have a space level that I want to include in my game. Do I simply make my variables global and go into my room and subtract and add to the variable at will? For example, in the space level I want to decrease the jump speed.
Top