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

CptMercury

Members
  • Content Count

    54
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by CptMercury

  1. You want a progress bar for the file transfer via modems? There is no built-in method available, so you need custom scripts for this. My approach would start with calculating the file's size and transmitting it to the receiving computer. Then the file is split into packets and transferred; by the size of the arriving packets the progress can easily be calculated. The remaining question is how to split the file. You could either send line by line or send a fixed number of bytes. Depending on your choice, the calculation method for the file size will vary. Number of lines:
  2. Well, you can use “not“, which will do exactly what you‘re trying to do. if not (val > x and val < y) then -- do stuff end But: - not greater than is the same as less than (actually less or equal <=) - not less then is the same as greater than (greater or equal) It would look like this: if val <= x and val >= y then -- do stuff end
  3. Well, you actually just need a computer and an adapter to interact with me-components (not even an inventory_controller upgrade). You also require an database component to configure me I/o stuff (export busses, import busses and interfaces) In order to properly use the export bus, you need to have access to the items in the network. Then, using the database component, you can store information about a stack of items in the database and use this to configure the export bus. The functions for accessing the items in the network are provided by the "common network api", which should be shared
  4. @Chaoschaot234 I think this version is deprecated. Dustpuppy made a new guy lib with more features etc. Have a look at it. Here's the forum post Its installer link is working properly, I just checked.
  5. Ok, as promised, here is a more advanced function. Instead of giving it one string and specify its color, you mark parts of the string and specify foreground (and also background) color by using a xml/html like syntax. If you want to change on part of the string, put it between <color fg=hex, bg=hex>your string goes here</color>. Hex is the color code starting with 0x (like 0xFFFFFF). You don't have to specify both, background and foreground, just set the color you like to change; if you set both, use a comma (,) as delimiter. local component = require "comp
  6. I assume you are currently using the term lib for writing stuff on the screen? For full control over the screen, you need to interact with the gnu component directly. You then need to also specify the x and y coordinate where your text starts. But it's easy to write a function that works exactly like term.write but allows you to specify the colors of each part of the string. local component = require "component" local term = require "term" local unicode = require "unicode" local gpu = component.gpu local function advancedWrite(s, c) -- s is the string, c is its color local x,
  7. Well, first of all, if you only need the message to contain one string, then you are better off by just sending the string as the message, so no need to make a table with that string, serialize the table transforming it into a string which is then send via the modem, once received, transformed back into a table which is then indexed to get the string you want to send... But anyways, I would assume the error with the serialization comes from trying to serialize a nil value. You're using a timeout with your event.pull, that means, event.pull returns nil if no modem_message was received with
  8. Can you post your code and a screenshot of the error message you are getting? This would help alot. I don‘t know exactly what you mean by serialization and why you have problems with the time expiring, but when I had the chance looking at the code I might be able to tell.
  9. Like Molinko said, you need a custom program that will allow you to manipulate another computer. And using network cards might be the best option. There are several ways to write programs that allow sending commands to a second computer; a very naive implementation would use the function load. When passed a string, the string is loaded as a chunk of Lua code and returns a function, that, when called, does whatever was coded in the string. And yes, you need to use event.pull or register a listener via event.listen, but your code needs to "pause" at least every 5 seconds anyways,
  10. In what piece of code you have 3 ends? I only find 3 ends in the last program I posted. There you have one end for closing the main function (2nd end), one for closing the if-statement (1st end) and the last end is for closing the while loop. And for the error: First it would be good if you could post the actual screenshot. Second, could you post the code of the program you were running? From what I currently see, there‘s propably a typo in line 18, but I can‘t tell exactly, what is wrong until I see the actual code.
  11. Hey, in these if statements, you need to use relational operators. Since you want to see if you're variable is equal to a certain string, you need the '==' (two equal signs). So you're code would look like this -- local require commands start local component= require (“component”) local sides = require(“sides”) local rs = component.redstone local event = require(“event”) -- local os = require(“os”) remove this, the os lib does not need to be required, I think -- local require commands end -- Main function start local function main() local username, message = event.pul
  12. I‘m not 100% sure, what causes the error, but it seems the installer doesn‘t handle the http request user data properly. You could try running the following command: wget https://raw.githubusercontent.com/zenith391/Fuchas/master/Installers/openos.lua installer installer Sadly I can‘t test this right now, but it might be worth trying. Edit: Ok, i figured out what is causing the error. The colon (:) in function call "data = con:read(math.huge)" in line 11 must be replaced with a period (.). So what definitely works is running pastebin get s2YZJ0T6 installer.lua
  13. You can also use event timers. Then you need a function to check and send your stuff. local event = require "event" local function dostuff() -- this is ur function that is doing stuff end local interval = 20 -- time in seconds between the runs of the function event.timer(interval, dostuff, math.huge) -- math.huge for infinite repeats Or if you want to keep Skript as it is, you can use Molinko's approach with os.execute Then your code would be: event.timer(interval, function() os.execute("/path"), math.huge)
  14. Ok, I forgot the program doesn‘t always run in the executor thread. Too bad there are only ways to have blocking high precision sleeps and timers and no non-blocking alternatives... But anyways, thanks alot
  15. @payonel Hey, I was wondering if there is any chance to see a high precision computer.pull function in OpenComputers, allowing to have timeouts below one tick (I believe the currently used computer.uptime only returns time with .05 s precision). With that in hand, non-blocking sleeps and timers for small time intervals should be realizable. I was trying to implement this in openOS by adding a computer.pull function using os.clock instead of computer.uptime and changing some other libs accordingly, but it didn't work out. So I'm asking if there is any reason against adding a
  16. Hey, you are correct, string metatables are protected, so you can‘t change or add functions. I assume, unicode.len(string) is not what you want, or is it? In case you want to have an object, you could interact with, you could build one. local unicode = require"unicode" local ucode = {} local mt = { __len = function(self) return unicode.len(self.string) end } function ucode.new(str) local obj = { string = str } return setmetatable(obj, mt) end return ucode Sorry for the code being just plane text, I’m on my mobile and dont know how to insert some co
  17. Ok, I see. With the colors, I would use your custom table, it should be fine, so you don't need to require colors. Sadly I am really busy right now, so I can't have a look at the code for like 2 days. It would be great if you could try to do as many tests and improvements as possible, and then I will have a look at your new results.
  18. I‘m glad that I could help. You‘re welcome! Could you post the error message?
  19. Ok, so the issue with locals you had is the following. When using local, it's important to have the right order of variable/function definitions, let me give an example: local function func_x() print("X") end -- that is some random function local function func_xy() func_x() func_y() end -- a function that will call func_x amd func_y -- this will throw an error, because func_y is defined after it is called by func_xy local function func_y() print("Y") end -- you have to ensure the right order! Ok, so I did some rearrangement of your functions, I hope it works. lo
  20. Can you insert your entire code? Then I could help you find the issue. If you kept the order of your function definitions, you need to change the order a bit, I will talk you through once posted the new code.
  21. So I did some small changes to your AE2Crafting.lua file, it should work now as intended. I wasn't able to test it yet, so tell me if it works or not. -- Original by Palagius : https://oc.cil.li/index.php?/topic/1426-ae2-level-auto-crafting/ -- Modfied by Dalden 2018-07-28 -- - Store crafting result object to check for status -- - If crafting job is not yet finished from previous cycle then skip this cycle local arg = {...} if not arg[1] then arg[1] = "009" else arg[1] = tostring(arg[1]) end if not arg[2] then arg[2] = "ac7" else arg[2] = tostring(arg[2]) end loca
  22. Well, I haven't done something similar yet, so I don't know if there's a way to have a program with and while loop running in the background, I did some quick test with coroutines, but it didn't seem to work. What would work is to use an event driven program, but that would require you to do some rewriting of your code. So what you would do is registering some events with event.listen(event_type, callback) and then having the corresponding callback do your stuff. For periodically stuff like checking your me system for items or whatever, you can register timers that are repeated
  23. Hey, I didn't check the entire code, it's a lot of stuff to go through, but I found the reason for your error. You are calling string.gsub on a number, but it's a string lib, so you have to convert the number to a string first, by calling tostring(number). Your while loop in lines 219-224 would then look like this: while true do formatted, k = string.gsub(tostring(formatted), "^(%d+)(%d%d%d)", '%1,%2') if k == 0 then break end end May I also suggest to use local whenever possible? Like all variables, functions etc. It helps to reduce errors in form of variable override
  24. Yeah, @Molinko‘s code should work, response (in your code it’s „data“) is an iterator suited for „for .. in“ loops. You don‘t actally have to pcall it, calling web.request works also fine.
  25. Oh sorry, my bad, it's supposed to be tostring(str)
×
×
  • Create New...

Important Information

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