• 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!

function

  1. Nick der mit hut

    SOLVED Easy way to clamp to 0 after a certain number has been reached?

    Hi, I have the variable speed = 8 In my step its: speed *= 0.9; and I want it to jump to 0 after its below 1. Do I always have to write if (speed < 1) speed = 0; ? or is there an easy function like clamp, min, max etc.
  2. Misael644

    SOLVED Any function or code that works like "draw a line for the instance whose variable is x?

    Hello! So, basically I want to make a code that is like: "draw a line for the instance whose variable is x". I thought about using instance_find to do this, but it only works like "I will only draw a line if the instance id is x". I wanted to use such a function to make "line graphics", which...
  3. xDGameStudios

    [TEXT TUTORIAL] Keyword "function" & Methods Explained

    GM Version: Studio 2.3+ Target Platform: Windows / All Download: n/a Links: n/a [THEME] Today we will be talking about functions, so this tutorial will be about the function keyword and the method() function. In the in-betweens, I will also talk about binding. What is it and why is it important...
  4. G

    Windows Upgrade function issues | Store Variable in Variable

    Hello, I have been working on my second game for a month now and wanted to add a series of upgrade Buttons to give the Player the ability to improve their stats (walking speed, mining speed etc.). I wrote a function that is supposed to be triggered if my button gets pressed. That works perfectly...
  5. T

    Strange struct variable behavior

    I have seen an strange behavior when declaring variables inside structs. The following code returns the x value of the instance that creates the struct even though it should return an error. I discovered this tracing a bug for a much bigger struct that I'm using and I really don't understand it...
  6. S

    GMS 2 Function in diffrent object event

    Is it possible for example to call a function in a step event, that is inside the draw event of that object? Like : Step event : DrawShadow() Draw event : function DrawShadow() { ...... }
  7. L

    How to create private function?

    I didn't find the way to approach it. All functions are global whether they are in script or in obj. when project gets bigger, it will be very terrible... (the "private" means non-global)
  8. Misael644

    SOLVED Any string function that works in a similar way to "string_format"?

    So, suppose I have a string of numbers whose value is "1234". I want only the first two digits, "12". Or another string whose value is 6. I want it to be 06. I thought about using the "string_format" function, but it's not exactly what I want. I want to use to make timers in the hh:mm:ss format...
  9. X

    Override a function of a parent object in the child object.

    Hello everybody, I've quite a little diffculty on something. Here is the recap : I have an object obj_aaa_par with a function in his create event : function generic_func(_var) constructor { obj_idx = _var.object_index; x = _var.x; y = _var.y; name = _var.name; } This...
  10. I

    Windows Need help making a string

    Hola comunidad, estoy necesitando un poco de ayuda, agradecería que las respuestas a este post estén preferiblemente en español, aunque si es de ayuda no me molestaría en recibirla de todas maneras. Contexto: estoy intentando hacer un cuadro de texto que solo acepte números como entrada...
  11. xDGameStudios

    Asset - Scripts [BUFFERS] xBufferFunctions is a collection of advanced buffer functions (FREE)

    [LINKS] https://marketplace.yoyogames.com/assets/9587/xbufferfunctions https://xdstudios.itch.io/xbufferfunctions [INFORMATION] This asset is composed by a set of buffer functions that allow for complex buffer parsing. Functions allow to seek and match patterns, copy regions (using read...
  12. A

    Variable <unknown_object>.instance_create() not set before reading it.

    Hello, I'm pretty new to game maker but I've messed around with Unity a lot in the past. I've hit a roadblock and haven't been able to figure out why I'm getting errors despite researching and reading the documentation, but it's probably because I don't quite understand how GML and scripts...
  13. W

    Can't assign a return to a variable

    I made (borrowed) a script for drawing buttons to gui and it works perfectly, except I cannot seem to assign a variable to the returned value. Here is the script: /// @function draw_gui_button_sprite(sprite, index, x, y, width, height, main_view); /// @param {index} sprite The sprite to...
  14. T

    draw_rectangle() Problems with Transparency

    I'm trying to make a textbox that appears when the mouse hovers over the object, and I'm drawing a rectangle as a backdrop for it. However, if the object is far enough to the right, I want to make it draw in the opposite direction, but when I do, it turns semi-transparent and draws behind other...
  15. FrostyCat

    IMPORTANT!!! GM 2022+ and 2.3+ users please read! Obsolete script syntax causes undefined variable errors

    Symptoms to Look For Expand for screenshot: The error is in the Create Event for object <undefined>. The subject is <unknown object> with a variable name that's either built-in or known to be already declared. The stack trace shows the source as something starting with gml_GlobalScript. For...
  16. ZacKow264

    SOLVED Opening windows in code?

    Simple question, is there a way to open new windows in code? Like a second window for the game? What are the limitations of this, if it's possible? Does anyone know? This would be in the actual game itself. So I want to basically open another window automatically while the game is running. Is...
  17. D

    Nesting functions

    Hello, I wonder if this is a bug or not... func_1 = function(){ code } func_2 = function(){ func_1(); code } When I place this in a create event, it calls the func_1 code without me executing func_2.... Is this a bug or is it not allowed to nest functions like this? Im...
  18. G

    How to play once the animation of die before function( game_restart(); )

    I'm making 2d platformer in GMS Language. I've a varibale "hpHero" and i did like " if hpHero=0 { game_restart(); } but I need to play the animation of die before game will restart,pls help me
  19. FoxyOfJungle

    GameMaker [SOLVED] zip_unzip() - How to save in a different location?

    The new version of Game Maker Studio 2.2.3.436 lets you disable the engine sandbox, this works with the "file_" functions, but doesn't work with zip_unzip(). Is there any way to extract a zip to any location outside of "appdata"? I'm basically doing an update system, and I need to extract the...
  20. S

    GameMaker Is there SDK or a hack/way to call GML builtin function from external side?

    Hello, This would be my second post (as well as thread) :) The title pretty much says it all about here. In my previous thread, I have talked a bit about my first extension (in my first game built using GameMaker). So far I have been able to call external functions from GML scripts. Our...
Top