GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 GML Reference » Object Creation Execution Order Bug » 2010-07-15 12:11:33

flexaplex
Replies: 0

Just a little bug to watch out for with those relying on execution order. To reproduce:

RUN 1:

Expand1. Create a new blank file
2. Create an object, add the creation code: global.t0 = 0;
3. Create another object, add the creation code: global.t1 = global.t0;
4. Create a room and place Object0 then Object1 in the room
5. Set the depth of Object1 to 99
6. Run the game

RESULT: NO ERROR WILL BE SHOWN

RUN 2:

Expand1. Now delete both objects from the room
2. Then place them back in the room in the same order, ie object0 then object1
3. Run the game again

RESULT: AN ERROR IS NOW SHOWN

It appears that in RUN 1 the game is bugged, executing the 2 objects in the incorrect order (thus making the error to show), however when you delete and replace the objects in the room even though the resultant file is exactly the same the error is removed. Just uploading and re-downloading the file again will remove the bug also which is why I cannot provide an example file for this.

I have known about this bug for years, I only just remembered about it so I thought I would just post it for interest.

#2 GML Code Help » Script Improvement » 2010-07-15 00:37:42

flexaplex
Replies: 0

This is a script from my recently made multi-struct project: http://gmc.yoyogames.com/index.php?showtopic=480656

I'm sure a few more scripts in it can probably be improved but I'm most curious about this one as I'm doubting my solution is optimal. This script is made to create array indexes up to the indicated array indexes and assign the value of 0 to them. It is used to mimic the behaviour that arrays do when set in GM. For example when you set in gml:

Expandarr[2, 4] = val;

If that is the first time you have set to arr GM will automatically assign the indexes up to it with the value 0, ie:

[0, 0] [0, 1] [0, 2] [0, 3] [0, 4] [1, 0] [1, 1] [1, 2] [01 3] [1, 4] [2, 0] [2, 1] [2, 2] [2, 3] 

