variable

  1. T

    Giving a colliding object your variable value.

    I have a game which has the main character (a light bulb boy) interacting with several intractable electric objects. The electric objects have two main "states" (though no real state system has been implemented yet), where they are either turned on or off as indicated by sprites. I have a system...
  2. G

    Drag And Drop Creating an instance using a variable.

    When creating an instance, is it possible to use a variable containing the object name instead of the object name itself? Whenever I try doing this, it results in an error.
  3. M

    GMS 2 Difference between undefined and variable not set.

    Hi there, first post so don't kill me here. Can someone explain the difference between a variable that's undefined and not set? It's just I'm used to JavaScript where they're the same thing. The reason I ask is sometimes I try to handle this by doing say if (is_undefined(fullScreen)) fullScreen...
  4. FoxyOfJungle

    GMS 2.3+ Update variable in step event without initialize it in the create event?

    It seems a little strange, but let's say I don't want to initialize a variable in the create event and just use the Draw event, is there any way to make that variable change without being started? I managed to do something like this: if !variable_instance_exists(object_index, "variable") var...
  5. C

    SOLVED Collision checks in local variables executes slower?

    Hello! I found something interesting while messing around with my code. Here it is, clearly following one of Shaun Spaulding's tutorials: In the Step Event: #region//set controls key_left = (keyboard_check(vk_left)) || (keyboard_check(ord("A"))); key_right = (keyboard_check(vk_right)) ||...
  6. KyleRansford

    GMS 2.3+ Solved Help with understanding error type

    Hello, everyone, I've actually upgraded to GMS 2.3.1 and for the most part, everything is working well. But, when I imported a project I was working on in 2.2, it was working well, but, since importing it into GMS 2.3.1, some aspects of the game don't work like they should. For instance, the...
  7. 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)...
  8. 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:
  9. 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"...
  10. 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...
  11. 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?
  12. 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...
  13. 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...
  14. 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...
  15. 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...
  16. 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.
  17. 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...
  18. 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...
  19. 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...
  20. 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 }
Top