Yes. It is possible.
But it could be a little bit difficult because loading a level happens within one single frame. So you have to code something that just looks like a progress bar depending on the amount of objects created by script in your level.
You could devide the loading process in to several processes.
For example:
process1 = loading the level
process2 = loading the models
process3 = loading the sprites
and so on....
The progress bar is full when a certain VAR has reached 100.
Code example:
var loading_percent;
var loading_processes = 3; //number of loading processes
var process_number;
var process_activity;
var bar_progress_per_model;
var bar_progress_per_sprite;
var models_to_load = 200; //the amount of models to load
var sprites_to_load = 400; //the amount of sprites to load
define loading_level, 1;
define loading_model, 2;
define loading_sprite, 3;
define I_am_loading, 1;
define I_finished, 2;
function load_my_world(){
progress_bar.visible=1;
loading_percent = 0;
Now_load_level();
while(process_activity==I_am_loading){
wait(1);
}
Now_load_models();
while(process_activity==I_am_loading){
wait(1);
}
Now_load_sprites();
while(process_activity==I_am_loading){
wait(1);
}
}
function Now_load_level(){
process_activity=I_am_loading;
process_number = loading_level;
level_load("level_name.wmb");
wait(3);
loading_percent = 100/loading_processes * loading_level; //this is 100/3 * 1 = 33,3333333...
process_activity=I_finished;
}
function Now_load_models(){
process_activity=I_am_loading;
process_number = loading_model;
bar_progress_per_model = 100/loading_processes/models_to_load;
temp.x=0;
temp.y=0;
while(temp<models_to_load){
ent_create(model_name,vector,function);
temp.x+=1;
temp.y+=1;
loading_percent = (100/loading_processes * loading_level)+ (bar_progress_per_model*temp.x);
if(temp.y>10){temp.y=0;wait(1);} //wait every 10 models, so that the progress bar can update on the screen
}
loading_percent = 100/loading_processes * loading_model; //100/3 * 2 = 66,6666...
process_activity=I_finished;
}
function Now_load_sprites(){
process_activity=I_am_loading;
process_number = loading_sprites;
bar_progress_per_sprite = 100/loading_processes/sprites_to_load;
temp.x=0;
temp.y=0;
while(temp<sprites_to_load){
ent_create(sprite_name,vector,function);
temp.x+=1;
temp.y+=1;
loading_percent = (100/loading_processes * loading_model) + (bar_progress_per_sprite*temp.x);
if(temp.y>20){temp.y=0;wait(1);} //wait every 20 sprites, so that the progress bar can update on the screen
}
loading_percent = 100/loading_processes * loading_sprite; //this is 100% (100/3 * 3)
process_activity=I_finished;
}
I think, this is it. I shrinked it a bit but I think you can see the way it works.
First the bar will make a large step of 33,3333% then until 66,6666% it will move in small steps, depending on the amount of models and then until 100% in small steps again depending on the amount of sprites.
So now you just have to change only some vars in case you want to add some more processes.
Please don`t mind typing mistakes or grammar thingys :-). It`s not my native language.
best regards