level_load (STRING* filename);
Level change;
creates an empty level or
loads a new level based on a level map (WMB), terrain (HMP)
or model (MDL).
Parameters:
filename -
STRING* or char*; name of the map, model, or
terrain file,
or NULL for an empty level.
Remarks:
- The current level is terminated, the cache holding level
entity files is purged. All current entities in the old level are
removed,
thus all entity pointers referring
to them
can't
be used anymore.
For preventing an entity file from being purged at level change - which could make sense for speeding up level loading - define it as a
view entity.
-
Functions assigned to
or called by
entities - that means all functions in which
the my pointer
is not zero - are automatically terminated at their next wait call.
All other functions in which my is zero, such as the main() function,
will keep running and won't change,
even if a different script was assigned in WED to the new level.
- A6 One frame cycle after this instruction
the level is loaded, two frame cycles after the instruction the
local entities in the new map are created and their
actions are started.
Wait two frame cycles (wait(2);) before modifying
the level, for instance by creating entities.
This restriction does not apply anymore
for A7 that loads the level immediately.
- When giving a HMP or MDL file name,
the new level contains this terrain or model only. When using NULL or an
empty string (""), an empty level will be loaded.
- A7 During the load process, the on_level event can be used to display
a progress bar or animation on a panel.
-
One frame after level loading the last_error variable indicates
loading errors.
Speed:
SlowExample:
level_load("newlevel.wmb"); // load level newlevel.wmb
See Also:
game_load, game_save,
level_free, on_level, last_error
► latest
version online