• 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. G

    How do i make tiles sets invisible? but sill have its collision.

    Hi im trying to find out how do i make tiles sets invisible and sill have its collision, I think there was a function called tile_set_alpha but, I think its gone now but sill, how do i make tiles sets invisible?
  2. Leif

    GML Expected number arguments of function

    Good day. Please help to solve syntax issue. I use function, that have four arguments, and all of them are optional. Inside I check all of arguments with is_undefined( _argument ), so there're no compile errors and all works perfectly. BUT: my Syntax Errors tab is full of warnings like...
  3. hakase22

    SOLVED string function is getting me a "wrong number of arguments" message error?

    Here I am again with a new problem. I tried to search it on this forum but nothing seems to be compared to my problem. I am using a string function, which has an optional option where you can use {0} and {1} to store values to "draw" strings dynamically , just like GameMaker Manual says. Nothing...
  4. A Random Creator

    SOLVED Defining functions in a struct and calling them as an instance?

    Hey everyone! So maybe I'm just using structs wrong I'm not really sure, but essentially what I'm trying to do is give my NPC different personality profiles - something like this: BehaviorProfiles = { Aggressive: { Weight:7, //Used for calculating rarity. weight/totalweight =...
  5. E

    GML Create custom function with curly brackets?

    All functions can do is execute code or return a value: func(); x = func(); What if I want to make a function with curly brackets like the "if" function: if true { code; } or "repeat" which has both normal and curly: repeat(420) { code; } or "do/until" which is 2 functions in 1: do { code; }...
  6. L

    What is the point of targets on certain functions (e.g. random number) and what does the value of a variable do?

    Hello, I'm very new to programming so forgive me for being naive, but I'm confused regarding to importance of targets and variable values in GML. How exactly do these work? Thank you.
  7. H

    GML I need help to get sprite at x and y on the asset layer

    I can't find a function that lets me get the name of a sprite in a room on the asset layer based upon the x and y values I give. I hope I'm just blind or stupid. Thank you very much in advance.
  8. AndreLeier

    GML Function returns rounded value

    Hey guys! Firstly I would like to apologize because english no good 😞. But my main issue is that I'm trying to get a really precise probability value, but the function is returning a rounded value. function prob(x, y) { return (score(x)/(score(x)+score(y))); }...
  9. E

    GameMaker Language-specific bug in asset dedection

    Edit: Changed the post title as we know the problem better now. I haven't worked on my project since last November. Today I have downloaded the newest version of GMS2 and when I try to run my game, I get this error...
  10. Xenon

    (Function draw_text ) Text disappears immediately

    When using the "draw_text" function, the text appears in the room for literally one frame. The same thing happens when using any function that starts with "draw". Despite the fact that even if you create a new project with one object and this function, this will still happen. I have not had to...
  11. AnnoyingDoggoX

    SOLVED Undefined position of struct in a ds list

    I can't figure out why the position of a struct in this ds list is "undefined." enemies = ds_list_create(); //this code adds the enemy - pirate wizard and electric jell ds_list_add(enemies, new pirate_wizard()); ds_list_add(enemies, new electric_jell()); //pos in the ds list should be 1 because...
  12. AnnoyingDoggoX

    SOLVED DS Lists & Constructor Functions

    This code is in a create event: ds_list_add(enemies, new electric_jell()); electric_jell() is a constructor function named s_enemies containing this code: function electric_jell() : actor() constructor{ name = "Electric Jell"; //base stats // life max_hp = 60; hp = 60; //...
  13. X

    Functions Cause Memory Leak?

    I've created a set of functions inside a script, but using those functions seem to cause a memory leak. I saw a thread talking about this on the forum, but it was posted in October 2020, and I just found the leak now. I don't know if this helps, but here is my function inside of my script...
  14. D

    SOLVED room_get_width and room_get_height??

    Is there no way to get the current width and height of a room we're not occupying? I can clearly set the width and height of another room but how can there be no accompanying get functions? 🤯
  15. Misael644

    GameMaker Parts of a string not being removed

    I am creating a function that serves as a textbox generator. The function works like this: //the function dialogue_create("Hello,/60 /03this is a test!","character",0,"left",3); //description /// dialogue_create(text,character,expression,pos,speed) /// @arg text /// @arg character /// @arg...
  16. pikachurian

    [Solved] Function/Script Executes Twice Help

    I'm making a turn based battle system. I have a battle manager object with a switch state machine. Each state has code that executes for the first frame in that state. The enemies in the battle are stored in an array in the battle manager. During the first frame in the enemy turn state, the...
  17. 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.
  18. 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...
  19. 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()...
  20. 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...
Top