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

Fingercomp

Members
  • Content Count

    120
  • Joined

  • Last visited

  • Days Won

    35

Everything posted by Fingercomp

  1. @Log Refined Storage provides a great OpenComputers API. See this page for details.
  2. OC bugs should be reported on the issue tracker. It's really inconvenient to manage issues posted on the forums.
  3. You need to call speechBox.say("Message.") to make a speech box say "Message." A speech box also has other methods, use the command below to list them. $ components -l speech_box | less
  4. This program was posted on the Russian forums. It's an automatic market. That means prices are calculated by the program itself. Calculations are based on amount of items sold and bought. If you think this is exactly what you were looking for, I'm calling @Log, the author of the program, here. I'm also sure that there were a few markets that allow the owner to set prices, also posted on the Russian forums. I can try to contact their authors if you want.
  5. Suppose you are creating some monitoring program: tank monitor, energy monitor or whatever. It should print how much energy (or fluid) is stored, draw a progress bar and a few histograms with different update intervals (1 second, 30 seconds, 1 minute and 10 minutes). I don't think printing will cause any programs, so I'll skip it. But what about progress bars and histograms? Well, it isn't not rocket science, of course. But not a really easy thing either. Anyway, a few months ago I've written a small library that makes it easy to draw histograms and progress bars, called "charts". In
  6. Yes, that's right. internet.open creates a TCP socket. They are useful when you need to communicate with a non-HTTP server (you probably know things like SSH, FTP -- those are all non-HTTP protocols). But when you want to send a request to an HTTP server, you need to use internet.request. It's a nice wrapper for component.internet.request that allows to interate over the response body. Like this: local inet = require("internet") local response = inet.request("https://google.com") local body = "" for chunk in response do body = body .. chunk end print(body) Chunk is a small piec
  7. What did you run? Was it require("internet").request("https://google.com:443"), or require("internet").connect("https://google.com:443"), or require("component").internet.request("https://google.com:443"), or require("component").internet.connect("https://google.com:443"), or what?
  8. Place an adapter next to the ender chest and use cables to connect the adapter to the computer. The "ender_storage" component should become available. Type lua to start Lua interpreter and run component.ender_storage.setFrequency(FREQ), replacing FREQ with the frequency you want to set. As for the second question, unless reading the source code of OpenComputers (and other mods that provide OC integration) is an option for you, no. Try to connect blocks to adapter and see if a component appears.
  9. Start the program. Switch to RT mode (i.e. click on the screen). Calculate the difference between the time displayed on the screen, and the real UTC time, in hours (for example, -1 means the real time is 1 hour behind the time shown). Open the program (edit programname.lua) and go to line 10, the one that starts with "CORRECT =". Replace 0 with the difference you've calculated in step 3. On the previous line, replace 0 with the timezone you want (sample values: -6, +3, -10, +11). Save the file (Ctrl+S) and quit (Ctrl+W). Restart the program.
  10. computer.getDeviceInfo was created exactly for this purpose: provide information about devices that don't have a component (processors, solar generators, memory banks). computer.getDeviceInfo returns a table. Its keys are addresses of devices, values that correspond to these keys are tables filled with basic information about a device. So you need to iterate over the returned table and compare fields of tables to expected values. For the solar generator upgrade, class is "power", and description is "Solar panel". Here's how you can check if the solar panel is installed. local sol
  11. Machine is stopped by calling computer.shutdown which is a "low-level" function brought to OpenOS from the bios environment. It becomes obvious that no event is fired when a computer is shutting down. You can override computer.shutdown to fire an event, wait for it to be processed, and then finally stop the machine.
  12. Geolyzer always returns a table of 64 entries. If it's filled partially (that means the volume is less than 64), the remaining entries will be filled with random noise.
  13. That's because you're missing " before and after the string. Instead of just minecraft:barrier, you need to use "minecraft:barrier". Also I'm pretty sure you don't need that minecraft: at the start of the particle name. component.particle.spawn("barrier", 1, 1, 1)
  14. The Lua table can't be just printed -- you'll get the address of the table in memory. Fortunately, there's the serialization library that can serialize a table (convert it into a string). The function to use is serialization.serialize(tbl: table). Or serialization.serialize(tbl: table, math.huge) that will make the returned string way more readable. Before you can use the library in your script, you need to require() the library. local component = require("component") local serialization = require("serialization") print(serialization.serialize(component.me_controller.getItemsInN
  15. Ah, right. When robot returns to the start, it receives the redstone_changed event and immediately repeats the code. The fix is to consume this event before pulling -- this can be done with os.sleep(). while true do local e, addr, side, prev, current = event.pull("redstone_changed") if e and side == sides.back and prev == 0 then farmTrees() end os.sleep(0.25) end
  16. When a redstone input changes, the "redstone_changed" event is fired. It contains the redstone card address, the side, the previous input strength, and the current strength. To wait for an event, use event.pull. You need to require("event") before you use any of the event library's functions. Here's an example. local event = require("event") local sides = require("sides") while true do local e, addr, side, prev, current = event.pull("redstone_changed") if e and side == sides.back and prev == 0 then -- your code here collectFruits() end end
  17. It's better to use block symbols: ▁▂▃▄▅▆▇█ ▏ ▎ ▍ ▌ ▋ ▊ ▉ █ http://www.unicode.org/charts/PDF/U2580.pdf
  18. The problem is on the 65th line. For some reason (it's probably a bug) when running OC 1.6.1, you have to pass the boolean argument to robot.compare. If the argument is true, it will ignore metadata when comparing. If you need the same behavior as on OC 1.5, the argument should be false. So, replace this line with the following code. while not robot.compare(false) do o.sleep(wait) end
  19. I've updated hpm once again. This time the update brings some really useful features. First, I've changed the way you install and remove non-hel packages. Instead of hpm install oppm:package you need to run hpm oppm:install package. This made it incredibly easier to implement the other features. save command no longer exist. To install a package to the current directory, pass the -s flag to install (or oppm:install). Added hel:upgrade that tries to install the up-to-date versions of the installed packages. This is one of the main features of this update, although it was simpl
  20. load is a function that's a part of the Lua standard library. This means that you can use it even in EEPROM programs. The signature of the function is load(chunk[, chunkname[, mode[, env]]]). The first argument is either a string of code you want to run, or an iterator function that returns a Lua code. The second argument is the name of the chunk. It's used for error messages. The third argument is the mode: either "bt" (both binary and text), "t" (text), and "b" (binary). In standard Lua implementations, "b" mode is used to load pre-compiled code returned by string.dump
  21. local function splitEvery(str, n) local result = {} for i = 1, #str, n do local substr = str:sub(i, i + n - 1) table.insert(result, substr) end return result end print(table.unpack(splitEvery("abcdefghi", 3))) --> abc def ghi print(table.unpack(splitEvery("hello, world!", 4))) --> hell o, w orld ! local function splitHalf(str) local leftLen = math.ceil(#str / 2) return str:sub(1, leftLen), str:sub(leftLen + 1, -1) end print(splitHalf("abcdef")) --> abc def print(splitHalf("helloworld")) --> hello world print(splitHalf("programming")
  22. It's better to create a topic with your questions. Anyway, I can answer the second question right here. You need to use event.pullMultiple("event1", "event2", ...). It will stop listening when either event1 or event2 is pushed.
  23. Creating a script in /boot is a poor idea unless the program must be run only when computer starts. Boot scripts are intended to initialize the system. Using /home/.shrc is preferred (this will run the program each time the shell boots, though). @novotd00 I'd just put resolution <x> <y> to /home/.shrc. That's much better than adding code to a file with a completely different purpose (in your case the purpose is to initialize the rc system). By the way, payonel listed the ways to make a program run automatically here.
  24. IIRC, OpenOS 1.6 doesn't load authorun.lua at root fs. This means that you either should add a command to /home/.shrc (this's the preferred way), or modify boot scripts. I guess the program you want to start automatically on boot doesn't require to be run before the shell loads, so just write the path to your program to /home/.shrc. /home/bin/my-program.lua
  25. First, replace local function = hex.toHex(input) to function hex.toHex(input). Second, you can't use = in if condition. If you want to check for equality, use ==. Third, you must end the function with the end operator. Fourth, the return hex line is incorrect. You didn't define the hex variable so the line will make the function return nil. Fifth, you can't do if a,b,c < 42 then. You must check every variable and then "sum" the answer using and, or, not. E.g., a < 42 and b < 42 and c < 42 checks that a, b, c all less than 42. Sixth, this is the most ineffic
×
×
  • Create New...

Important Information

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