Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Fingercomp

Members
  • Content count

    106
  • Joined

  • Last visited

  • Days Won

    24

Fingercomp last won the day on July 7

Fingercomp had the most liked content!

2 Followers

About Fingercomp

  • Rank
    Leading Member

Contact Methods

  • GitHub
    Fingercomp
  • IRC
    fingercomp

Profile Information

  • Gender
    Male

Recent Profile Visitors

1292 profile views
  1. Fingercomp

    Internetcard github download

    Oh, right... I forgot about that, sorry. Replace socket:close() with response:close().
  2. Fingercomp

    Internetcard github download

    The code below tries to make sure that the request finished, and then it reads the response. Unfortunately, I can't test the program in the game for various reasons. Could you try using it? local c = require("component") local computer = require("computer") local internet = require("internet") local f = io.open("test.txt", "wb") local imax = 0 local xmax = 75 local ymax = 180 local zmax = 87 local TIMEOUT = 5 -- in seconds local link = "https://raw.githubusercontent.com/LordNocturnus/sf-" local folder = "/master/" local pos = 0 for i = 0, imax do for xb = pos, xmax do for yb = 0, ymax do for zb = 0, zmax do print(xb, yb, zb) local file = xb .. "-" .. yb .. "-" .. zb .. ".mb3d" local url = link .. i .. folder .. file local status, response = pcall(internet.request, url) if not status or not response then print("Download of " .. url .. " failed.") else local startTime = computer.uptime() while true do local result, isFinished = pcall(response.finishConnect) if result and isFinished then break elseif not result then print("Could not connect to " .. url .. ".") os.exit() elseif computer.uptime() - startTime > TIMEOUT then print("Request to " .. url .. " timed out") os.exit() else os.sleep(0.25) end end local f = io.open(file, "wb") for chunk in response do f:write(chunk) end f:close() socket:close() end end end end end
  3. Fingercomp

    OPPM says it's installed but isn't 1.7.10

    Pay attention to what the installer says. It's where to install to, not what to install. You've been trying to install OPPM to a floppy disk or something, but you should've chosen the OpenOS filesystem instead to install it on the system HDD.
  4. Fingercomp

    Internetcard github download

    There are a bunch of questions, so let me start from the easiest ones to solve. There is indeed no such thing as internet.close. You call the close method directly on the response object — and after you no longer need it. You can't read from a socket if you closed it. -- this code... local imax = 10 do local i = 1 while i <= imax do print(i) i = i + 1 end end -- ...is equivalent to the following code: for i = 1, imax do print(i) end -- I recommend using for loops as there's less code to write Now, the main question: how to check if a file exists. The GitHub server returns HTTP 404 status code if a location, the file in our case, does not exist. And, fortunately, the response object provides a method to get the status code: response.response() (from the docstring: function():number, string, table -- Get response code, message and headers). local c = require("component") local internet = require("internet") local f = io.open("test.txt", "wb") local imax = 0 local xmax = 75 local ymax = 180 local zmax = 87 local link = "https://raw.githubusercontent.com/LordNocturnus/sf-" local folder = "/master/" local pos = 0 for i = 0, imax do for xb = pos, xmax do for yb = 0, ymax do for zb = 0, zmax do print(xb, yb, zb) local file = xb .. "-" .. yb .. "-" .. zb .. ".mb3d" local status, response = pcall(internet.request, link .. i .. folder .. file) if not status or not response or response.response() >= 400 then print("Download of " .. link .. i .. folder .. file .. " failed.") else local f = io.open(file, "wb") for chunk in response do f:write(chunk) end f:close() socket:close() end end end end end
  5. Fingercomp

    OPPM not installable

    Oh, too long without yielding... This error means the computer exceeded the timeout, but didn't yield; it's required to prevent "stupidly written or malicious programs" from blocking other computers from running. I can't say oppm is stupidly written (although it isn't certainly the most efficient program ever, either), nor is it malicious. The error can also be thrown if the MC host server (or, if you are playing in a SP world, your computer) is overloaded and causes the game — and the opencomputers — run slower. Less code is executed per second, so it can just be unable to reach an os.sleep call in the default five seconds. In this case, you may want to increase the timeout setting in the OpenComputers configuration file.
  6. Fingercomp

    OPPM not installable

    My guess is that you didn't even install OpenOS, and now you're trying to install oppm on a read-only floppy disk. This won't work, of course. Insert a HDD, boot from the OpenOS floppy, run install, choose openos if you're asked, and reboot the computer when it's done. Then you can try to install oppm.
  7. Fingercomp

    How do you make a loop stop on user input?

    Well, it executes exactly what's written in the code, and is the expected behavior. event.pull("modem_message") stops the program (more specifically, the thread) until it gets the modem_message event. You may want to set a timeout, so that the pull would stop early — returning nil in such case; for example, event.pull(1, "modem_message") sets the timeout to 1 second. Let's step through the program line by line. The first 5 lines don't cause any difficulties, so we skip them. There's the repeat-until loop, and the first iteration is run unconditionally. First, the string "hello" is printed to the screen. After that there's the event.pull line, which (as I said before) stops the program until it gets the modem message. The execution now does not go any further. The program is running — it just waits for a modem message now. You broadcast a stop message; the program gets it, and goes on. select is called, and the actual message is set to the cmd variable. Only then "hi" is written. As the condition is satisfied, the loop stops, and the program exits. if this is not what you wanted, please clarify the intended behavior.
  8. Fingercomp

    Fishing Program

    Actually, it's possible. Here's the program if you don't mind some Russian. Assemble a robot with: an inventory upgrade; an inventory controller upgrade; a redstone card; a solar generator upgrade (optional; you can use a charger instead).
  9. Fingercomp

    HELP MY SERVER IS BLIND... OR AM I BLIND?

    Erm, the thin line is for the modem. The thick line is for components.
  10. Fingercomp

    Double Click Issue/Touch Signal Sent Twice?

    The bug is really simple. To find it, follow through the code line-by-line, analyzing what happens at each line. (This is something I do quite often when debugging an obscure problem.) First, skip the first few dozens of lines until we get to the L65 (short for line 65), where the loop is defined. We then encounter the if block at L68, of which the first branch is actually run (page == "page1" as it was set to this value on L63), resulting in the pageOne call. The next line to examine is L79, where the program stops until it pulls the touch event. Here, I check that the event parameters weren't mixed up. All right, let's go on and press the button. The first condition, on L82, is satisfied (page == "page1", set on L63), so we get the page variable updated to the new value, "page2". But there's more code to run before we loop back! The second condition, on L89. The coodinate mess after the first and evaluates to true. What about page? Well, we've just set it to "page2", so... it, too, yields true. Therefore, the whole condition is satisfied. And the variable is set back to "page1". We loop back, and redraw the first page. This is how we've just spotted the bug. In case you wonder why Event 2 isn't written to the screen: well, it is written. At position (4, 45). You've just mistaken x for y (and vice versa): 4 is the column, 45 is the row. This is clearly beyond the viewport 58×18, so you see nothing actually printed. OK. How should you fix it? It's simple: use elseifs. if (x >= w / 2 - 5 and x <= w / 2 - 5 + 11 and y >= h / 2 - 1 and y <= h / 2 + 1) then if page == "page1" then mon.set(4, 10, "Event 1") table.insert(a, "X") page = "page2" elseif page == "page2" then mon.set(45, 10, "Event 2") page = "page1" end end
  11. Fingercomp

    Guide to the Sound Card

    The sound card is added by Computronics, a wonderful addon for OpenComputers. There are a few who actually know what it does. Even less people are able to use it. No one dares to understand how it works, or so I hope. Anyway, it appeared a few years (?) ago, and is still mostly undocumented. There is a page in the in-game manual, which fails to explain how great the card is. Of course it does! It has a heap of different methods, which you can use to cast many crazy magics to make the sound card sound, and it's impossible to teach someone to do magic by reading a single page. OK, I'm serious now. Last year I managed to understand how to use it, and even wrote a few posts about that. In Russian. Half a year later, I translated them to English. And now I thought of posting a topic here so that you could read them, too. Here's the link. The first two parts are all about basic things, like getting simple sounds, ADSR, and modulation. The third part features a little bit more complex things, like complex numbers and Fourier transforms. I tried to keep it simple, so I could get something wrong. If so, please leave a comment there pointing out the mistake. Grammar fixes are also highly appeciated.
  12. Fingercomp

    Computronics Tape Drive

    Use a file storage that gives you a direct link to the file, not some webpage packed with JS scripts. For instance, https://mixtape.moe/, or any other site like this.
  13. Fingercomp

    Got a problem with reactor.setActive()

    No Lua built-in function, type name, primitive, library, etc. starts with a capital letter. So you should write true, not True.
  14. Fingercomp

    Simple Clock from Fingercomp

    If I remember correctly, the RT does not work on Lua 5.3. Try switching the processor to Lua 5.2 (shift-click while holding it).
  15. Fingercomp

    Problem with adapter using inventory controller upgrade

    See this comment on the issue you opened. It references a few issues that describe similar problems. You can't really say "I guess it's a bug" if you haven't tried solving the problem—without the assumption it's indeed a bug.
×

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.