GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2008-03-23 12:24:55

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

room_tile_add - GM6 and GM7 BUG

The function room_tile_add() does not properly set the blending color of the tile to white. This is not a design feature, this is a bug. This bug is present in GM6 and GM7. GM5 works as expected. The color assigned appears random, although tiles placed at the same time have the same color. The is no convenient workaround. At first I thought that it would be simple to store the ids of the tiles as they are added to the room and then after the room switch, set the blending. The problem is, room_tile_add() returns an index, not an id. The index appears to be all but useless, there isn't anything that interfaces with it that I can find. There is the possibility that adding 10000001 to the index will produce the correct id, but this seems sketchy.

GMC member torigara had this to say:

torigara @ GMC wrote:

The issue has reported at least three times here (hint: search.) I haven't seen any workaround is made, though.

One idea is to make the room add tiles to itself on its creation, e.g.:

room_set_code(other_room, "tile_add(bla bla bla);
tile_add(bla bla bla);
...");

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

It's such a crap problem to work around, a custom functional replacement seems in order. Something to record room_tile_add() instructions, and then carry them out when the room is changed, for instance in the room creation code. I think I'll do that.


Abusing forum power since 1986.

Offline

#2 2008-08-29 13:59:06

Fede-lasse
Member
Registered: 2008-07-18
Posts: 4

Re: room_tile_add - GM6 and GM7 BUG

This also happened to me when making a level editor with tiles. What I did as a workaround, was setting an alarm to 1 step and then, in the alarm, looping through all tiles in the layer 1000000 and setting their color blending to white. Also, my tiles in this case are 48x48.

set_automatic_draw(0);
alarm[0] = 1;

And in Alarm 0:

var i,ii,tile;
for (i=0; i<room_width; i+=48) {
  for (ii=0; ii<room_height; ii+=48) {
    tile = tile_layer_find(1000000,i,ii);
    if (tile_exists(tile)) {
      tile_set_blend(tile,c_white);
    }
  }
}

set_automatic_draw(1);

Last edited by Fede-lasse (2008-08-29 13:59:50)

Offline

#3 2009-05-31 16:57:16

flexaplex
Member
Registered: 2008-12-11
Posts: 72

Re: room_tile_add - GM6 and GM7 BUG

Brief Description:            room_tile_add - sets tiles blend to a random color instead of white when used
GM Versions:                   GM6, GM7
References:                     [1] [2] [3]
Example File:                   room_tile_add bug.gmk
Bug Confirmed:                Yes
Hardware Dependent:     No

Main Info:

When using the room_tile_add function when going to the room the tile's blend color is set incorrectly to a random color instead of white. This makes the function rather unusable.

Workaround:

There is no nice workaround to this, however one way is to use the add_tile function (which doesn't have this bug) in the room creation code instead. Doing this you can make your own replacement room_add_tile function like so:

//room_tile_add(ind,back,left,top,width,height,x,y,depth)
room_code[argument0] += 'tile_add('+string(argument1)+','+string(argument2)+','+string(argument3)+','+string(argument4)+','+string(argument5)+','+string(argument6)+','+string(argument7)+','+string(argument8)+');';
room_set_code(argument0,room_code[argument0]);

In order to use this script you must first initialise a room_code array which is used to track the room creation code string for each room. In the case where you are already using instance creation code in a room you need to set the array to the corresponding code string used there otherwise just initialise it as an empty string. For example:

//note: this should be initialised in a controller object at the start of the game.

globalvar room_code;
room_code[room1] = "";
room_code[room2] = "instance_create(20,20,obj_player);";

This would be the initialisation if you had no instance creation code in room1 and the instance creation code:  instance_create(20,20,obj_player);  in room2.

Last edited by flexaplex (2009-06-21 20:01:50)

Offline

Board footer

Powered by FluxBB