D
Drago Supremo
Guest
Hi guys,
i'm trying to make a script which stes the tiles of a block of wall based on the sprites stored in its array, but somehow when i call this function on the object the compiler tells me that i' m "trying to index a variable which is not an array".
Each block of wall is built at the start of the room by the object "wall starter"
Here's the pieces of code:
WALL STARTER
SCRIPT REPLICATE
SCRIPT TILESET
[/CODE]
"GROUND BLOCK" CREATE EVENT
i'm trying to make a script which stes the tiles of a block of wall based on the sprites stored in its array, but somehow when i call this function on the object the compiler tells me that i' m "trying to index a variable which is not an array".
Each block of wall is built at the start of the room by the object "wall starter"
Here's the pieces of code:
WALL STARTER
Code:
objectToReplicate = instance_place(x, y, all);
replicationList = ds_queue_create();
ds_queue_enqueue(replicationList, objectToReplicate);
while !(ds_queue_empty(replicationList))
{
objectToReplicate = ds_queue_dequeue(replicationList);
with (objectToReplicate)
{
replicate(other);
if (object_index == obj_ground)
{
tileSet(parent_boundaries);
}
}
}
Code:
///replicate
if !(place_meeting(x, y + 1, object_index))
{
replicated = instance_create(x, y + 16, object_index);
with (argument0) ds_queue_enqueue(replicationList, other.replicated);
}
if !(place_meeting(x, y - 1, object_index))
{
replicated = instance_create(x, y - 16, object_index);
with (argument0) ds_queue_enqueue(replicationList, other.replicated);
}
if !(place_meeting(x + 1, y, object_index))
{
replicated = instance_create(x + 16, y, object_index)
with (argument0) ds_queue_enqueue(replicationList, other.replicated);
}
if !(place_meeting(x - 1, y, object_index))
{
replicated = instance_create(x - 16, y, object_index);
with (argument0) ds_queue_enqueue(replicationList, other.replicated);
}
SCRIPT TILESET
Code:
///tileSet(sprites, boundaries, animated)
placeUp = advancedCollision(x, y - 1, argument0);
placeDown = advancedCollision(x, y + 1, argument0);
placeRight = advancedCollision(x + 1, y, argument0);
placeLeft = advancedCollision(x - 1, y, argument0);
boardXFactor = placeLeft - placeRight;
boardYFactor = placeUp - placeDown;
tFactor = 4 - boardXFactor - 3 * boardYFactor;
sprite_index = sprites[tFactor];
superiorInstance = instance_place(x, y - 1, argument0);
leftInstance = instance_place(x - 1, y, argument0);
xFactor = 0;
if (leftInstance != noone) && (leftInstance.tFactor == tFactor)
{
xFactor = leftInstance.xFactor + 1;
}
yFactor = 0;
if (superiorInstance != noone) && (superiorInstance.tFactor == tFactor)
{
yFactor = superiorInstance.yFactor + 1;
}
rowTiles = 1;
if (tFactor == 4)
{
rowTiles = sprites[tFactor, 0];
}
image_index = xFactor + yFactor * rowTiles;
image_speed = 0;
[/CODE]
"GROUND BLOCK" CREATE EVENT
Code:
sprites[0] = spr_groundLeftSuperiorCorner;
sprites[1] = spr_groundSuperior;
sprites[2] = spr_groundRightSuperiorCorner;
sprites[3] = spr_groundRight;
sprites[4] = spr_groundInterior;
sprites[5] = spr_groundLeftLowerCorner;
sprites[6] = spr_groundInferior;
sprites[7] = spr_groundRightLowerCorner;
Last edited by a moderator: