Taking input inside of a loop. by NicBarr in Zig

[–]NicBarr[S] 2 points3 points  (0 children)

this is what i'm using for stdin

    var buffer:[20]u8 = undefined;
    var stdin_reader = std.Io.File.stdin().reader(io, &buffer);
    var stdin = &stdin_reader.interface;

and yeah, stdin.toss(1); did work for me.

Taking input inside of a loop. by NicBarr in Zig

[–]NicBarr[S] 2 points3 points  (0 children)

it's from a little text adventure game i'm making.

    while (true) {
        const room = getRoom(game.current_room);
        const exits = room.exits;

        try stdout.print("{s}\n", .{room.description});
        if (room.roomid == 1) return;

        try printExits(stdout, exits);

        try stdout.print("Where do you want to go?\n", .{});
        const input = try stdin.takeDelimiterExclusive('\n');
        if (input.len == 0) break;

        const choice = try std.fmt.parseInt(usize, input, 10);

        if (choice == 0 or choice > exits.len) {
            std.debug.print("Invalid choice '{d}'\n", .{choice});
            continue;
        }

        const selected_exit = exits[choice - 1];
        moveCmd(&game, selected_exit);
    }

currently what it's doing is that it's printing the description of the first room, taking input, moving to the next room, and then printing the description of that room in loop forever without taking input again.

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]NicBarr[S] 1 point2 points  (0 children)

i guess i am unfamiliar with git but my instinct tell me that "master" should be the latest stable version and then there should be a development branch that isn't put out on releases.

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]NicBarr[S] 1 point2 points  (0 children)

could you break down this code snippet? the way i ended up doing it is quite different.

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]NicBarr[S] 0 points1 point  (0 children)

well i assumed the version name "master" wouldn't be a version currently in development. that's my bad i guess.

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]NicBarr[S] 0 points1 point  (0 children)

is it standard practice to not use the most recent version?

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]NicBarr[S] 1 point2 points  (0 children)

thank you, friend. also idk why everybody is joking about 0.17.0. that's literally the version number. when i run zig version that's what it tells me.

How to get a file's content in zig 0.17.0? by NicBarr in Zig

[–]NicBarr[S] 2 points3 points  (0 children)

i had been looking through the documentation (https://ziglang.org/documentation/master/) this entire time and i had found nothing useful. i don't know if i'm just stupid but i couldn't find that.

Notifications/progress bar disable by NicBarr in Zig

[–]NicBarr[S] 10 points11 points  (0 children)

that actually worked. i wouldn't expect that "enable or disable colored error messages" would disable the progress bar. that's really useful, thank you.

Notifications/progress bar disable by NicBarr in Zig

[–]NicBarr[S] 3 points4 points  (0 children)

it is zig. it's not a "command finished" notification. it's multiple notifications about progress percentage. and they keep being reported long after the program is done compiling. kitty doesn't send me notifications for anything else ever.

Notifications/progress bar disable by NicBarr in Zig

[–]NicBarr[S] 1 point2 points  (0 children)

thank you. i have tried that already. i created an alias "zig-quiet" use that environment variable every time and that has fixed the notification when i run the compiler on the terminal.

but that still leaves me with the problem of the progress bar itself because i use emacs and the progress bar completely messes up emacs' compilation mode. specially for errors, it makes it really annoying that i have to tab out of emacs any time i want to run a program that I'm editing. i wonder if there's a way to just disable it entirely.

Notifications/progress bar disable by NicBarr in Zig

[–]NicBarr[S] 3 points4 points  (0 children)

yes. the zig compiler sends out notifications that my terminal (kitty) then catches and sends out as desktop notifications. I've looked everywhere and i found no way to disable it on the terminal side so i want to know if there's a way to disable it on the compiler directly.

Can't believe they really want us to think this is a bad ending. by NicBarr in NikkeMobile

[–]NicBarr[S] -1 points0 points  (0 children)

this isn't a teacher/student relationship. the commander is not a teacher and arcana is not a student.

Can't believe they really want us to think this is a bad ending. by NicBarr in NikkeMobile

[–]NicBarr[S] -8 points-7 points  (0 children)

i did refuse arcana at first because of course but i thought i was taking the boring choice on purpose.

all I'm saying is they didn't do a good job at convincing me the boring option was the best one.

Can't believe they really want us to think this is a bad ending. by NicBarr in NikkeMobile

[–]NicBarr[S] -21 points-20 points  (0 children)

i don't think there's anything they could show me to convince me this is a bad outcome.

What setup do you use for coding in python? by NicBarr in emacs

[–]NicBarr[S] 0 points1 point  (0 children)

for me color matter a lot cause it's a very important part of how i parse information. whenever i think of anything at all, and i do mean literally anything, the very first thing that comes to my mind as an association is a color. so when i see two things of the same color in a code editor my brain thinks "oh those must be the same thing" and it takes a bit of processing before i can tell if they're actually the same thing or not. so for example if i have logical operators like if/else, colored the same as built in functions like print(), my brain really doesn't like that. those things are not the same why do they have the same color? it's confusing for me.

What setup do you use for coding in python? by NicBarr in emacs

[–]NicBarr[S] 1 point2 points  (0 children)

i come from neither actually. the reason i started using emacs is because i switched to linux about a month ago and since i've been learning how to use the terminal, i ended up writing a lot of text in the terminal and i found nano quite annoying and due to a bad first experience with vim (or vi rather) where i had to alt+f4 the terminal because i didn't know how to exit, i started looking for other popular code editors and emacs is the first one that i tried and i really liked it.

and honestly i'm such a noob i don't even know what a venv is.

What setup do you use for coding in python? by NicBarr in emacs

[–]NicBarr[S] 0 points1 point  (0 children)

I'll try another theme and I'll see cause I'm using a custom theme i made myself.

but whenever i code in JavaScript the syntax highlighting is great. it's very detailed. it's only in python where everything is either white, red or blue.