function

  1. FoxyOfJungle

    SOLVED How many times can I call gml_pragma("global")?

    Hi! I have a question, can I assign a function to run in gml_pragma("global", ...) more than once? Example: gml_pragma("global", "init_global_variables();"); gml_pragma("global", "init_shader_uniforms();"); Will this work? Thanks! Edit: fixed typo.
  2. FoxyOfJungle

    SOLVED Unable to get object for index 100001 ???

    Hi! It's the first time I've seen this error specifically. I'm starting to think it's a bug (or I don't understand this behavior), but I'll try to explain: #1 - I have this code in a script file (GML): Code 1: enum ENUM { ITEM1, ITEM2 } function ftr_setup() { global.list_of_itens...
  3. Joe_La_Bricole

    Asign funtions in structs

    Hello ! I would like to declare a function in a script and then assign this funtion to a variable in a struct to call that function. Is that possible and if yes how ? Here is a little example : function message() { show_debug_message("this is a message"); } function struct_with_message()...
  4. Gunnar the Clovis

    SOLVED [SOLVED] Passing object_index to function instead of one instance / Making functions work like with (kinda)

    Howdy, I assumed this would be an easy issue / have tons of similar threads on it already, but I can't seem to find any. What I'm trying to do I thought would be very simple, but it's proving to be troubling for me. Hopefully I'm just being stupid and there is an easy solution: I want to...
  5. N

    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.
  6. 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...
  7. xDGameStudios

    GMS 2.3+ [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...
  8. 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...
  9. T

    GMS 2.3+ 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...
  10. 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() { ...... }
  11. L

    GMS 2.3+ 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)
  12. 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...
  13. X

    GMS 2.3+ 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...
  14. itarkytec

    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...
  15. 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...
  16. Arilyn

    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...
  17. 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...
  18. The_Scientist___

    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...
  19. FrostyCat

    GMS 2.3+ IMPORTANT!!! GM 2.3 Users Please Read! Improper script usage generates 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...
  20. 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...
Top