• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

return

  1. 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...
  2. MIkadini

    GML Script Return don't work

    I've try to make a simple script that simply increment a number that we pass in the argument. In my object i call this script function every step and the variable is crate in the create section and not in the step section. this is my code, the resoult in the console isn't increment and simply...
  3. XirmiX

    Legacy GM What happens to lists and maps in these instances?

    Wondering what would happen in these cases to lists and maps. Picture that they are in a script, and when a script is called with either of these pieces of code in, I'm interested in knowing what will happen in terms of garbage collection; will the list or map be destroyed or hang around filling...
  4. XirmiX

    GML [SOLVED] Convert string to keyboard input or return keyboard input?

    Is it possible to convert a string to a keyboard input? Say I have "mouse_x" string variable and I want to create a new variable that holds keyboard input and takes that string variable to get what key the variable will be set to? Or may be it's possible to set in a list a key value? I've tried...
  5. N

    Legacy GM When this, skip the next ?

    Hi. I have a quick question, this is my code: if (!place_meeting(x+sign(hsp),y-8,par_ground) && !place_meeting(x+sign(hsp),y-8,obj_pipe)) { with (obj_oneway) { if (place_meeting(x-sign(other.hsp),y+8,other)) { if !(bbox_top > other.bbox_bottom) {...
  6. Fixer90

    GMS 2 Returning a function in a script? (SOLVED)

    After getting GMS 2, I noticed that one of the compatibility scripts (the one for instance_create) used return before its function. Here's the code for reference: var d = object_get_depth(argument2); return instance_create_depth(argument0, argument1, d, argument2); What I'm wondering is, what...
  7. S

    The Return statement doesn't work in the script

    Hi, In a nutshell, I want to use the scr_zx() I created besides this: if (keyboard_check_pressed(ord('Z')) or keyboard_check_pressed(ord('X'))) so I created the scr_zx() function where i've put: return (keyboard_check_pressed(ord('Z')) or keyboard_check_pressed(ord('X'))) then I replaced the...
  8. N

    GMS 2 Returning array from script

    I vaguely recall some functions returning an array, but it doesn't seem to work for me. Say you have a script that fills a local array with values, is it possible to return the array and end up with something like this? ///script_array() var array array[0] = 10 array[1] = 11 array[2] = 12...
  9. D

    GMS 2 instance_position(xLocation,yLocation,all); returning 100099

    For some reason instance_position(xLocation,yLocation,all) is returning 100099 instead of -4 (or noone) like it should. It appears that the first time the code is run it returns -4. However, the second time it returns 100099 which is not the ID of any object and causes issues further down the...
  10. T

    GMS 2 Returning Physics_World Variables

    Hello, does anyone know how to return values such as gravity in the current room or if physics are enabled in the current room? I have looked at: https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/physics/the physics world/index.html...
  11. Cantavanda

    GML The return statement

    The return statement, what does it do? Hiya! I've been busy learning GML recently, and if there's one thing I don't understand, and just can't find a clear answer for (manual, forums) it's what the term returning a value means, and what the return statement does. Could someone explain it in...
  12. U

    Error in function exp()

    Hello everyone. I am running a script called sigma within the object obj Create Event. This script is as simple as this: return 1/(1+exp(-argument0)) which is returning the output of the logistic function. I don't see anything wrong with the code. However, sometimes I'd say like 1/5 of the...
  13. R

    Formulas returning NaN [SOLVED]

    I've This code event_inherited(); //parent gives his code slider_value = obj_options_menu_controller.surf_height; instance_create(x,y,obj_vbar); obj_vbar_parent.scroll_power = 20; obj_vbar_parent.slider_px_height = sprite_height; obj_vbar_parent.real_slider_height = slider_value...
  14. R

    returning an argument in a script, gone wrong I guess?

    position = argument0; key_kind = argument1; if(mouse_check_button_pressed(mb_left) && point_in_rectangle(mouse_x,mouse_y,x_pos+first_line-(button_size/2),y_pos*position-(button_size/2),x_pos+first_line+(button_size/2),y_pos*position+(button_size/2))) { key_kind = position; inside_region = true...
  15. A

    [SOLVED] How do I check which value in array is active?

    Sorry if the question was a little hard to understand. I'll try and break it down: i've initialized an array cRect[ ] to hold the returned values of a collision check for various collision rectangles. for (n = 0; n < arbitraryNumber; n++){ cRect[n] = collision_rectangle(32, 32 * n, 64, 64...
Top