• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

global variable

  1. 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...
  2. 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
  3. 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?
  4. 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...
  5. 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...
  6. 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...
  7. 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.
  8. J

    [SOLVED] global not set before read

    I have a menu with a play button object. The left mouse event has the following code: room_goto(rm_Level1); When I click, I get this error: obj_counter is an object physically placed in the room. I do not get this error if I place rm_Level1 at the top of the objects list and run it first...
  9. D

    Permanently increasing an objects speed with each click

    Hey guys, Hoping for some help with a problem I can't figure out. I have a ball object in my game that bounces around in random directions upon creation, and off the walls of the room. I have a series of buttons at the bottom of the screen that I want to use to do two things: Change the...
  10. W

    Windows [SOLVED] Not set Before reading it....?

    Hi guys i have a problem on game maker with a game that im working on.... and i keep getting an error tell me that i have not set a value before the program has read it , but i have.... maybe i did it wrong please help and reply ASAP error: global variable <unknown built-in...
  11. K

    Global Variables not working

    I have a obj_variables that is persistent that handles all my global variables for my game. Here is what the code looks like right now In Create globalvar foyerdark; foyerdark = false; In Step if foyerdark = true { with (obj_Foyer) && (obj_picframe_foyer){ image_index = 1;} } if...
  12. C

    Global Variable vs Objects

    General question here. I have an object which spawns blood patterns. An enemy's blood trajectory changes based on how they were killed. I'm thinking about implementing global variables for each. This would mean the game checks global variables for each blood instance. Is this a practical use of...
  13. X

    How to code to store the score in a global variable temporarily then reset the room

    How can i code to store the score in a global variable temporarily then reset the room. Then add code to the oGame creation event where it resets the score. Add a check for that global variable. If the global variable is more than 0 then set score to equal the global variable and make the...
  14. H

    Legacy GM [SOLVED] Lag when checking if joysticks are plugged in

    Hello. I am making a 2 player game, and I need to check if there is 1 or 2 joysticks plugged in. If there is one, player one moves using keyboard. If there is none, player 1 moves with keyboard too. If there are 2 joysticks plugged, player 1 can move with keyboard and with one of the...
  15. T

    [SOLVED] Putting global variable into sprite index?

    Alright so in my game I have a companion creature which will (hopefully) eventually be one of 200 creatures. They also have a battle object and instead of having to write out for every possible companion is it possible to put the global variable inside of the sprite index? Here's what I mean...
  16. F

    Using [font_add_sprite_ext]

    I asked about fonts some time ago at the Game Design, Development and Publishing . I wanted to use font_add_sprite_ext but I had concerns about the memory leak risk. Then I was I told that I can add and store the font in a global variable when the game starts, then the font will be available...
  17. P

    Legacy GM SOLVED: Global Array Reading Problem

    I'm getting some very strange things happening with an array right now, and was wondering if anyone would know what is going on. I have an array (global variable) called targetChara, pertaining to target character information. The array has been set up as shown, in a function called...
  18. R

    I don't understand this error out of range?

    ___________________________________________ ############################################################################################ FATAL ERROR in action number 1 of Draw Event for object obj_input_controller: Push :: Execution Error - Variable Index [1,769] out of range [1,-1] -...
  19. D

    Legacy GM [SOLVED] Where should global variables be initialized?

    Hi, I'm new to GM Studio (running 1.4), and have followed a few tutorials successfully, making a couple simple games. I'm trying to figure out where the best place is to initialize a global variable such that you won't run into the "global variable .... not set before reading it" error. My...
  20. P

    global variable on mulitplayer

    so in frustrations ive scrapped my old character customization design and decided to refrence a tutorial. specificly this one- for the TLDR's here- basically he uses global variables to know what sprites to use in his character. if i were to use that method, would it be multiplayer...
Top