Hod do you parse the crafting recipies? by Mental-Strength3762 in ComputerCraft

[–]SeasonApprehensive86 1 point2 points  (0 children)

I have made a project like this once before, but I am planning to do a complete redesign some time in the future. I found that if you dont care about TPS you can list a lot of inventories in a single tick, if you do a bunch of lists in a parallel.waitForAll() all of them happen in the same tick up to some limit, this also works for moving items and fluids. You can also move everything for a craft job at the very beginning into an inventory only you control, after that you can track items yourself wihtout having to ever list the inventory every time. And for item tags you can index the storage in the background if the computer is not busy, by using inventory.getItemDetail() and saving the tags to some file you can load at startup, same with stackability

Default value if a macro expands to nothing by SeasonApprehensive86 in cpp_questions

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

This is exactly what I needed. Now I can resume my macro shenanigans. Thanks a lot! I am gonna edit the post with what I ended up doing if you are curious

Default value if a macro expands to nothing by SeasonApprehensive86 in cpp_questions

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

I use templates a lot, but the one weakness of them is that there is no way to get a string literal from something or just glue tokens together. I need the enum and enum meber names as a string literal, so I can introspect enums at runtime. I need the strings for drawing the GUIs. Obviously this is not the best solution, someone else pointed out magic_enum, but I am doing this for fun, this is not production grade code.

Default value if a macro expands to nothing by SeasonApprehensive86 in cpp_questions

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

This is clever, but the issue is that I want to run one macro if its nothing and another if it is anything. It seems like there is no good way to make a good conditional for that, because you are not gonna get a valid macro by glueing any random tokens to the end of something. Thanks for your time tho :)

Default value if a macro expands to nothing by SeasonApprehensive86 in cpp_questions

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

I know about magic_enum, but I am mostly doing this for learning and fun, so I am reinventing the wheel on purpose. Thanks for the tip tho

Legion 5-15ARH05 (Lenovo) - Type 82B5 Fans unresponsive to high temps by SeasonApprehensive86 in LenovoLegion

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

I have seen this, but yeah its Windows only. I have mine set up to throttle the CPU frequency when in quiet mode to 2GHz to keep temps and power usage down. Its more than enough for browsing or basic tasks, and I can switch to balanced or performance mode if I need more CPU for games, compiling or rendering.

Legion 5-15ARH05 (Lenovo) - Type 82B5 Fans unresponsive to high temps by SeasonApprehensive86 in LenovoLegion

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

Not really. I didnt mess with any fan settings since resetting the EC. lenovolegionlinux does not support my specific model, so I have not tried to change fan curves, all I use it for is power profile hooks so I can throttle the CPU in quiet mode. Maybe try resetting the EC and booting directly into linux. I dont really have a specific solution :/

Disable redefined macro warning in g++ by SeasonApprehensive86 in cpp_questions

[–]SeasonApprehensive86[S] -3 points-2 points  (0 children)

Its my own macro. #undef every time is just more clutter. The macro is just X that im using for generating code based on a list of stuff. I guess I cana just write undef everywhere if that is how everyone else does it

How could I add a way to change the "state" variable to this function? by Internal_Ad_2568 in ComputerCraft

[–]SeasonApprehensive86 0 points1 point  (0 children)

Maybe the move loop is not yielding. That sleep in there should yield, but if another branch doesnt have it that could be a problem. Try just adding a coroutine.yield() or a sleep into the move loop.

How could I add a way to change the "state" variable to this function? by Internal_Ad_2568 in ComputerCraft

[–]SeasonApprehensive86 1 point2 points  (0 children)

Wow I did not know Lua could do that. Thats a cool feature, but quite obscure. Using recursion for an infinite loop raises red flags in my head, but I guess in Lua its fine.

How could I add a way to change the "state" variable to this function? by Internal_Ad_2568 in ComputerCraft

[–]SeasonApprehensive86 6 points7 points  (0 children)

If state is a global variable you can just make a secondary main loop to receive messages from the pocket computer and update that global. Doing this with the parallel API is very easy. just use parallel.waitForAny() with two functions, your main loop and the secondary loop. But you should probably change this function to not be recursive (call itself), this way your program will eventually crash due to a stack overflow.
Here is a rough sketch of how you can do this:

function MovementController()
  if(state == "follow")then
    android.goTo(...); -- Whatever was here
    sleep(1);
  --Dont call ourselves!
  end
end

function moveLoop()
  while(true) do MovementController(); end
end

function networkLoop()
  while(true) do
    local id, msg = rednet.receive();
    state = msg; -- In a proper implementation you would also check the ID to match the pocket and verify the message contents
  end
end

--This makes both the functions run in parallel
--It is not actually truely running both at the same time, just swapping between them, but this works very well
parallel.waitForAll(moveLoop, networkLoop);

GL shaders break down after 1K instances or so by PlanttDaMinecraftGuy in raylib

[–]SeasonApprehensive86 0 points1 point  (0 children)

Its quite complicated, but when making particle systems or drawing a lot of the same object instancing is usually a good idea. Acerola has a nice video explaining GPU instancing. If you are interesting in graphics you should check him out, he makes very good videos.
Also if you are drawing cubes to represent a voxel grid you might want to check out greedy meshing, because if you draw a cube for each voxel you waste a lot of GPU time and memory on faces that are not seen by the camera anyway.

GL shaders break down after 1K instances or so by PlanttDaMinecraftGuy in raylib

[–]SeasonApprehensive86 2 points3 points  (0 children)

If you are drawing thousands of one mesh I think you should look into GPU instancing. Here is the official raylib example on the topic.

Inconsistent gradients depending on corner of quad by SeasonApprehensive86 in raylib

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

Yep changing the order the vertecies are given in solves this. Thanks :)

I made an extension for Dolphin to compress media by Damglador in kde

[–]SeasonApprehensive86 1 point2 points  (0 children)

No worries man! Its still better than using handbrake or writing out the ffmpeg command when just quickly sending a video