This is what I am trying to do with this script, except in this project the number of dimensions for the array can be from anything from 1 to 14 so it becomes a little more difficult. This is a simplified version (I've removed error checking and some other stuff) of the the script I am using:


Expand//ar_fill(id, ind1, ind2, ind3, ...) arbitrary number of indexes can be entered as arguments, the number should be equal to the array dimension

var i, dim_n, ar_id;
ar_id = argument0;

i = 1;
dim_n = ds_map_find_value(ar_dim_map, ar_id);  //returns the number of dimensions the array is

argument1 = floor(argument1);

if (dim_n == 1)  //1 dimensional arrays are handled separately as they can be executed much faster doing so
{
  for (i = 0; i < argument1; i += 1)
  {
    ds_map_add(ar_id, string(i), 0);   //to store the indexes I am just using a ds_map
  }
}
else
{
  var am, ac, str, tot;

  i = 1;
  tot = 1;
  repeat (dim_n)
  {
    am[i - 1] = argument[i] + 1;   //set all the index arguments into an array
    ac[i - 1] = 0;
    tot *= am[i - 1];  //add up the sum of all the indexes
    i += 1;
  }

  repeat (tot)
  {
    i = 0;
    str = "";
    repeat (dim_n)
    {
      str += string(ac[i]) + ",";   //add the indexes into a string for storing in the ds_map
      i += 1;
    }

    i = 1;
    repeat (dim_n)   //this loop is explained below
    {
      ac[dim_n - i] += 1;   
      if (ac[dim_n - i] == am[dim_n - i])
      {
        ac[dim_n - i] = 0;
      }  
      else
      {
        break;
      }
      i += 1;
    }
    ds_map_add(ar_id, str, 0);
  }
}

The method used in that loop is basically to increase indexes individually starting from the right if index is increased without reaching the index limit the code breaks otherwise it will move onto the next index to the left. This gives the desired effect of adding.

So yer just wondering if anyone can think of a better method or way of improving the script. Hopefully everyone wont run a mile when they see the code (like I probably would smile).

#3 Re: Script Submission » Format your message box the way you want » 2010-06-18 09:01:15

Well naturally I wouldn't call your script in that way. I would use the following script format:

Expandset_message_background();  //what I would rename your script to
show_message_ext("", but0, but1, but2);
clear_message_background();

I think that is a more logical way of setting this. It allows you to make multiple show_message_ext calls with the same background or change the background script call but still use the same messages.

#4 Re: Script Submission » Format your message box the way you want » 2010-06-17 22:01:54

Yes I go back to my previous point. This is much more an example rather than a script. As you need to edit in script to get the functionality you want it is not flexible as a standalone script.

It is certainly an interesting way of making a pause script. You could technically use the buttons in the show_message to make a basic menu if wanted also. Recalling another show_message based on the button pressed.

#5 Re: Script Submission » Format your message box the way you want » 2010-06-17 15:07:51

Hmm not sure this is best used as a script, think it would suit better as an example in the tutorials forum. I'm interested in seeing an example also, I'm too lazy to even open GM at the moment laugh

You should reset all the fonts yourself though, assign the current settings to variables before it's run then set again when it ends. I think there should be an in-built message_set_default() function in GM.

#6 Re: Script Submission » get_value » 2010-06-17 14:56:01

Yes it really should be included, I wish I remembered to ask when GM8 was being made (though I'm doubting it would have been made). I've seen it being asked a lot recently which is why I decided to make a script for it.

#7 Re: Script Submission » ds_list_exists » 2010-06-17 14:51:41

xot wrote:

Not a bad approach, as long as the list being searched for doesn't have a huge id. Looks like this technique could be applied to any type of data structure.

There's one thing I think I'd change, namely the bit where you reject ids with a fractional component. The existing ds_list functions accept these for arguments, rounding to the nearest integer. I suggest "argument0 = round(argument0)" instead of your check.

It looks like it handles negative ids gracefully, but I haven't actually tested it yet. Does it?

Yes it can be expanded to other data structures. I think this should function be default built into GM as well with all the data structures.

It does handle negatives correctly. I agree changing to round() is better, I had not thought about that.

This is the only approach found that was able to handle things correctly.

#8 Re: Script Submission » draw_text_ext replacement and related script » 2010-06-17 14:49:35

Yes it's different. It reformats the string so you are able to use it with draw_text_ext correctly. Here is the gmc topic on it:
http://gmc.yoyogames.com/index.php?showtopic=401419

I'm not sure which (if any) scripts would fit well with gmlscripts though.

#9 Script Submission » ds_list_exists » 2010-06-17 00:43:48

flexaplex
Replies: 2

Wrote this quite a while ago.

Expand//ds_list_exists(index) returns whether the ds_list with given index exists or not

if !(is_real(argument0)) {return false;}
var ds_temp, ds_temp_list, i;
ds_temp_list = ds_list_create();
ds_temp = ds_temp_list;

argument0 = round(argument0);
while (ds_temp < argument0)
{
  ds_temp = ds_list_create();
  ds_list_add(ds_temp_list, ds_temp);
}
for (i = ds_list_size(ds_temp_list) - 1; i >= 0; i -= 1)
{
  ds_list_destroy(ds_list_find_value(ds_temp_list, i));
}
ds_list_destroy(ds_temp_list);

return ds_temp != argument0;

Not sure if you will really want to use it though. It uses a bit of a trick that when creating a new list GM reuses ds_list indexes that have been destroyed.

#10 Script Submission » get_value » 2010-06-17 00:12:43

flexaplex
Replies: 2

From my gmc topic: http://gmc.yoyogames.com/index.php?showtopic=475256

Expand//get_value(Original Message, Default Value, Invalid Message)

var user_val, user_dig, val_mes;
user_dig = "";  val_mes = argument0;

while !(string_digits(user_dig) == user_dig && string_length(user_dig) > 0)
{
  user_val = get_string(val_mes, argument1);
  if (string_char_at(user_val, 1) == "-" || string_char_at(user_val, 1) == "+")
  {
        user_dig = string_replace(string_delete(user_val, 1, 1), ".", "");
  }
  else
  {
        user_dig = string_replace(user_val, ".", "");
  }
  val_mes = argument2;
}
return real(user_val);

This script does not cover exponential format so I decided not to call it get_real. Torigara did write an alternative using exps if you prefer that:
http://gmc.yoyogames.com/index.php?showtopic=466011

#11 Re: GML Reference » image_angle is drawn as though it is 0 when between 0 and 1; » 2010-05-21 07:11:59

icuurd12b42 wrote:

So you must imply that the draw, or the visible increment is .01

Yer sorry, that's what I meant.

#12 Re: GML Reference » image_angle is drawn as though it is 0 when between 0 and 1; » 2010-05-20 08:19:31

Just to note that the 0.58 precision was fixed in GM8. The precision is now set to 0.24 around 0 also. I did just find out something else about image_angle though.. that it's drawn value seems to be rounded to 2 decimal places.

#13 Re: Game Maker Bugs » Confirmed Bug List » 2010-04-17 15:25:59

OK took a little while but I've updated this list for GM8.

Note that the bug: computational functions - bugs and erratic behaviour can occur when using large values does behave differently in GM8 but I've forgotten exactly what Mark did to try and fix it (I remember he added a string return to some functions when too large a value is used as a argument but forgotten which). Also it is not fully fixed anyway as a lot of functions still bug and crash, testing would take too much effort.

Just to mention I am now hosting the bug topics at google docs: link. So in the future I may only update there.

#14 Re: GML Creations » Yet Another Idiotic Light and Shadow Engine » 2009-09-14 12:36:04

The kill wall doesn't actually seem to make that much difference, increases the speed slightly that's all.

#15 Re: GML Creations » Yet Another Idiotic Light and Shadow Engine » 2009-09-13 17:33:32

I'm getting about the same speeds as Joseph, just a tad slower (but then my laptop specs are just a tad worse).
Video Card: Mobile Intel(R) 965 Express Chipset Family (32bit, 60Hz)

Can't wait till I actually settle somewhere and get a good desktop computer.

Still this looks really great and the shadows works well. I don't expect a light engine to work fast on my laptop but I think some further optimisation would still probably be a good idea.

#16 Re: GML Reference » GM8 - Things that work differently than GM7 » 2009-09-12 08:29:18

Well Mark's finished going through all the reports now. Other notable bug fixes are the double collisions and ds_grid bugs. some more have not really been solved but just documented in the manual.

I will update all the bug topics when GM8 is fully released. Would it be possible please xot to sort all the bug topics out here properly into the Game Maker Bugs forum before the GM8 release? Or have you not managed to find an adequate way of doing so?

#17 Re: GML Reference » GM8 - Things that work differently than GM7 » 2009-09-07 13:57:46

Well I've learnt more from Marks remarks that things work different internally than what I thought they did. I guess I should not have been making presumptions about the mechanism GM uses. Mark has said they plan to do a lot of speedups of code in the next version of Game Maker though, maybe if we're lucky the functionality will also change to allow this to be possible.

#18 Re: GML Reference » GM8 - Things that work differently than GM7 » 2009-09-05 13:32:25

Yes he is making his way through a lot, I think he is planning to get through all the reports before the next BETA release which is great. There is not actually that many left now, if he keeps up this rate it shouldn't take that long.

Some of his reports have been on a slightly more positive note this time. He has commented that a lot of suggestions could be good to implement but that he is not planning on altering things for this version, so there is at least hope that some of these things could be implemented in the future. Most of these are commonly known suggestions which most people would like to see.

These include:

Redo of graphics system. So far mentioned the possibility of adding option to disable bilinear filtering.
Extending the loading mechanism. So far mention possibility of different kinds of loading bars and deactivating loading bar completely.
Changing to arrays. So far mentioned making arrays passable and extended possibilities when initializing arrays .
Short-circuiting expressions.
Ability to have var declaration without using a semi-colon.
Extending the debugging mechanism.
Script, DLL api and gm functions be able to return multiple values via arguments parameters.
Functionality for index = script_add(name,code);
Tile count and tile found functions


I don't wish to guess what will be implemented in GM9 or not though, there could be all sorts of changes/improvements/additions in GM9 given the rewrite and new blood in YYG's looking and working with the source. I also wouldn't want to take a guess at how long it will be before it is released, however I am thinking it will probably be quite a long while.

There are couple more old bugs/glitches fixed:

- The draw_path bug has been fixed: http://www.gmlscripts.com/forums/viewtopic.php?id=1629

Mark actually said the issue was it not drawing beyond 4000 pixels not the amount of points. I never thought of it being the distance but I should of really because in the example file it actually draws a bit past the point when the bug kicks in, it's obvious now. I will update that soon.

- Mark's fixed a small glitch with show_message_ext: http://gmc.yoyogames.com/index.php?showtopic=424954

- Mark's fixed a small glitch with evaluating 0.5 as true in expressions. Ie in the case of this code:

Expandif (0.5)
{
    show_message("This isn't shown");
}
else if !(0.5)
{
    show_message("This isn't shown either");
}

Also a few little changes:

- About a bug report on closing the debugger:

I anyway changed the working of the close button in the debug form. It will no longer stop the game, only close the debug window.

- Also Mark said he added a suggestion of mine which is a zoom feature in the new mask properties window. I had a good feeling that suggestion would get through.

There have still been a lot of suggestions shot down though (a lot of them were Icuurds). Some noticeable ones for me are:

- Unfortunately he said he does not plan on changing mod so it has proper cyclic behaviour with negatives. Saying it behaves this way in many programming languages, which is true but annoying in all of them in my opinion. I would fight against this call but I doubt he would change it any way as he said he doesn't really plan on changing gml in this version. In the next version beta release I will bring it up again, just got to live with it in the mean time.

- He also rejected the notion of changing # to \n for the new line mechanism. He agreed it would be better but said it would not be worth the incompatibility with previous versions.

- The suggestion for an argument_count variable has been dismissed. Though he did not specify his reasons for this.

#19 Re: GML Reference » GM8 - Things that work differently than GM7 » 2009-09-05 01:39:14

xot wrote:

His comment about trigger errors is really peculiar. GM's error system normally gives like seven pieces of information: action number, event, object, row, column, source code, error type. What's so different about triggers versus a step event?

I'm almost tempted to ask him, but that is not what the report system is used for so I am not going to.

Fortunately most triggers will only be executed from a specific corresponding object. I think a new 'good coding practice' which I will employ is to put the object name in the title of triggers. This will then be beneficial for both error reporting and general organisation in the game. Although saying that I doubt I am actually ever going use triggers anyway smile

#20 Re: GML Reference » GM8 - Things that work differently than GM7 » 2009-09-04 21:07:59

Mark's actually getting through quite a lot of reports. Looks like I might have been wrong when I said he would miss some bug reports out. Lots to interesting things from Mark's last report sessions. Unfortunately a lot of them are remarks that they are not fixable.

Error reporting for trigger events do not show objects in the report: (http://gm8.yoyogames.com/view.php?id=241)
Mark's response to this was:

In the system I can only report one thing and I think the trigger is more important than the object.

So it looks like it's not going to get fixed. I'm rather curious to why only one thing can be reported.. what makes triggers different to anything else or have they just not be implemented thoroughly?

Bug where persistent object instances deactivated in one room can not be reactivated in another. (http://www.gmlscripts.com/forums/viewtopic.php?id=102)
Mark said this is too difficult to solve so has just put a warning about it in the manual.

Both the other bugs with instance deactivation, in the draw and creation events. (1, 2)
Mark remarked that he didn't know what the problem was with either and that they would be too difficult to solve. So has made warnings in the manual about both instead. He said:

These problems are caused because of the following: When drawing the instances we obviously run along the list. Now when you deactivate (or activate) something, the list changes. But the drawing loop will continue running along the old list. In this way it can miss instances or treat them twice.

Even though this clearly is a bug I have no idea how to solve it efficiently. I could leave the deactivate instances in the list and check whether they are deactivated, but this destroys the whole idea of deactivating because it would no longer save much running time.

Maybe the best idea would be to completely remove the notion of deactivation. But for compatibility reasons I cannot do this. I added a comment indicating this in the documentation.

Given the nature of the bugs I am personally dubious to whether this reasoning means the bugs cannot be fixed. I think they are both caused by a mistake in choosing instances upon a changed list which could surely be corrected without slowing down normal execution. Given this information I am going to try and work out exactly how GM handles activation/deactivation, then try and work out where an error could of come into play in making these bugs occur so I can report to Mark directly why I think the bugs are happening and what could possibly be done to solve the issue.

I can understand though that something like deactivation would be a nightmare to program and it is probably a web of mess getting it to work correctly in GM. But that shouldn't be a reason for him to give up on deactivation completely, just because there are a few bugs he could not solve.

Computational function errors and crashes (http://www.gmlscripts.com/forums/viewtopic.php?id=1628):
Mark's comment to this:

In some sense. I cannot really fix it because the Dephi functions to handle this type of conversion cannot handle it. However, the game now no longer crashes and the string ERROR is returned.

This is very interesting. Normally I would expect Mark just to stick a normal error message in these cases. This now means you will now be getting "cannot compare argument errors" when using the functions which could be very confusing to someone if this functionality is unknown to them, so I hope it is properly documented in the manual. However doing this means the functions can now still be misused by user input without stopping the game due to an error report which could be useful.

Fixes:
So along with those reports there have been quite a few suggestions that have been shot down. But one suggestion has seemingly been implemented which is to have a new variable debug_mode to detect whether you are in debug mode or not: http://gm8.yoyogames.com/view.php?id=310

Also another one of the old bugs has been marked as fixed: the draw_line_width_color when length equivalent to 0 (http://www.gmlscripts.com/forums/viewtopic.php?id=98)

Board footer

Powered by FluxBB