fix bug with console commands

This commit is contained in:
Tuomas Katajisto 2025-08-01 21:24:48 +03:00
parent 77a70fc139
commit 495c02e1b1
3 changed files with 29 additions and 1 deletions

View File

@ -40,6 +40,23 @@ current_mode : Trile_Editor_Tool_Mode = .AREA;
current_trile : *Trile;
#scope_export
new_trile :: (name: string) {
print("Create new trile: %\n", name);
set_trile_gfx(current_trile.name, generate_trile_gfx_matias(current_trile));
newt : Trile;
newt.name = sprint("%", name);
set_trile(newt.name, newt);
current_trile = get_trile(newt.name);
} @Command
edit_trile :: (name: string) {
set_trile_gfx(current_trile.name, generate_trile_gfx_matias(current_trile));
current_trile = get_trile(name);
} @Command
#scope_file
apply_tool_to_trixel :: (x: s64, y: s64, z: s64) {

View File

@ -90,7 +90,7 @@ add_console_commands :: (message: *Message, w: *Workspace) {
case .STRING;
print_to_builder(*builder, "a% : string;;\n", i);
print_to_builder(*builder, "if args.count > % {\n", i);
print_to_builder(*builder, "a% := args[%];\n", i, i);
print_to_builder(*builder, "a% = args[%];\n", i, i);
print_to_builder(*builder, "}\n");
case;
compiler_report(sprint("Argument % is of type %, which is not handled by automatic command registration.", arg_name, type_tag), make_location(cast(*Code_Node)arg), .ERROR);
@ -102,6 +102,7 @@ add_console_commands :: (message: *Message, w: *Workspace) {
print_to_builder(*builder, "return \"Something really really weird has happened. Your argument count somehow went trough all the return checks....\";\n");
print_to_builder(*builder, "}\n");
str := builder_to_string(*builder);
// print("Generated: %\n", str);
array_add(*console_commands_to_register, sprint("%", expression.name));
add_build_string(str, w.*);
free(str);

View File

@ -65,6 +65,15 @@ get_trile :: (name: string) -> (*Trile, success: bool) {
return trileptr, true;
}
list_trile :: () -> string {
count := 0;
for v : trile_table {
console_add_output_line(sprint("%", v.name));
count += 1;
}
return tprint("% triles", count);
} @Command
Material :: struct {
addRoughness : u8 = 0;
roughness : u8 = 4;
@ -79,6 +88,7 @@ Trixel :: struct {
};
Trile :: struct {
name : string = "test";
trixels : [16][16][16] Trixel;
};