GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-07-04 09:50:32

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

GM8 - Scripts that do not work

Some functions in GM8 have changed from their GM7 ancestors. That means some scripts on GMLscripts.com will not work under GM8. Post any you find here.

Status - Script
Broken - collision_triangle_init


Abusing forum power since 1986.

Offline

#2 2009-07-04 12:10:37

paul23
Member
Registered: 2007-10-17
Posts: 110

Re: GM8 - Scripts that do not work

all sprite/background resource functions are broken. Since the preload modifier is now always set to "true" (at least some memory viewers make it seem as if the resources are loaded in the video memory always. - But I don't have really very good tools for that)...

Maybe an idea (so those who keep using GM7/6 have better compatibility): maybe add a field at the script-page to indicate with which version of gamemaker the script works?

Offline

#3 2009-07-04 12:12:54

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: GM8 - Scripts that do not work

Yeah, it's obvious I'm going to have to do that. It's something I'd like, it's just more work I gotta do. I guess I've got about a month to get that done.


Abusing forum power since 1986.

Offline

#4 2009-07-27 03:01:35

Big J
Member
Registered: 2009-07-26
Posts: 5

Re: GM8 - Scripts that do not work

There's a typo in the collision_triangle() script:

    // Bounding box check
    xmin = min(x1,x2,x3);
    xmax = maX(x1,x2,x3); //Typo is here, maX() you need max()
    ymin = min(y1,y2,y3);
    ymax = max(y1,y2,y3);
    if (not collision_rectangle(xmin,ymin,xmax,ymax,object,false,false)) return false;

EDIT: Oh, the code tag here auto highlights. biggrin I wish the GMC code tags did that.

Last edited by Big J (2009-07-27 03:05:20)

Offline

#5 2009-07-27 05:04:45

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: GM8 - Scripts that do not work

Huh, wonder how that happened? Fixed it.

If you use Firefox (and maybe some other browsers) you can get code highlighting at GMC. It's pretty cool and works well. Script requires Greasemonkey. More info here:

http://gmc.yoyogames.com/index.php?showtopic=427086

I usually browse with Chrome so I miss out. When I switch to Firefox, it's always a nice surprise to see highlighted code.


Abusing forum power since 1986.

Offline

#6 2010-01-13 13:16:52

paul23
Member
Registered: 2007-10-17
Posts: 110

Re: GM8 - Scripts that do not work

Is this a generic 'broken-scripts' thread? (if so, lemme search my computer I've somewhere a list of all scripts which ought to be updated, pre-gm8 already).

Offline

#7 2010-01-13 17:53:13

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: GM8 - Scripts that do not work

Yes, please post links or name any scripts that need to be changed to work in GM8.


Abusing forum power since 1986.

Offline

#8 2010-01-20 12:32:29

paul23
Member
Registered: 2007-10-17
Posts: 110

Re: GM8 - Scripts that do not work

Ok, had 2 days of spare times (without internet) so I thought: why not?

I've worked my way through the list of all gmscripts-scripts (those that come with the download).

There were a few bugs I could easily fix, a few suggestions I have to change some functionality (internal things in a script), a few suggestions I have to change the "interface" (way you should call those scripts), a few suggestions for "logical" extra scripts. A list of bugs I fixed, a list of bugs I couldn't fix, a list of "questions" about certain things.. And a long list of scripts I didn't thoroughly check (either because I don't have the expertise, I didn't have the time or I simply didn't feel like doing it).

A few general suggestions I have:
-What's actually the USE of removeback option in sprite_create_from_surface? - I mean, the surfaces can already hold alpha values, so why the need to remove the background (one should always clear the surface anyways before drawing).. In most scripts (apart from sprite_edit_end, where it might not be what we want) I simply set this argument to "true" in case there was an accidental call to draw_clear instead of draw_clear_alpha.
-there's no way to get the smoothness from the sprite! - I simply made always the "smooth" part to true in all sprite-creation functions (apart from draw_rectangle_dashed). However is this good/bad??
-Many functions seemed to be made for a 'specific' case: a good example is "factor_quadratic()" function: it returns a STRING like "(x + 8) * (x - 2)" - Very nice if we want to display it on the screen, however if we want to do something MORE with those factors it's a pain to extract the string again. (There are more examples, but this was the most notoire)
-Also some functions (gauss ie) seemed kind of "randomly thought" to me: it does 6 times a random number and then takes the average (or something like that): WHY 6?
-Finally some function could use a better description (gain, step etc)

Download updates.zip there you can find a zip file with all suggestions/fixes. (I recon this post is going to be pretty large/unreadable)

I'll first post the bugs (fixes), and suggestions and at the bottom of this post there's a long list with all the updated scripts:

fixed bugs
**added functions: map_background_if, map_fonts_if, map_objects_if, map_paths_if, map_rooms_if,map_sounds_if,map_sprites_if,map_timelines_if
**collision_triangle: revamped  made new resources more expicit (so we can add "collision_triangle_deinit")
**collision_triangle_init, redone
**added: collision_triangle_deinit
**added: collision_triangle_list
**d3d_model_copy: change "working_directory" to "temp_directory" (better chance for write-permission on newer OS)
**draw_background_tiled_area: rearranged. (x/width calculation to outer loop)
**draw_background_tiled_area_ext: used argument8,9 instead of 7,8.. Also added the arguments for xscale,yscale. (to represent better _ext functions)
**draw_background_tiled_area_ext: completely redone!
**draw_rectangle_dashed, line 33:         global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,true,false,0,0);
**draw_rectangle_dashed_color, line 33:   global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,true,false,0,0);
**draw_sprite_inverted(sprite,subimg,x,y): script wrongly named "draw_sprite_hud" - also line 62 updated
**draw_sprite_tiled_area: script was wrongly named
**draw_sprite_tiled_area: rearranged. (x/width calculation to the outer loop)
**draw_sprite_tiled_area_ext: completely redone! (added functionality for xscale/yscale)
**draw_text_shadow: changed line 37/67 from draw_text_ext() to draw_text()..
**ds_list_median: line 17: ds_list_copy(j,argument0);
**ds_map_mirror: added "note: it's up to the caller to make sure no values are 2 times in the map"
**exp_dist: script wrongly named gauss
**instance_nth_farthest: change name to "instance_nth_furthest":
**map_backgrounds, line 16:    no = background_create_color(1,1,c_white);
**map_fonts: changed line 16 to "    no = font_add("arial",12,false,false,32,32);" - changed references to PATHS to fonts.
**map_sprites, line 16:     no = sprite_create_from_screen(0,0,1,1,false,false,0,0);
**motion_blur: changed line 21 var i, length,stp,dir,px,py,a; Changed names "step" to stp..
**polygon_area: change loop to do 2i increments each step
**polygon_centroid: change loop to do "2" increments each step.
**save_screenshot: changed line 22 to "        fname = working_directory+"\"+argument1+argument0+"_"+string(i)+".png";" - new default is png images
**speakable_password, line 17:         if !(i & 1) result += string_char_at("aeiou",floor(random(5))+1);
**speakable_password, line 18:         else result += string_char_at("bcdfghjklmnprstwyz",floor(random(18))+1);
**sprite_desaturate: revamped! (NEED advanced checking, are alpha sprites needed these days?)
**sprite_edit_end: revamped!
**sprite_invert_color: revamped (NEED advanced checking, are alpha sprites needed these days?)
**sprite_replace_color: revamped (NEED advanced checking, are alpha sprites needed these days?)
**sprite_replace_color_blend: revamped (NEED advanced checking, are alpha sprites needed these days?)
**string_escape: replace string_copy(str,X,1) with string_char_at(str,X)
**string_parse: rearranged. DIFFERENT BEHAVIOR WITH OLD: if the string ends with a token, and ignore is false: the "post end" (empty) string is added too.
**string_parse_number: big revamp (what was the use of using substr as ONLY a lvalue? - also use string_count is faster in case empty spaces are not ignored). DIFFERENT BEHAVIOUR (see string_parse).
**string_shuffle: revamped (was pretty naive) - ALSO: notice it uses another method than for ds_grid_shuffle (1 method should be used)
**string_split: line 21 removed (76 is way to random)
**string_stagger_case: revamped (removed ugly "continue" statement, and rearranged the code so it works
**string_width_limit, line 13 added: "**      with the current font settings" for clarity
**string_width_wrap, revamped (pos_currently shouldn't be reset to 1, string_delete instead of string_copy, removed for null string check)

non fixed bugs
**draw_sprite_hud: it's broken (for one it only uses view[0])!
**draw_text_hud: it's broken (for one it only uses view[0])!
**draw_sprite_inverted: is there no better method (this one has potentional for lots of bugs, what if the screen isn't cleared before the function?)
**draw_sprite_inverted: in current form better would be: make_image_inverted. - which returns a newly created sprite
**ds_map_load: HUH, broken, only uses comma as seperator (+ it's very slow method: first creating a long string from lines, then reading those lines back into a map)
**ds_map_load:    Suggestion: add a version with 2 delimiters, to handle keys,values;morekeys,morevalues;
**ds_map_save: HUH, broken, only uses comma as seperator (+ it's very slow method: first creating a long string from lines, then reading those lines back into a map)
**ds_map_save: Suggestion: add a version with 2 delimiters, to handle keys,values;morekeys,morevalues;
**motion_blur: bugs around "corners" (unfixable though without a real engine)
**normal_detect: shouldn't line 34 be:"         for (j=0; j<=rad; j+=res) {" instead of "         for (j=res; j<=rad; j+=res) {" - if I am correct it does a pixel-by-pixel check in the circel around the point, with setting j to 0 it also checks directly above/below..

functionality suggestions
**base_convert possibly make it with user-inputted string (ie: base_convert(01234,ADSFGHEIJ) would convert a base-5 number with 01234 as numbers to a base 9 number with ADSFGHEIJ - or maybe base_convert(01234565789A,11,2))
**draw_get_button: change interface to draw_get_button(x,y,x2,y2,DRAWSCRIPT), where DRAWSCRIPT is a user script taking the parameters: (x,y,x2,y2,pressed) (or: (x,y,x2,y2,in,press) )
**dateformat: add \\ mark.. Also: format-strings seem kind of random (are there standardized letters?)
**draw_rectangle_dashed/color: create also an initialize/deinitialize function for it (like triangle collisions)
**draw_rectangle_dashed/color: (and by forcing those 2 not to be executed in the draw event you prevent the call to draw_getpixel).
**draw_sprite_percent: uses "round" which statistically rounds a variable (so 0.5 -> 0, 1.5 -> 2) - better uses floor(x+0.5)
**draw_sprite_stretched_direction, let it take x and y, as SEEN scaling (possibly new function?)
**draw_sprite_wave: isn't it possible & faster with using textures and models/vertices?
**ds_grid_swap: can be updated with new functionality ds_grid_set_grid_region.. (now working)
**erf: lookup on the internet (possibly cleaner solution)
**factorial: include non recursive function
**factor_quadratic: update it to return a list instead of string? (or another, real-data container)****
**fibonacci, replace that name by "fibonacci_approach" and add the function "fibonacci" which does the real work
**gauss: rather "random" function (why use the number '6')
**instance_find_enemy/friend/team: change to "instance_nearest_enemy/friend/team".. (and add function for furtherst? - or even a generic function?)
**instance_find_enemy/friend/team: depend on a local variable that is rather "random"/"common".
**roll_dice: possibly a simple function instead of this loop-structure?
**sprite_edit_begin: change the return to a numeral (as session id): formula? - use fraction/int part (accurate?)?
**string_width_wrap: Maybe make specific case for "non forced" wrapping (only need to check the spaces here). - also: what happens to the spaces?

interface suggestions
**collision_*_list: remove the "noone" check (so the returned value is always a list, and not another "type", also the user could then easily change the value)
**draw_arc/draw_pie: base it on direction rather than 4 points?
**draw_sprite_percent(sprite,amount,x,y,restrict), replace by a function that instead of taking the percentage takes a "part" (scaled from 0 - 1)
**ds_map_mirror: Suggestion: change the interface to: newmap = ds_map_mirror(dsid).. - and don't change dsid. (it's both faster, and allows the user to have more functionality)
**explode_real/_string: don't use an array (all other functions that report multiple data points use lists)
**explode_real/string: switch data/sep arguments, make sep maybe optional? (and abuse the fact that the "NULL" character is treated specially?)
**implode_real/_string: use lists instead of arrays (if explode also uses that is)
**implode_real/_string: move sep argumant to the last 1 (and possibly optional?)
**intercept_course: let it accept coordinates instead of instances?
**polygon_area/polygon_centroid: take 2 lists instead of 1, map maybe?
**smoothstep, shouldn't throw (return a/b if they're the same)
**spline: use list instead of "knotarray"?
**suggestion: prefix all globals with "GS_"

new script suggestions
hex_to_color()
color_to_hex()
draw_sprite_flip()
ds_list_find_if()
rotN() (generic form or rot13() )
string_add_char() (generic form of string_add_spaces)
bitwise_reverseN()
draw_*_inverted() (for all standard shapes/added shapes?)
draw_text_shadow_ext()
joystick_get_button_list()

questions
**color_to_wavelength: ?? everything with the same hue gets the same wavelength?
**decel_distance?
**round_fixed: notice that round uses the statistical rounding (possibly idea for other script)
**string_wordwrap: what's it supposed to do? if it word wraps based on the NUMBER OF CHARACTERS: revamp needed!!!!
**acos, asin  (how are they made?)
**combination: shouldn't it be possible to create/use a simple formula?
**draw_chord: possibly updating using surfaces (draw circle, remove rectangle: then you have a chord).. Not sure what's faster
**draw_curve: what curvature type?
**is_clockwise: broken (define clockwise for 3 points?) ie: 0,0 - 0,1 - 1,1 would return "false"
**sprite_edit_begin: does the function work with the new blend modes (specifically draw_set_blend_mode_ext(bm_one,bm_zero))

Offline

#9 2010-01-20 12:33:07

paul23
Member
Registered: 2007-10-17
Posts: 110

Re: GM8 - Scripts that do not work

followed by all the fixed scripts

/*
**  Usage:
**      collision_triangle_list(x1,y1,x2,y2,x3,y3,object)
**
**  Arguments:
**      x1,y1     first point of triangle
**      x2,y2     second point of triangle
**      x3,y3     third point of triangle
**      object    an object or instance to check for collision
**
**  Returns:
**      a ds_list id, or keyword noone if no instances are found
**
**  Notes:
**      Must be initialized with collision_triangle_init() before use.
**
**  GMLscripts.com
*/
{
    var x1,y1,x2,y2,x3,y3,object,xmin,xmax,ymin,ymax,d12,d13,d23,d14,d24,t,dx,dy,x4,y4,that,this,dsid,i;
    x1 = argument0;
    y1 = argument1;
    x2 = argument2;
    y2 = argument3;
    x3 = argument4;
    y3 = argument5;
    object = argument6;
    // Bounding box check
    xmin = min(x1,x2,x3);
    xmax = max(x1,x2,x3);
    ymin = min(y1,y2,y3);
    ymax = max(y1,y2,y3);
    if (! collision_rectangle(xmin,ymin,xmax,ymax,object,false,false)) return noone;

    // Find long side, make it (x1,y2) to (x2,y2)
    d12 = point_distance(x1,y1,x2,y2);
    d13 = point_distance(x1,y1,x3,y3);
    d23 = point_distance(x2,y2,x3,y3);
    switch (max(d12,d13,d23)) {
        case d13:
            t = x2; x2 = x3; x3 = t;
            t = y2; y2 = y3; y3 = t;
            d12 = d13;
            break;
        case d23:
            t = x1; x1 = x3; x3 = t;
            t = y1; y1 = y3; y3 = t;
            d12 = d23;
            break;
    }
    // From (x3,y3), find nearest point on long side (x4,y4).
    dx = x2 - x1;
    dy = y2 - y1;
    if ((dx == 0) && (dy == 0)) {
        x4 = x1;
        y4 = y1;
    }else{
        t = ((x3 - x1) * dx + (y3 - y1) * dy) / (d12 * d12);
        x4 = x1 + t * dx;
        y4 = y1 + t * dy;
    }
  
    // A line constructed from (x3,y3) to (x4,y4) divides
    // the original triangle into two right triangles.
    // Fit the collision mask into these triangles.
    d14 = point_distance(x1,y1,x4,y4);
    d24 = d12 - d14;
    r = false;
    dsid = ds_list_create();
    with (instance_create(0,0,global.GS_objCollisionTriangle)) {
        image_angle  = point_direction(x1,y1,x4,y4);
        image_xscale = d14 / size;
        image_yscale = point_distance(x3,y3,x4,y4) / size;
        if ((x1 > x4) ^^ (y3 < y4)) image_yscale *= -1;
    }
    with (instance_create(0,0,global.GS_objCollisionTriangle)) {
        image_angle  = point_direction(x1,y1,x4,y4);
        image_xscale = -d24 / size;
        image_yscale = point_distance(x3,y3,x4,y4) / size;
        if ((x1 > x4) ^^ (y3 < y4)) image_yscale *= -1;
    }
    with (object) {
        that = id;
        with (global.GS_objCollisionTriangle) {
            i = instance_place(x4,y4,that);
            if (i != noone) ds_list_add(dsid,i);
        }
    }
    with (global.GS_objCollisionTriangle) {
        instance_destroy();
    }
    if (ds_list_empty(dsid)) {
        ds_list_destroy(dsid);
        dsid = noone;
    }
    return dsid;
}
/*
**  Usage:
**      collision_triangle_uninit(size)
**
**  Arguments:
**
**  Returns:
**      nothing
**
**  Notes:
**      deletes possible object & sprite inside the globalvariables GS_objCollisionTriangle and GS_sprCollisionTriangle
**
**  GMLscripts.com
*/

{
    if (variable_global_exists("GS_objCollisionTriangle")) {
        if (object_exists(global.GS_objCollisionTriangle)) {
            object_delete(global.GS_objCollisionTriangle);
        }
    }
    if (variable_global_exists("GS_sprCollisionTriangle")) {
        if (sprite_exists(global.GS_sprCollisionTriangle)) {
            sprite_delete(global.GS_sprCollisionTriangle);
        }
    }
}
/*
**  Usage:
**      collision_triangle(x1,y1,x2,y2,x3,y3,object)
**
**  Arguments:
**      x1,y1     first point of triangle
**      x2,y2     second point of triangle
**      x3,y3     third point of triangle
**      object    an object or instance to check for collision
**
**  Returns:
**      (true) if there is a collision between the given
**      triangle and the given object, (false) otherwise
**
**  Notes:
**      Must be initialized with collision_triangle_init() before use.
**
**  GMLscripts.com
*/
{
   var x1,y1,x2,y2,x3,y3,object,xmin,xmax,ymin,ymax,d12,d13,d23,d14,d24,t,dx,dy,x4,y4,r;
   x1 = argument0;
   y1 = argument1;
   x2 = argument2;
   y2 = argument3;
   x3 = argument4;
   y3 = argument5;
   object = argument6;
   
   // Bounding box check
   xmin = min(x1,x2,x3);
   xmax = max(x1,x2,x3);
   ymin = min(y1,y2,y3);
   ymax = max(y1,y2,y3);
   if (!collision_rectangle(xmin,ymin,xmax,ymax,object,false,false)) return false;
   
   // Triangle perimeter check
   if (collision_line(x1,y1,x2,y2,object,true,false)) return true;
   if (collision_line(x1,y1,x3,y3,object,true,false)) return true;
   if (collision_line(x2,y2,x3,y3,object,true,false)) return true;

   // Find long side, make it (x1,y2) to (x2,y2)
   d12 = point_distance(x1,y1,x2,y2);
   d13 = point_distance(x1,y1,x3,y3);
   d23 = point_distance(x2,y2,x3,y3);
   switch (max(d12,d13,d23)) {
       case d13:
           t = x2; x2 = x3; x3 = t;
           t = y2; y2 = y3; y3 = t;
           d12 = d13;
           break;
       case d23:
           t = x1; x1 = x3; x3 = t;
           t = y1; y1 = y3; y3 = t;
           d12 = d23;
           break;
   }
   
   // From (x3,y3), find nearest point on long side (x4,y4).
   dx = x2 - x1;
   dy = y2 - y1;
   if ((dx == 0) && (dy == 0)) {
       x4 = x1;
       y4 = y1;
   }else{
       t = ((x3 - x1) * dx + (y3 - y1) * dy) / (d12 * d12);
       x4 = x1 + t * dx;
       y4 = y1 + t * dy;
   }
   
   // A line constructed from (x3,y3) to (x4,y4) divides
   // the original triangle into two right triangles.
   // Fit the collision mask into these triangles.
   d14 = point_distance(x1,y1,x4,y4);
   d24 = d12 - d14;
   r = false;
   with (instance_create(0,0,global.GS_objCollisionTriangle)) {
       image_angle  = point_direction(x1,y1,x4,y4);
       image_xscale = d14 / size;
       image_yscale = point_distance(x3,y3,x4,y4) / size;
       if ((x1 > x4) ^^ (y3 < y4)) image_yscale *= -1;
       if (place_meeting(x4,y4,object)) {
           r = true;
       }
       else {
           image_xscale = -d24 / size;
           if (place_meeting(x4,y4,object)) r = true;
       }
       instance_destroy();
   }
   return r;
}
/*
**  Usage:
**      collision_triangle_init(size)
**
**  Arguments:
**      size      size of the test triangle in pixels
**                increase size to increase accuracy
**
**  Returns:
**      nothing
**
**  Notes:
**      Creates an object, a sprite, and global variables called objCollisionTriangle sprCollisionTriangle
**      Don't call this script during the draw event!
**
**  GMLscripts.com
*/
{
    var size;
    size = argument0;
    if (!variable_global_exists("GS_objCollisionTriangle") ) {
        global.GS_objCollisionTriangle = object_add();
        object_event_add(global.GS_objCollisionTriangle,ev_create,0,"size = "+string(size));
    } else if (!object_exists(global.GS_objCollisionTriangle)) {
        global.GS_objCollisionTriangle = object_add();
        object_event_add(global.GS_objCollisionTriangle,ev_create,0,"size = "+string(size));
    }
    if (variable_global_exists("GS_sprCollisionTriangle")) {
        if (sprite_exists(global.GS_sprCollisionTriangle)) {
            sprite_delete(global.GS_sprCollisionTriangle);
        }
    }
    draw_clear(c_black);
    color = draw_get_color();
    draw_set_color(c_white);
    draw_set_alpha(1);
    draw_triangle(size,size,size,0,0,0,false);
    draw_set_color(color);
    GS_sprCollisionTriangle = sprite_create_from_screen(0,0,size,size,true,false,size,0);
    object_set_sprite(global.GS_objCollisionTriangle,GS_sprCollisionTriangle);
}
/*
**  Usage:
**      sprite_desaturate(sprite)
**
**  Arguments:
**      sprite      sprite to change
**
**  Returns:
**      (-1) on error
**
**  Notes:
**      This script converts a sprite to grayscale.
**      No new sprites are created, the given sprite is changed.
**      Blending mode is reset to normal.
**
**  GMLscripts.com
*/
{
    var sprite,w,h,n,p,s,l,xo,yo,surf,i,newsprite,alphasprite;
    sprite = argument0;

    w  = sprite_get_width(sprite);
    h  = sprite_get_height(sprite);
    n  = sprite_get_number(sprite);
//    p  = sprite_get_precise(sprite);
//    s  = sprite_get_smooth(sprite);
//    l  = sprite_get_preload(sprite);
    s = false; //PROBLEM HERE! - no possible way to GET the smoothiness of a sprite, so we don't knkow if the new sprite needs to be smoothed..
    
    
    xo = sprite_get_xoffset(sprite);
    yo = sprite_get_yoffset(sprite);
    
    surf = surface_create(w,h);
    if (surf < 0) return -1;
    surface_set_target(surf);
    draw_clear_alpha(c_white,1);
    tempsprite = sprite_create_from_surface(surf,0,0,w,h,true,s,xo,yo);
    if (tempsprite < 0) {
        surface_free(surf);
        surface_reset_target();
        return -1;
    }
    for (i=1; i<n; i+=1) sprite_add_from_surface(tempsprite,surf,0,0,w,h,true,s);
    sprite_set_alpha_from_sprite(tempsprite,sprite);

    for (i=0; i<n; i+=1) {
        draw_clear_alpha(c_black,1);
        draw_sprite(tempsprite,i,xo,yo);
        draw_set_blend_mode(bm_add);
        draw_rectangle_color(0,0,w,h,c_black,c_black,c_black,c_black,false);
        if (i == 0) {
            newsprite = sprite_create_from_surface(surf,0,0,w,h,true,s,xo,yo);
            if (newsprite < 0) {
                sprite_delete(tempsprite);
                surface_reset_target();
                surface_free(surf);
                return -1;
            }
        }else{
            sprite_add_from_surface(newsprite,surf,0,0,w,h,true,s);
        }
        draw_clear_alpha(c_white,1);
        draw_set_blend_mode_ext(bm_zero,bm_src_alpha);
        draw_sprite(sprite,i,xo,yo);
        if (i == 0) {
            alphasprite = sprite_create_from_surface(surf,0,0,w,h,true,s,xo,yo);
            if (alphasprite < 0) {
                sprite_delete(tempsprite);
                sprite_delete(newsprite);
                surface_reset_target();
                surface_free(surf);
                return -1;
            }
        }else{
            sprite_add_from_surface(alphasprite,surf,0,0,w,h,true,s);
        }
        draw_set_blend_mode(bm_normal);
    }
    
    surface_reset_target();
    sprite_assign(sprite,newsprite);
    sprite_set_alpha_from_sprite(sprite,alphasprite);
    sprite_delete(alphasprite);
    sprite_delete(newsprite);
    sprite_delete(tempsprite);
    surface_free(surf);
}
/*
**  Usage:
**      d3d_model_copy(model)
**
**  Arguments:
**      model       d3d model index
**
**  Returns:
**      d3d model index of a copy of the given model
**
**  Notes:
**      This function requires write access to the working directory.
**
**  GMLscripts.com
*/
{
    var newmodel;
    d3d_model_save(argument0,working_directory+"\tempmod.dat");
    newmodel = d3d_model_create();
    d3d_model_load(newmodel,working_directory+"\tempmod.dat");
    file_delete(working_directory+"\tempmod.dat");
    return newmodel;
}
/*
**  Usage:
**      draw_background_tiled_area_ext(background,x,y,x1,y2,x2,y2,xscale,yscale,color,alpha)
**
**  Arguments:
**      background  the background to be drawn
**      x,y         the offset of the tiled area, as defined by a point 
**                  the background will/would be drawn
**      x1,y1       top left corner of the rectangle defining the area
**      x2,y2       bottom right corner of the area
**      color       the color mask that you want to blend the background with
**      alpha       the alpha value to draw it at
**
**  Notes:
**      x1 MUST be less than x2, and y1 less than y2
**      (x,y) doesn't have to be in the area, but if it is, then some
**      drawn background will have it's origin at this point
**
**  GMLscripts.com
*/
{
    var bg,xx,yy,x1,y1,x2,y2,xscale,yscale;
    bg = argument0;
    xx = argument1;
    yy = argument2;
    x1 = argument3;
    y1 = argument4;
    x2 = argument5;
    y2 = argument6;
    xscale = argument7;
    yscale = argument8;
    
    var bw,bh,i,j,jj,left,top,width,height,X,Y;
    bw = background_get_width(bg) * xscale;
    bh = background_get_height(bg) * yscale;
    
    i = x1-((x1 mod bw) - (xx mod bw)) - bw*((x1 mod bw)<(xx mod bw));
    jj = y1-((y1 mod bh) - (yy mod bh)) - bh*((y1 mod bh)<(yy mod bh)); 
    for(i=i; i<=x2; i+=bw) {
        if(i <= x1) {
            left = (x1-j);
            X = i + left;
        }
        else {
            left = 0;
            X = i;
        }
        
        if (x2 <= i+bw) width = x2-i+1-left;
        else width = bw-left;
        width /= xscale;
        left /= yscale;
        for(j=jj; j<=y2; j+=bh) {
            if(j <= y1) {
                Y = j + top;
                top = (y1-j);
            }
            else {
                top = 0;
                Y = j;
            }
            if(y2 <= j+bh) height = y2-j+1-top;
            else height = bh-top;
            draw_background_part_ext(bg,left,top/yscale,width,height/yscale,X,Y,xscale,yscale,argument9,argument10);
        }
    }
}
/*
**  Usage:
**      draw_rectangle_dashed_color(x1,y1,x2,y2,col1,col2,col3,col4,size)
**
**  Arguments:
**      x1,y1       first corner of the rectangle
**      x2,y2       second corner of the rectangle
**      col1,col2   top left, top right corner colors
**      col3,col4   bottom right, bottom left corner colors
**      size        length of the dashes in pixels (optional)
**
**  Returns:
**      nothing
**
**  Notes:
**      Draws a rectangle made of dashes of the given size.
**      If no size is given, one pixel dots will be used.
**      Creates a sprite, 2x2 pixels is size, and a pair
**      of global variables the first time it is called.
**
**  GMLscripts.com
*/
{
    // initialize the script the first on the first call
    if (!variable_global_exists("_DRAW_RECT_DASH_SPR")) {
        var i,j,k,l;
        i = draw_getpixel(0,0);
        j = draw_getpixel(1,0);
        k = draw_getpixel(0,1);
        l = draw_getpixel(1,1);
        draw_point_color(0,0,c_white);
        draw_point_color(1,0,c_black);
        draw_point_color(0,1,c_black);
        draw_point_color(1,1,c_white);
        global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,true,false,0,0);
        global._DRAW_RECT_DASH_TEX = sprite_get_texture(global._DRAW_RECT_DASH_SPR,0);
        draw_point_color(0,0,i);
        draw_point_color(1,0,j);
        draw_point_color(0,1,k);
        draw_point_color(1,1,l);
    }
    
    // main script begin
    var x1,y1,x2,y2,u1,v1,u2,v2,alpha;;
    x1 = min(argument0,argument2);
    y1 = min(argument1,argument3);
    x2 = max(argument0,argument2);
    y2 = max(argument1,argument3);
    
    // scale and center texture UV coordinates
    argument8 = max(1,argument8);
    u2 = (x2-x1)/(2*argument8);
    v2 = (y2-y1)/(2*argument8);
    u1 = 0.25 - (u2 mod 2)/2;
    v1 = 0.25 - (v2 mod 2)/2;
    u2 += u1;
    v2 += v1;
    
    // draw textured rectangle using the given colors and default alpha
    alpha = draw_get_alpha();
    texture_set_repeat(1);    
    draw_primitive_begin_texture(pr_linestrip, global._DRAW_RECT_DASH_TEX);
    draw_vertex_texture_color(x1, y1, u1, v1, argument4, alpha);
    draw_vertex_texture_color(x2, y1, u2, v1, argument5, alpha);
    draw_vertex_texture_color(x2, y2, u2, v2, argument6, alpha);
    draw_vertex_texture_color(x1, y2, u1, v2, argument7, alpha);
    draw_vertex_texture_color(x1, y1, u1, v1, argument4, alpha);
    draw_primitive_end(); 
}
/*
**  Usage:
**      draw_background_tiled_area(background,x,y,x1,y1,x2,y2)
**
**  Arguments:
**      background  the background to be drawn
**      x,y         the offset of the tiled area, as defined by a point 
**                  the background will/would be drawn
**      x1,y1       top left corner of the rectangle defining the area
**      x2,y2       bottom right corner of the area
**
**  Notes:
**      x1 MUST be less than x2, and y1 less than y2
**      (x,y) doesn't have to be in the area, but if it is, then some
**      drawn background will have it's origin at this point
**
**  GMLscripts.com
*/
{
    var bg,xx,yy,x1,y1,x2,y2;
    bg = argument0;
    xx = argument1;
    yy = argument2;
    x1 = argument3;
    y1 = argument4;
    x2 = argument5;
    y2 = argument6;
    
    var bw,bh,i,j,jj,left,top,width,height,X,Y;
    bw = background_get_width(bg);
    bh = background_get_height(bg);
    
    i = x1-((x1 mod bw) - (xx mod bw)) - bw*((x1 mod bw)<(xx mod bw));
    jj = y1-((y1 mod bh) - (yy mod bh)) - bh*((y1 mod bh)<(yy mod bh)); 
    
    for(i=i; i<=x2; i+=bw) {
        if(i <= x1) left = x1-i;
        else left = 0;
        X = i+left;
                    
        if(x2 <= i+bw) width = ((bw)-(i+bw-x2)+1)-left;
        else width = bw-left;
        
        for(j=jj; j<=y2; j+=bh) {
            if(j <= y1) top = y1-j;
            else top = 0;
            Y = j+top;

            if(y2 <= j+bh) height = ((bh)-(j+bh-y2)+1)-top;
            else height = bh-top;
            
            draw_background_part(bg,left,top,width,height,X,Y);
        }
    }
}
/*
**  Usage:
**      draw_rectangle_dashed(x1,y1,x2,y2,size)
**
**  Arguments:
**      x1,y1       first corner of the rectangle
**      x2,y2       second corner of the rectangle
**      size        length of the dashes in pixels (optional)   
**
**  Returns:
**      nothing
**
**  Notes:
**      Draws a rectangle made of dashes of the given size.
**      If no size is given, one pixel dots will be used.
**      Creates a sprite, 2x2 pixels is size, and a pair
**      of global variables the first time it is called.
**
**  GMLscripts.com
*/
{
    // initialize the script the first on the first call
    if (!variable_global_exists("_DRAW_RECT_DASH_SPR")) {
        var i,j,k,l;
        i = draw_getpixel(0,0);
        j = draw_getpixel(1,0);
        k = draw_getpixel(0,1);
        l = draw_getpixel(1,1);
        draw_point_color(0,0,c_white);
        draw_point_color(1,0,c_black);
        draw_point_color(0,1,c_black);
        draw_point_color(1,1,c_white);
        global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,true,false,0,0);
        global._DRAW_RECT_DASH_TEX = sprite_get_texture(global._DRAW_RECT_DASH_SPR,0);
        draw_point_color(0,0,i);
        draw_point_color(1,0,j);
        draw_point_color(0,1,k);
        draw_point_color(1,1,l);
    }
    
    // main script begin
    var x1,y1,x2,y2,u1,v1,u2,v2,color,alpha;
    x1 = min(argument0,argument2);
    y1 = min(argument1,argument3);
    x2 = max(argument0,argument2);
    y2 = max(argument1,argument3);
    
    // scale and center texture UV coordinates
    argument4 = max(1,argument4);
    u2 = (x2-x1)/(2*argument4);
    v2 = (y2-y1)/(2*argument4);
    u1 = 0.25  - (u2 mod 2) / 2;
    v1 = 0.25  - (v2 mod 2) / 2;
    u2 += u1;
    v2 += v1;
    
    // draw textured rectangle using the default color and alpha
    color = draw_get_color();
    alpha = draw_get_alpha();
    texture_set_repeat(1);    
    draw_primitive_begin_texture(pr_linestrip, global._DRAW_RECT_DASH_TEX);
    draw_vertex_texture_color(x1, y1, u1, v1, color, alpha);
    draw_vertex_texture_color(x2, y1, u2, v1, color, alpha);
    draw_vertex_texture_color(x2, y2, u2, v2, color, alpha);
    draw_vertex_texture_color(x1, y2, u1, v2, color, alpha);
    draw_vertex_texture_color(x1, y1, u1, v1, color, alpha);
    draw_primitive_end(); 
}
/*
**  Usage:
**      draw_sprite_inverted(sprite,subimg,x,y)
**
**  Argument:
**      sprite      sprite to draw
**      subimg      subimage to draw
**      x,y         location of the screen at which to draw
**
**  Returns:
**      (-1) on error, or draws the given sprite subimage,
**      at the given location on the screen, inverted
**
**  Notes:
**      Resets blending mode to normal, and turns fog off.
**
**  GMLscripts.com
*/
{
    var sprite,subimg,xs,ys;
    sprite = argument0;
    subimg = argument1;
    xs = argument2;
    ys = argument3;
    
    var w,h,xo,yo,x1,y1,x2,y2,vx1,vy1,vx2,vy2,xp,yp,wp,hp,tempsprite;
    w  = sprite_get_width(sprite);
    h  = sprite_get_height(sprite);
    xo = sprite_get_xoffset(sprite);
    yo = sprite_get_yoffset(sprite);
    
    x1 = xs-xo;
    y1 = ys-yo;
    x2 = x1+w;
    y2 = y1+h;
    
    if (view_enabled) {
        vx1 = view_xview[view_current];
        vy1 = view_yview[view_current];
        vx2 = view_wview[view_current]+vx1;
        vy2 = view_hview[view_current]+vy1;
    }else{
        vx1 = 0;
        vy1 = 0;
        vx2 = room_width;
        vy2 = room_height;
    }
    
    xp = min(max(0,vx1-x1),vx2,w);
    yp = min(max(0,vy1-y1),vy2,h);
    wp = min(max(0,x2-vx1),vx2-x1,w);
    hp = min(max(0,y2-vy1),vy2-y1,h);
    
    x1 = x1+xp;
    y1 = y1+yp;
    x2 = x1+wp-1;
    y2 = y1+hp-1;
    
    if (wp > 0 && hp > 0) {
        draw_set_blend_mode_ext(bm_zero,bm_inv_src_alpha);
        draw_sprite_part(sprite,subimg,xp,yp,wp,hp,x1,y1);
        tempsprite = sprite_create_from_screen(x1,y1,wp,hp,false,0,0,0);
        draw_set_blend_mode(bm_normal);
        if (tempsprite < 0) return -1;
        d3d_set_fog(true,c_white,0,0);
        draw_sprite(tempsprite,0,x1,y1);
        d3d_set_fog(0,0,0,0);
        draw_set_blend_mode_ext(bm_zero,bm_src_alpha);
        draw_sprite(sprite,subimg,xs,ys);
        draw_set_blend_mode_ext(bm_zero,bm_inv_src_color);
        draw_sprite(sprite,subimg,xs,ys);
        draw_set_blend_mode_ext(bm_one,bm_one);
        draw_sprite(tempsprite,0,x1,y1);
        sprite_delete(tempsprite);
        draw_set_blend_mode(bm_normal);
    }
}
/*
**  Usage:
**      draw_text_shadow(x,y,str,tcolor,scolor,intensity,distance,direction)
**
**  Arguments:
**      x,y         position of text
**      str         a string of text
**      tcolor      text color
**      scolor      shadow color
**      intensity   shadow intensity {0..1}
**      distance    shadow distance in pixels
**      direction   shadow direction in pixels
**
**  GMLscripts.com
*/
{
    var c,a,i,j;
    c = draw_get_color();
    a = draw_get_alpha();
    i = lengthdir_x(argument6, argument7);
    j = lengthdir_y(argument6, argument7);
    draw_set_color(argument4);
    draw_set_alpha(a * argument5);
    draw_text(argument0 + i, argument1 + j, argument2);
    draw_set_color(argument3);
    draw_set_alpha(a);
    draw_text(argument0, argument1, argument2);
    draw_set_color(c);
}
/*
**  Usage:
**      draw_sprite_tiled_area(sprite,subimg,x,y,x1,y2,x2,y2)
**
**  Arguments:
**      sprite  the sprite to be drawn
**      subimg  the sub image of the sprite to be drawn
**      x,y     the offset of the tiled area, as defined by a point 
**              the sprite will/would be drawn
**      x1,y1   top left corner of the rectangle defining the area
**      x2,y2   bottom right corner of the area
**
**  Notes:
**      x1 MUST be less than x2, and y1 less than y2
**      (x,y) doesn't have to be in the area, but if it is, then some
**          drawn sprite will have it's origin at this point
**
**  GMLscripts.com
*/
{
    var sprite,subimg,xx,yy,x1,y1,x2,y2;
    sprite = argument0;
    subimg = argument1;
    xx = argument2;
    yy = argument3;
    x1 = argument4;
    y1 = argument5;
    x2 = argument6;
    y2 = argument7;
    
    var sw,sh,i,j,jj,left,top,width,height,X,Y;
    sw = sprite_get_width(sprite);
    sh = sprite_get_height(sprite);

    i = x1-((x1 mod sw) - (xx mod sw)) - sw*((x1 mod sw)<(xx mod sw));
    jj = y1-((y1 mod sh) - (yy mod sh)) - sh*((y1 mod sh)<(yy mod sh)); 
    
    for(i=i; i<=x2; i+=sw) {
        if(i <= x1) left = x1-i;
        else left = 0;
        X = i+left;
                    
        if(x2 <= i+sw) width = ((sw)-(i+sw-x2)+1)-left;
        else width = sw-left;
        
        for(j=jj; j<=y2; j+=sh) {
            if(j <= y1) top = y1-j;
            else top = 0;
            Y = j+top;

            if(y2 <= j+sh) height = ((sh)-(j+sh-y2)+1)-top;
            else height = sh-top;
            
            draw_sprite_part(sprite,subimg,left,top,width,height,X,Y);
        }
    }
}
/*
**  Usage:
**      ds_map_mirror(dsid)
**
**  Arguments:
**      dsid        ds_map data structure for which
**                  keys and values will be swapped
**
**  Returns:
**      nothing
**
**  Notes:
**      It's up to the caller to make sure no values are 2 times in the map
**
**  GMLscripts.com
*/
{
    var dsid,temp,key,val;
    dsid = argument0;
    temp = ds_map_create();
    key = ds_map_find_first(dsid);
    val = ds_map_find_value(dsid,key);
    ds_map_add(temp,val,key);
    repeat (ds_map_size(dsid)-1) {
        key = ds_map_find_next(dsid,key);
        val = ds_map_find_value(dsid,key);
        ds_map_add(temp,val,key);    
    }
    ds_map_copy(dsid,temp);
    ds_map_destroy(temp);
}
/* 
**  Usage:
**      exp_dist(x)
**
**  Arguments:
**      x       upper bound of desired random value
**  Returns:
**      a random number from 0 to x with an exponential ditribution
**
**  GMLscripts.com
*/
{
    return argument0 * (-ln(random(1)))
}
/*
**  Usage:
**      ds_list_median(id)
**
**  Arguments:
**      id      ds_list of numbers
**
**  Returns:
**      the median value of all elements in the given list
**
**  GMLscripts.com
*/
{
    var i,j,k;
    j = ds_list_create();
    k = ds_list_size(argument0);
    ds_list_copy(j,argument0);
    ds_list_sort(j, true);
    i = ds_list_find_value(j,k div 2);
    ds_list_destroy(j);
    return i;
}
/*
**  Usage:
**      instance_nth_furthest(x,y,obj,n)
**
**  Arguments:
**      x,y       a point
**      obj       an object_index, or keyword "all"
**      n         proximity
**
**  Return:
**      inst      (n)th farthest instance id of type
**                (object) from the given point (x,y),
**                or keyword "noone" if none found.
**
**  GMLscript.com
*/
{
    var pointx,pointy,object,n,list,farthest;
    pointx = argument0;
    pointy = argument1;
    object = argument2;
    
    n = argument3;
    n = min(max(1,n),instance_number(object));
    list = ds_priority_create();
    farthest = noone;
    with (object) ds_priority_add(list,id,distance_to_point(pointx,pointy));
    repeat (n) farthest = ds_priority_delete_max(list);
    ds_priority_destroy(list);
    return farthest; 
}
/*
**  Usage:
**      map_backgrounds(ds_map)
**
**  Arguments:
**      ds_map      map to which all backgrounds are loaded
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = background_create_color(1,1,c_white);
    background_delete(no);
    for (i=0; i<no; i+=1) {
        if (background_exists(i)) {
            ds_map_add(ds_map,background_get_name(i),i);
        }
    }
}
/*
**  Usage:
**      map_fonts(ds_map)
**
**  Arguments:
**      ds_map      map to which all fonts are loaded
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0
    no = font_add("arial",12,false,false,32,32);
    font_delete(no);
    for (i=0;i<no;i+=1) {
        if (font_exists(i)) {
            ds_map_add(ds_map,font_get_name(i),i)
        }
    }
}
/*
**  Usage:
**      map_backgrounds_if(ds_map,pred)
**
**  Arguments:
**      ds_map      map to which all backgrounds are loaded
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = background_create_color(1,1,c_white);
    pred = argument1;
    background_delete(no);
    for (i=0; i<no; i+=1) {
        if (background_exists(i)) {
            if (script_execute(pred,i)) {
                ds_map_add(ds_map,background_get_name(i),i);
            }
        }
    }
}
/*
**  Usage:
**      map_sprites(ds_map)
**
**  Arguments:
**      ds_map      map to which all sprites are loaded
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = sprite_create_from_screen(0,0,1,1,false,false,0,0);
    sprite_delete(no);
    for (i=0; i<no; i+=1) {
        if (sprite_exists(i)) {
            ds_map_add(ds_map,sprite_get_name(i),i);
        }
    }
}
/*
**  Usage:
**      map_fonts_if(ds_map,pred)
**
**  Arguments:
**      ds_map      map to which all fonts are loaded
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0
    no = font_add("arial",12,false,false,32,32);
    font_delete(no);
    for (i=0;i<no;i+=1) {
        if font_exists(i) {
            if (script_execute(pred,i)) {
                ds_map_add(ds_map,font_get_name(i),i);
            }
        }
    }
}
/*
**  Usage:
**      map_objects_if(ds_map,pred)
**
**  Arguments:
**      ds_map      map to which all objects are loaded
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = object_add();
    object_delete(no);
    for (i=0; i<no; i+=1) {
        if (object_exists(i)) {
            if (script_execute(pred,i)) {
                ds_map_add(ds_map,object_get_name(i),i);
            }
        }
    }
}
/*
**  Usage:
**      map_rooms_if(ds_map,pred)
**
**  Arguments:
**      ds_map      map to which all rooms are loaded.
**      pred        predicate script (id) that gets as argument the resource id
**
**  Notes:
**      Fills the map with {key=name, val=index} pairs.
**      To find the maximum number of rooms, it creates an extra
**      room. The name of this room will be added to the map
**      unless a room with the same name already exists.
**
**  Returns:
**      the index of the created room
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0
    no = room_add();
    for (i=0;i<no;i+=1) {
        if (room_exists(i)) {
            if (script_execute(pred,i)) {
                ds_map_add(ds_map,room_get_name(i),i);
            }
        }
    }
    if (!ds_map_exists(ds_map,room_get_name(no))) ds_map_add(ds_map,room_get_name(no),i);
    return no;
}
/*
**  Usage:
**      polygon_centroid(polygon)
**
**  Description:
**      Takes a list of points defining the boundary of a polygon
**      and returns the area enclosed within. This function also
**      computes the centroid of a polygon and stores their 
**      coordinate values into a pair of global variables.
**
**  Arguments:
**      polygon    ds_list containing XY coordinate pairs defining
**                 the shape of a polygon
**
**  Returns:
**      area                area of the polygon, if negative the
**                          polygon is clockwise
**      global.xCentroid    x coordinate of centroid of polygon
**      global.yCentroid    y coordinate of centroid of polygon
**
**  Notes:
**      Polygons are closed figures, the first point in the polygon
**      will also be considered the last point in the polygon.
**      Polygons must be simple, which means they can not have
**      edges that cross each other.
**
**  Example:
**      in:  polygon = [ 100,100,  100,200,  200,200,  200,100 ]
**           (a square polygon: four coordinate pairs)
**      out: 10000
**      centroid: (150,150)
**
**  GMLscripts.com
*/
{
    var ai,atmp,xtmp,ytmp,i,j,x1,y1,x2,y2;
    atmp = 0;
    xtmp = 0;
    ytmp = 0;
    global.xCentroid = 0;
    global.yCentroid = 0;
    j = ds_list_size(polygon);
    for (i=0; i<j; i+=2) {
        x1 = ds_list_find_value(polygon,(i)        );
        y1 = ds_list_find_value(polygon,(i+1) mod j);
        x2 = ds_list_find_value(polygon,(i+2) mod j);
        y2 = ds_list_find_value(polygon,(i+3) mod j);
        ai = x1*y2 - x2*y1;
        atmp += ai;
        xtmp += (x2 + x1) * ai;
        ytmp += (y2 + y1) * ai;
    }
    if (atmp != 0) {
        global.xCentroid = xtmp / (3 * atmp);
        global.yCentroid = ytmp / (3 * atmp);
    }
    return atmp / 2;
}
/*
**  Usage:
**      map_paths_if(ds_map)
**
**  Arguments:
**      ds_map      map to which all paths are loaded
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = path_add();
    path_delete(no);
    for (i=0; i<no; i+=1) {
        if (path_exists(i)) {
            ds_map_add(argument0,path_get_name(i),i);
        }
    }
}
/*
**  Usage:
**      polygon_area(polygon)
**
**  Description:
**      Takes a list of points defining the boundary of a polygon
**      and returns the area enclosed within.
**
**  Arguments:
**      polygon    ds_list containing XY coordinate pairs defining
**                 the shape of a polygon {x0,y0,x1,y1,...,xn,yn}
**
**  Returns:
**      area       area of the polygon, if negative the polygon is 
**                 clockwise
**
**  Notes:
**      Polygons are closed figures, the first point in the polygon
**      will also be considered the last point in the polygon.
**      Polygons must be simple, which means they can not have
**      edges that cross each other.
**
**  Example:
**      in:  polygon = {100,100,100,200,200,200,200,100}
**           (a square polygon with corners at 100,100 and 200,200)
**      out: 10000
**
**  GMLscripts.com
*/
{
    var a,i,j,x1,y1,x2,y2;
    a = 0;
    j = ds_list_size(polygon);
    for (i=0; i<j; i+=2) {
        x1 = ds_list_find_value(polygon,(i)        );
        y1 = ds_list_find_value(polygon,(i+1) mod j);
        x2 = ds_list_find_value(polygon,(i+2) mod j);
        y2 = ds_list_find_value(polygon,(i+3) mod j);
        a += x1*y2 - x2*y1;
    }
    return a / 2;
}
/*
**  Usage:
**      map_sprites_if(ds_map,pred)
**
**  Arguments:
**      ds_map      map to which all sprites are loaded
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = sprite_create_from_screen(0,0,1,1,false,false,0,0);
    sprite_delete(no);
    for (i=0; i<no; i+=1) {
        if (sprite_exists(i)) {
            if (script_execute(pred,i)) {
                ds_map_add(ds_map,sprite_get_name(i),i);
            }
        }
    }
}
/*
**  Usage:
**      map_sounds_if(ds_map,ex_sound,pred)
**
**  Arguments:
**      ds_map      map to which all sprites are loaded
**      ex_sound    filename from an external sound
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**  Notes:
**      The loaded sound is "unloaded" directly, and only
**      used to get the max index number
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = sound_add(argument1,0,false);
    if (no != -1) {
        sound_delete(no);
        for (i=0; i<no; i+=1) {
            if (sound_exists(i)) {
                if (script_execute(pred,i)) {
                    ds_map_add(ds_map,sound_get_name(i),i);
                }
            }
        }
    }
}
/*
**  Usage:
**      motion_blur(length,direction)
**
**  Arguments:
**      length          length of blur
**      direction       direction of the blur
**
**  Returns:
**      nothing
**
**  Notes:
**      Example of use (draw event): motion_blur(speed*2,direction);
**      Please also remember that the script is compatible with
**      image_alpha. For example: If image_alpha is 0.5 then whole
**      motion blur will have half tranparency.
**
**  GMLscripts.com
*/
{
    var i, length,stp,dir,px,py,a;
    length = argument[0];
    
    if (length > 0) {
        stp = 3;
        dir = degtorad(argument[1]);
        px = cos(dir);
        py = -sin(dir);
        
        a = image_alpha/(length/sep);
        if (a >= 1) {
            draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,
                            image_yscale,image_angle,image_blend,image_alpha);
            a /= 2;
        }
           
        for(i=length;i>=0;i-=stp) {
            draw_sprite_ext(sprite_index,image_index,x+(px*i),y+(py*i),
                            image_xscale,image_yscale,image_angle,image_blend,a);
        }
    } else {    
        draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,
                        image_yscale,image_angle,image_blend,image_alpha);
    }
}
/*
**  Usage:
**      map_timelines_if(ds_map,pred)
**
**  Arguments:
**      ds_map      map to which all timelines are loaded
**      pred        predicate script (id) that gets as argument the resource id
**
**  Returns:
**      nothing, but fills the map with {key=name, val=index} pairs
**
**  GMLscripts.com
*/
{
    var no,i,ds_map;
    ds_map = argument0;
    no = timeline_add();
    timeline_delete(no);
    for (i=0; i<no; i+=1) {
        if (timeline_exists(i)) {
            if (script_execute(pred,i)) {
                ds_map_add(ds_map,timeline_get_name(i),i);
            }
        }
    }
}
/*
**  Usage:
**      speakable_password(length)
**
**  Arguments:
**      length      the length of the generated password
**
**  Returns:
**      a speakable random password of the given length
**
**  GMLscripts.com
*/
{
    var result,i;
    result = "";
    for (i=0; i<argument0; i+=1) {
        if (i mod 2) result += string_char_at("aeiou",ceil(random(5)));
        else result += string_char_at("bcdfghjklmnprstwyz",ceil(random(18)));
    }
    return result;
}
/*
**  Usage:
**      save_screenshot(name,folder)
**
**  Arguments:
**      name          prefix to assign screenshots
**      folder        subfolder to save screenshot to,
**                    eg. "screens\" (optional)
**
**  Returns:
**      true on success in saving a automatically numbered
**      screenshot in the working directory, false otherwise
**
**  GMLscripts.com
*/
{
    var i,fname;
    i = 0;
    // If there is a file with the current name and number,
    // advance counter and keep looking:
    do {
        fname = working_directory+"\"+argument1+argument0+"_"+string(i)+".png";
        i += 1;
    } until (!file_exists(fname))
    // Once we've got a unused number we'll save the screenshot under it:
    screen_save(fname);
    return file_exists(fname);
}
/*
**  Usage:
**      sprite_edit_end(session)
**
**  Arguments:
**      session     the editing session ID provided by sprite_edit_begin()
**
**  Returns:
**      nothing
**
**  Notes:
**      Ends the editing session started with sprite_edit_begin, replacing
**      the old sprite with the edited sprite and freeing the editing surface.
**
**  Dependencies:
**      sprite_edit_begin()
**
**  GMLscripts.com
*/
{
    var session,p,surface,sprite,w,h,n,prec,tran,smth,load,xoff,yoff,temp,i;
    session = argument0        
    p = string_pos(':',session);
    surface = real(string_copy(session,1,p-1));
    sprite = real(string_copy(session,p+1,10));
    w = sprite_get_width(sprite);
    h = sprite_get_height(sprite);
    n = sprite_get_number(sprite);
    //prec = sprite_get_precise(sprite);
    //tran = sprite_get_transparent(sprite);
    //smth = sprite_get_smooth(sprite);
    //load = sprite_get_preload(sprite);
    smth = true;
    xoff = sprite_get_xoffset(sprite);
    yoff = sprite_get_yoffset(sprite);
    temp = sprite_create_from_surface(surface,0,0,w,h,false,smth,xoff,yoff);
    for(i=1; i<n; i+=1) {
        sprite_add_from_surface(temp,surface,w*i,0,w,h,false,smth);
    }
    sprite_assign(sprite,temp);
    sprite_delete(temp);
    surface_reset_target();
    surface_free(surface);
}
/*
**  Usage:
**      sprite_invert_color(sprite)
**
**  Arguments:
**      sprite      sprite to change
**
**  Returns:
**      (-1) on error
**
**  Notes:
**      This script inverts the colors of a given sprite.
**      No new sprites are created, the given sprite is changed.
**
**  GMLscripts.com
*/
{
    var sprite,w,h,n,p,s,l,xo,yo,surf,i,newsprite,alphasprite;
    sprite = argument0;

    w  = sprite_get_width(sprite);
    h  = sprite_get_height(sprite);
    n  = sprite_get_number(sprite);
    s = true;       //see discussion
    xo = sprite_get_xoffset(sprite);
    yo = sprite_get_yoffset(sprite);

    surf = surface_create(w,h);
    if (surf < 0) return -1;
    surface_set_target(surf);
    
    surface_reset_target();
    sprite_assign(sprite,newsprite);
    sprite_set_alpha_from_sprite(sprite,alphasprite);
    sprite_delete(newsprite);
    sprite_delete(alphasprite);
    surface_free(surf);
}
/*
**  Usage:
**      sprite_replace_color(sprite,oldcolor,newcolor)
**
**  Arguments:
**      sprite      sprite to change
**      oldcolor    color that will be replaced
**      newcolor    color used as replacement
**
**  Returns:
**      (-1) on error
**
**  Notes:
**      This script replaces one color in a sprite with another.
**      No new sprites are created, the given sprite is changed.
**
**  GMLscripts.com
*/
{
    var sprite,oldc,newc;
    sprite = argument0;
    oldc  = argument1;
    newc  = argument2;

    var w,h,n,p,s,l,xo,yo,surf,i,tempsprite,newsprite,alphasprite;
    w  = sprite_get_width(sprite);
    h  = sprite_get_height(sprite);
    s =true;
    xo = sprite_get_xoffset(sprite);
    yo = sprite_get_yoffset(sprite);

    surf = surface_create(w,h+1);
    if (surf < 0) return -1;
    surface_set_target(surf);

    for (i=0; i<n; i+=1) {
        draw_clear_alpha(c_black,1);
        draw_set_blend_mode_ext(bm_inv_dest_color,bm_one);
        draw_sprite(sprite,i,xo,yo);
        draw_set_blend_mode(bm_normal);
        draw_point_color(0,h,oldc);
        tempsprite = sprite_create_from_surface(surf,0,0,w,h+1,true,s,xo,yo);
        draw_clear_alpha(newc,1);
        draw_sprite(tempsprite,0,xo,yo);
        sprite_delete(tempsprite);
        if (i == 0) {
            newsprite = sprite_create_from_surface(surf,0,0,w,h,true,s,xo,yo);
            if (newsprite < 0) {
                surface_free(surf);
                return -1;
            }
        }else{
            sprite_add_from_surface(newsprite,surf,0,0,w,h,true,s);
        }
        draw_clear_alpha(c_white,1);
        draw_set_blend_mode_ext(bm_zero,bm_src_alpha);
        draw_sprite(sprite,i,xo,yo);
        if (i == 0) {
            alphasprite = sprite_create_from_surface(surf,0,0,w,h,true,s,xo,yo);
            if (alphasprite < 0) {
                sprite_delete(newsprite);
                surface_free(surf);
                return -1;
            }
        }else{
            sprite_add_from_surface(alphasprite,surf,0,0,w,h,true,s);
        }
        draw_set_blend_mode(bm_normal);
    }

    surface_reset_target();
    sprite_assign(sprite,newsprite);
    sprite_set_alpha_from_sprite(sprite,alphasprite);
    sprite_delete(newsprite);
    sprite_delete(alphasprite);
    surface_free(surf);
}
/*
**  Usage:
**      newsprite = sprite_replace_color_blend(sprite,oldcolor,
**                     newcolor,trancolor,htol,stol,vtol,blend)
**
**  Given:    
**      sprite      sprite index
**      oldcolor    original color
**      newcolor    replacement color
**      trancolor   transparency color of the new sprite
**      htol        hue tolerance, real
**      stol        saturation tolerance, real
**      vtol        value tolerance, real
**      blend       blend shading, true/false
**
**  Returns:
**      sprite index, or (-1) on error
**
**  Notes:
**      (trancolor) must be supplied, it is the color used for the
**      new sprite's transparency mask.
**
**      Three tolerance arguments (htol,stol,vtol) contol exactly
**      which colors are replaced. A higher tolerance will match
**      a broader range of hue, saturation, or value. Values
**      around (htol = 20; stol = 240; vtol = 240) work well.
**
**      If (blend) is set to true (recommeded), changed colors
**      will retain their original shading.
**
**      This function creates new sprites. It should only be
**      called once per color replacement, such as the Create Event
**      of an instance. You should be careful to delete created
**      sprites when you are done with them. This function draws
**      to the frame buffer and should never be called during the
**      Draw Event. Sprite colors in 16-bit color mode are not
**      exact. They can shift from expected values in-game. Use
**      the tolerance controls to compensate. Finally, this
**      function is not fast. It is very slow with large sprites
**      and/or sprites with many frames. 
**
**  GMLscripts.com
*/
{
    var sprite,oldcolor,newcolor,trancolor,htol,stol,vtol,blend;
    sprite = argument0;
    oldcolor = argument1;
    newcolor = argument2;
    trancolor = argument3;
    htol = argument4;
    stol = argument5;
    vtol = argument6;
    blend = argument7;

    var p,t,s,l,xo,yo,n,w,h,oh,os,ov,nh,ns,nv;
    var i,sx,sy,color,th,ts,tv,dh,ds,dv,hue,sat,val,newsprite;
    s = true;
    xo = sprite_get_xoffset(sprite);
    yo = sprite_get_yoffset(sprite);
    n  = sprite_get_number(sprite);
    w  = sprite_get_width(sprite);
    h  = sprite_get_height(sprite);
    oh = color_get_hue(oldcolor);
    os = color_get_saturation(oldcolor);
    ov = color_get_value(oldcolor);
    nh = color_get_hue(newcolor);
    ns = color_get_saturation(newcolor);
    nv = color_get_value(newcolor);

    for(i=0;i<n;i+=1) {
        draw_set_color(trancolor);
        draw_rectangle(0,0,w,h,false);
        draw_sprite(sprite,i,xo,yo);
        for(sx=0;sx<w;sx+=1) {
            for(sy=0;sy<h;sy+=1) {
                color = draw_getpixel(sx,sy);
                th = color_get_hue(color);
                ts = color_get_saturation(color);
                tv = color_get_value(color);
                dh = th-oh;
                ds = ts-os;
                dv = tv-ov;
                if (abs(dh)>128) dh = sign(dh)*256-dh;
                if (abs(dh)<htol && abs(ds)<stol && abs(dv)<vtol) {
                    if (blend) {
                        hue = (nh+dh+256) mod 256;
                        sat = min(max(0,ns+ds),255);
                        val = min(max(0,nv+dv),255);
                        draw_point_color(sx,sy,make_color_hsv(hue,sat,val));
                    }
                }
            }
        }
        if (i==0) {
            newsprite = sprite_create_from_screen(0,0,w,h,true,s,xo,yo);
            if (newsprite<0) return -1;
        }else{
            sprite_add_from_screen(newsprite,0,0,w,h,true,s);
        }
    }
    return newsprite;
}
/*
**  Usage:
**      string_parse(str,token,ignore_null)
**
**  Arguments:
**      str         a string with a certain token seperating the
**                  desired substrings,  string
**      token       a string (usually a single variable) representing
**                  the character(s) that str is seperated by,  string
**      ignore_null whether or not to include empty strings if, for
**                  example, the token was repeated,  bool (true/false)
**                   
**  Returns:
**      a ds_list containing all substrings taken from str which
**      were seperated by token.
**
**  Example:
**      string_parse("cat|dog|house|bee", "|", true);
**      returns a ds_list containing "cat", "dog", "house", and "bee"
**
**  GMLscripts.com
*/
{
    var str, token, ignore, list, tlen, temp;
    
    str = argument0;
    token = argument1;
    ignore = argument2;
    
    list = ds_list_create();
    tlen = string_length( token);
    
    temp = string_pos( token, str); 
    
    while( temp) {
        if( temp != 1 || !ignore)
                ds_list_add( list, string_copy(str, 1, temp - 1));
        str = string_copy( str, temp + tlen, string_length( str));
        temp = string_pos( token, str);
    }
    if (string_length(str) > 0 || !ignore ) {
        ds_list_add( list, str);
    }
    str = "";
    return list;
}
/*
**  Usage:
**      string_parse_number(str,token,ignore_null)
**
**  Arguments:
**      str         a string with a certain token seperating the
**                  desired substrings,  string
**      token       a string (usually a single variable) representing
**                  the character(s) that str is seperated by,  string
**      ignore_null whether or not to include empty strings if, for
**                  example, the token was repeated,  bool (true/false)
**                   
**  Returns:
**      the number of substrings in str seperating them with token
**
**  Example:
**      string_parse_number("cat|dog|house|bee", "|", true);
**      returns 4
**
**  GMLscripts.com
*/
{
    var str, substr, token, ignore, N, tlen, temp, i;
    
    str = argument0;
    token = argument1;
    ignore = argument2;
    
    tlen = string_length( token);
    
    substr = "";
    i = 0;
    while( string_length( str) != 0) {
        temp = string_pos( token, str);
        if( temp) {
            if( temp != 1 || !ignore) {
                substr = string_copy(str, 1, temp - 1);
                i += 1;
            }
            str = string_copy( str, temp + tlen, string_length( str));
        }
        else {
            substr = str;
            i += 1;
            str = "";
        }
    }
    
    return i;
}
/*
**  Usage:
**      string_escape(str)
**
**  Arguments:
**      str     a string with embedded C-style escape sequences
**
**  Returns:
**      the given string with all escape sequences parsed
**
**  GMLscripts.com
*/
{
    var str, out, pos, tmp, ref, val;
    str = argument0;
    out = "";
    ref = "0123456789abcdef";
    while (str != "") {
        pos = string_pos("\",str);
        out += string_copy(str,1,pos-1);
        str = string_delete(str,1,pos);
        if (pos > 0) {
            tmp = string_char_at(str,1);
            str = string_delete(str,1,1);
        }
        else {
            out += str;
            str = "";
            tmp = "";
        }
        switch (tmp) {
            case '\':
            out += '\';
            break;
            case 'r':
            out += chr(13);
            break;
            case 'n':
            out += chr(10);
            break;
            case 't':
            out += chr(9);
            break;
            case 'x':
            val = string_pos(string_char_at(str,2),ref)-1;
            if (val < 0) {
                break;
            }
            val += 16*(string_pos(string_char_at(str,1),ref)-1);
            if (val >= 0) {
                out += chr(val);
                str = string_delete(str,1,2);
            }
            break;
            case '0':
            case '1':
            case '2':
            case '3':
            if (string_copy(str,1,2) == string_digits(string_copy(str,1,2))) {
                val = 64*(string_pos(tmp,ref)-1);
                val += 8*(string_pos(string_char_at(str,1),ref)-1);
                val += string_pos(string_char_at(str,2),ref)-1;
                out += chr(val)
                str = string_delete(str,1,2);
            }
            else if (tmp == '0') {
                out += chr(0);
            }
            break;
        }
    }
    return out;
}
/*
**  Usage:
**      string_shuffle(str)
**
**  Arguments:
**      str         a set of characters, string
**
**  Returns:
**      the given string with characters shuffled
**
**  GMLscripts.com
*/
{
    var str,out,len,i;
    str = argument0;
    out = "";
    len = string_length(str);
    repeat (len) {
        i = floor(random(len))+1;
        out += string_char_at(str,i);
        len -= 1;
        string_delete(str,i,1);
    }
    return out;
}
/*
**  Usage:
**      string_split(str,num,break)
**
**  Arguments:
**      str     a string of text
**      num     number of characters before a break
**      break   characters to insert into text
**
**  Returns:
**      the given string with the given break characters
**      inserted at the given interval
**
**  GMLscripts.com
*/
{
    var str,num,brk,len,i;
    str = argument0;
    num = argument1;
    brk = argument2;
    if (is_real(brk)) brk = "#";
    len = string_length(str);
    for (i=len-((len-1) mod num); i>num; i-=num) {
        str = string_insert(brk,str,i);
    }
    return str;
}
/*
**  Usage:
**      string_stagger_case(str,spaces,first)
**
**  Arguments:
**      str         string to modify
**      spaces      count spaces as letters, true or false
**      first       first letter capitalized, true or false
**
**  Returns:
**      the given string with the letters in staggered case, 
**      such as: "hElLo! hOw ArE yOu ToDaY?"
**
**  GMLscripts.com
*/
{
    var new,iii,len,old,j,t;
    old = argument0;
    iii = argument2;
    len = string_length(old);
    t = ''; 
    new = "";
    for (j=1; j<=len; j+=1) {
        if (string_char_at(new,j) == ' ' && argument1 == false) {
            if (iii) t = string_upper(string_char_at(old,j)); 
            else     t = string_lower(string_char_at(old,j)); 
            new += t;
            iii = !iii;
        }
    }
    return new;
}
/*
**  Usage:
**      string_width_limit(string,width,extension)
**
**  Arguments:
**      str         string to limit
**      width       width in pixels to constrain the string to
**      extension   text to append to string if it is cut
**
**  Returns:
**      the string (including an extension if used) 
**      that fits within the given width when drawn
**      with the current font settings
**
**  GMLscripts.com
*/
{
    var str,ext,wid;
    str = argument0;
    ext = argument2;
    wid = max(argument1, string_width(ext));
    if (string_width(str) <= wid) return str;
    while (string_width(str + ext) > wid) {
        str = string_delete(str, string_length(str), 1);
    } 
    return str + ext;
}
/*
**  Usage:
**      string_width_wrap(text,width,char,force)
**
**  Arguments:
**      text        string of text you want to wrap, string
**      width       maximum line width in pixels, real
**      char        line break character, string
**      force       if true, force line break if no spaces are present,
**                  if false, let lines overflow
**
**  Returns:
**      the given string, word wrapped to the given pixel width,
**      with line break characters inserted at the end of each line
**
**  GMLscripts.com
*/
{
    var pos_space, pos_current, text_current, text_output, line_current;
    pos_space = -1;
    pos_current = 1;
    text_current = argument0;
    if (is_real(argument2)) argument2 = "#";
    text_output = "";
    while (string_length(text_current) >= pos_current) {
        if (string_char_at(text_current,pos_current) == " ") pos_space = pos_current;
        if (string_width(string_copy(text_current,1,pos_current)) > argument1) {
            //if there is a space in this line then we can break there
            if (pos_space != -1) {
                text_output += string_copy(text_current,1,pos_space) + string(argument2);
                //remove the text we just looked at from the current text string
                text_current = string_delete(text_current,1,pos_space);
                if (pos_space == pos_current) {
                    pos_current = 1;
                } else {
                    pos_current -= pos_space;
                }
                pos_space = -1;
            } else if (argument3) {
                //if not, we can force line breaks
                text_output += string_copy(text_current,1,pos_current-1) + string(argument2);
                //remove the text we just looked at from the current text string
                text_current = string_delete(text_current,1,pos_current-1);
                pos_current = 1;
                pos_space = -1;
            }
        }

        pos_current += 1;
    }
    text_output += text_current;
    return text_output;
}

and finally a list of all scripts I didn't thoroughly check (checked it only quickly on syntax errors, rest I double checked on bugs):

asin
acos
b64_to_bytes
bias
bias_fast
bin_to_dec
bin_to_fraction
bin_to_hex
bitwise_reverse*
box_step
bytes_to_*
cambridge_encode
clamp
colr_mix
color_multiply
color_scale
color_to_cmyk
color_to_hex
color_to_wavelength
crc16
d3d_model_copy
date_get_easter
dec_to_bin
dec_to_hex
dec_to_oct
decode_real_double
directory_copy
draw_arc
draw_chord
draw_curve
draw_pie
draw_roundrect_ext
draw_sprite_flip_ext
draw_sprite_hud****
draw_sprite_wave
draw_sprite_wave_ext
draw_sprite_inverted
draw_text_hud****
ds_grid_mirror
ds_list_cv
ds_list_pop_standard_deviation
ds_list_standard_score
ds_map_load****
ds_map_save****
encode_real_double
erf
exact_gauss
factor_quadratic
fine_bin_read_word
file_bind_seek_relative
file_bin_write_word
fraction_to_bin
gain
gain_fast
gammacorrect
exp_dist
hex_to_bin
hex_to_bytes
hex_to_dec
hex_to_rgb
is_clockwise****
lerp
md2
md5
move_to_Line
normal_detect
number_format*
oct_to_dec
permutation
point_in_polygon
polygon_area
pulse
rc4
rgb_to_cmyk
rgb_to_hex
roman_numerals
roman_to_dec
smoothstep
spline
spline4
sprite_edit_begin****
step
vignere_ascii
vignere_cipher
wavelength_to_hue

EDIT: 26 / 01 / 10: even I'm not perfect tongue - saw some obvious mistakes in the top part the collision_triangle's headers weren't updated..

Last edited by paul23 (2010-01-25 18:39:57)

Offline

#10 2010-01-20 15:04:53

xDanielx
Member
Registered: 2009-01-02
Posts: 38

Re: GM8 - Scripts that do not work

=[] !

Offline

#11 2010-01-20 15:56:12

paul23
Member
Registered: 2007-10-17
Posts: 110

Re: GM8 - Scripts that do not work

Forgot to mention one thing (it is in the list of suggestion though, but easily missed): some functions (collision_triangle_init(), draw_rectangle_dashed etc) set something "global": shouldn't there be a common "name-convention" for it.. To prevent name collision with other parts (I suggested putting GS_, maybe GMLS_ in front of them.. - We might also put them all in caps or something?)

Offline

#12 2010-01-22 23:09:19

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: GM8 - Scripts that do not work

Good God!

It's times like these I'm glad I created a caching system for the code highlighter.

I absolutely agree with you about the global naming. I'd like to pick something standard that limits the chances of any naming collisions. I'll probably go with your suggestions.

A few of the suggestions and bug fixes will have to addressed in future topics. At first glance I see some problems with them or they go against already planned changes. I haven't yet had the chance to examine everything.

Paul, I can't possible thank you enough for taking so much time to assemble these lists and to provide fixes and suggestions for so many scripts. You deserve a special commendation for meritorious service above and beyond the call of duty and outstanding valor in the face of overwhelming forces. That or a padded room and a straightjacket.


Abusing forum power since 1986.

Offline

#13 2010-01-24 06:59:22

paul23
Member
Registered: 2007-10-17
Posts: 110

Re: GM8 - Scripts that do not work

Lol, well just finish gmlscripts 3.0 tongue

Anyways I've been thinking about it: alpha sprites are indeed useless, if we draw to the a surface with standard blend modes (otherwise we can't simply rule them out, somebody with more knowledge should look).

Also as said I put "removeback" in most cases to "true": this might be usefull when capturing sprites from the screen.. But with surfaces the bottom-left pixel might be from the sprite itself, so shouldn't removeback be always false in those cases?

Offline

#14 2010-01-24 11:50:19

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: GM8 - Scripts that do not work

It's hard for me to answer any questions involving the creation of sprites because I do not yet have GM8 Pro. Beyond my current money problems, I've been holding off on upgrading because there was talk that YoYo might provide free upgrades for senior GMC moderators. Their continued indecision has put me in a difficult position here and at the GMC. The longer it takes for them to decide, the more I feel like I should have never suggested the idea to Sandy.


Abusing forum power since 1986.

Offline

#15 2010-05-28 14:53:13

neil_v
Member
Registered: 2010-05-28
Posts: 6

Re: GM8 - Scripts that do not work

Hi... I'm very new. I'm just figuring out scripting so I don't quite know how to properly post an error report, or how to bug fix it myself tongue , so enjoy:

___________________________________________
COMPILATION ERROR in Script: draw_rectangle_dashed_color
Error in code at line 35:
   /***  Usage:**      draw_rectangle_dashed_color(x1,y1,x2,y2,col1,col2,col3,col4,size)****  Arguments:**      x1,y1       first corner of the rectangle**      x2,y2       second corner of the rectangle**      col1,col2   top left, top right corner colors**      col3,col4   bottom right, bottom left corner colors**      size        length of the dashes in pixels (optional)****  Returns:**      nothing****  Notes:**      Draws a rectangle made of dashes of the given size.**      If no size is given, one pixel dots will be used.**      Creates a sprite, 2x2 pixels is size, and a pair**      of global variables the first time it is called.****  GMLscripts.com*/{    // initialize the script the first on the first call    if (!variable_global_exists("_DRAW_RECT_DASH_SPR")) {        var i,j,k,l;        i = draw_getpixel(0,0);        j = draw_getpixel(1,0);        k = draw_getpixel(0,1);        l = draw_getpixel(1,1);        draw_point_color(0,0,c_white);        draw_point_color(1,0,c_black);        draw_point_color(0,1,c_black);        draw_point_color(1,1,c_white);        global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,0,1,0,0,0,0);        global._DRAW_RECT_DASH_TEX = sprite_get_texture(global._DRAW_RECT_DASH_SPR,0);        draw_point_color(0,0,i);        draw_point_color(1,0,j);        draw_point_color(0,1,k);        draw_point_color(1,1,l);    }        // main script begin    var x1,y1,x2,y2,u1,v1,u2,v2,alpha;;    x1 = min(argument0,argument2);    y1 = min(argument1,argument3);    x2 = max(argument0,argument2);    y2 = max(argument1,argument3);        // scale and center texture UV coordinates    argument8 = max(1,argument8);    u2 = (x2-x1)/(2*argument8);    v2 = (y2-y1)/(2*argument8);    u1 = 0.25 - (u2 mod 2)/2;    v1 = 0.25 - (v2 mod 2)/2;    u2 += u1;    v2 += v1;        // draw textured rectangle using the given colors and default alpha    alpha = draw_get_alpha();    texture_set_repeat(1);        draw_primitive_begin_texture(pr_linestrip, global._DRAW_RECT_DASH_TEX);    draw_vertex_texture_color(x1, y1, u1, v1, argument4, alpha);    draw_vertex_texture_color(x2, y1, u2, v1, argument5, alpha);    draw_vertex_texture_color(x2, y2, u2, v2, argument6, alpha);    draw_vertex_texture_color(x1, y2, u1, v2, argument7, alpha);    draw_vertex_texture_color(x1, y1, u1, v1, argument4, alpha);    draw_primitive_end(); }
                                                                                    ^
at position 83: Wrong number of arguments to function or script.

Offline

#16 2010-05-28 19:26:39

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: GM8 - Scripts that do not work

Welcome to the forums, Neil.

That script broke because the sprite creation functions changed in GM8. Earlier in this thread, paul23 was kind enough to post a new version. I think there is only one change.

Find this line:

        global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,0,1,0,0,0,0);

... and replace it with this line:

        global._DRAW_RECT_DASH_SPR = sprite_create_from_screen(0,0,2,2,true,false,0,0);

Abusing forum power since 1986.

Offline

#17 2010-05-29 14:20:21

neil_v
Member
Registered: 2010-05-28
Posts: 6

Re: GM8 - Scripts that do not work

Thank you for your polite reply! I will make the replacement.

Offline

Board footer

Powered by FluxBB