This might sound crazy, but as I am paving the way for my external resource engine, where I would use my created functions to extract a particular segment from a file.....
Currently you can use sound_add and sprite_add,
background_add, etc. but they all add from files.......
So in this case it means I would have to have my engine read bytes from a file and write them to another and invoke the *_add functions to read the newly written file.
In order to avoid 2 unnecessary steps such as writing and reading,
what if there was a function to add sprite, sound, background from variable. As Harri suggested from data / raw, so it can take from content of a variable or buffer.
Here is an example:
file=".\data\graphics.res";
file2=".\data\cache\intro.png";
file_bin_open(file,0);
file_bin_seek(file,16000);
repeat (1024)
{
data += chr((file_bin_read_byte(file)));
}
file_bin_close(file);
file_bin_open(file2,1);
repeat (size)
{
i++;
character=string_byte_at(data,i);
file_bin_write_byte(file2,character);
}
file_bin_close(file2);
sprite=sprite_add(file2,1,0,0,0,0);
obj_0.sprite_index=sprite;
This is just a quickly made draft, inside a create event,
will read 1024 bytes from graphics.res starting at position 16000 and store into variable data. Then it will write a file with the contents of data.
As you can see here I am invoking the sprite add which will read the newly created file.
What if there was a way to simply say:
sprite=sprite_add_from_string(data,1,0,0,0,0);sprite=sprite_add_from_raw(data,1,0,0,0,0)
This way I could simply remove all code involved for writing ! All that would be needed is a file binary read storing it in data and fetching whatver is in data to sprite add.
Effectively loading resources directly to memory.
This would save disk space and speed things up.