hmm. this is harder than i thought...
heres a tutorial i found for external code:
/*
This code will load external code and turn it into objects, to see the
code in the objects, look at "Code.txt"
Example created by Coolist with Game Maker 8 Registered
*/
//Open a text file
text=file_text_open_read("Code.txt");
//Set array id varible
i=0;
//Loop untill we break from the loop
while (1)
{
//Load the code from the text file to a temporary variable
load=file_text_read_string(text);
//Check to see what event type it is and delete the keyword
if (string_copy(load,0,5)=="CRATE")
{
//Set the event type (0=Create) and load the code
code[i,0]=string_delete(load,1,6);
}
else
if (string_copy(load,0,5)=="STEPE")
{
//Set the event type (1=Step) and load the code
code[i,1]=string_delete(load,1,6);
//Add to our array ID only if the last event has been loaded
i+=1;
}
//Go to next line
file_text_readln(text);
//Check to see if we've reached the end
if (file_text_eof(text)==1)
{
//If we have, break from the loop
break;
}
}
//Close the text file
file_text_close(text);
//Set a new temporary varible j and start a loop
for (j=0; j<i; j+=1;)
{
//Create a new object
global.obj[j]=object_add();
//Add a create event to the object with our loaded create text
object_event_add(global.obj[j],ev_create,0,code[j,0]);
/*
global.obj[j] is our object ID, ev_create is the event type (Create Event)
the event number is 0 becuase it is the Create Event, and the last string
is the code which we loaded from the text file.
*/
//Add a step event to the object with our loaded step text
object_event_add(global.obj[j],ev_step,ev_step_normal,code[j,1]);
/*
global.obj[j] is our object ID, ev_step is the event type (Step Event)
the event number is ev_step_normal becuase it is the normal Step Event,
and the last string is the code which we loaded from the text file.
*/
//Give the object a sprite to see it
object_set_sprite(global.obj[j],sprite_fly)
//Create the instance of object global.obj[j] in the middle of the room
instance_create(room_width/2,room_height/2,global.obj[j]);
}
