add_engine_console_commands :: () { add_command(console, "new", cmd_new_scene); add_command(console, "load", cmd_load_scene); } cmd_new_scene :: (arguments: [] string) { if arguments.count != 1 { console_error("Expected one argument, got %\n", arguments.count); return; } if engine.mode == .PLAYING { console_error("Can't create new scene while in play-mode\n"); return; } scene_path := tprint("../assets/scenes/%", arguments[0]); if file_exists(scene_path) { console_error("Scene '%' already exist\n", arguments[0]); return; } #if EDITOR { engine.editor.selected_entities.count = 0; } if engine.current_scene != null { unload_scene(engine.current_scene); } engine.current_scene = create_scene(arguments[0]); switch_to_scene(arguments[0]); console_success("Scene '%' loaded\n", arguments[0]); } cmd_load_scene :: (arguments: [] string) { if arguments.count != 1 { console_error("Scene '%' doesn't exist\n", arguments[0]); return; } scene_path := tprint("../assets/scenes/%", arguments[0]); if !file_exists(scene_path) { console_error("Scene '%' doesn't exist\n", arguments[0]); return; } #if EDITOR { engine.editor.selected_entities.count = 0; } switch_to_scene(arguments[0]); console_success("Scene '%' loaded\n", arguments[0]); }