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

mpmxyz

Members
  • Content Count

    56
  • Joined

  • Last visited

  • Days Won

    24

Everything posted by mpmxyz

  1. Content Introduction Reproducing an Error Error Messages Debug Output Appendix List of Error Messages Using a Debugger Ad alert: cbrowse Introduction Writing code is one thing, making it work is a completely different story. More often than not something is not working as intended and sometimes your program just crashes the instant you run it. This can be fun and inspiring but most often it is just frustrating. This guide is meant to introduce you to several useful debugging techniques with the primary focus being Open
  2. I can't help you directly because I don't have OpenSecurity installed and you've already got too much code for me to walk through manually. But here are a few hints: Add debug output! (A lot!) You want to find out the values of important variables throughout your code. Compare the output to what you would expect! You can narrow down the area of the error because it must be somewhere after a correct output and before a wrong output. Move your outputs closer to the error. When you found the error fix it. You can now remove all remaining debug output. In
  3. Update (13.04.17) -added --address option to specify used tape drive
  4. Update 13.04.17: -fixed a bug which was caused by filesystem.list returning file names without sorting in newer OC versions -added crunch to oppm I decided not to add a 'self extracting archive' option because that deserves to be another program. The output of that program could be compressed though. My next target will be full Lua 5.3 support. I have to check memory requirements after that though. (lots of new operators) Update 16.04.17: -Added Lua 5.3 Support (Operators were missing.) Memory requirement didn't increase noticeably. But the parsing table grew by
  5. It's actually a good idea to keep using this part as it allows for easier extension using options: local args, options = shell.parse(...) --"prog arg1 -ab --option --value=2 arg2 arg3" will result in: args = {"arg1", "arg2", "arg3"} options = { a = true, b = true, option = true, value = "2", } But this needs further processing because the received arguments are strings and the functions expect number values corresponding to a light number and a color: local shell = require("shell") local colors = require("colors") local args, options = shell.parse(...) (...) --You can acce
  6. If you have installed an internet card in your computer you can access the "real world" internet. One example on what you could do: wget 'https://raw.githubusercontent.com/mpmxyz/ocprograms/master/home/bin/tar.lua' This will download the file tar.lua. It is a small program I wrote to interact with real world *.tar archives. Note: On some OpenComputers versions you had to install internet related programs separately using an "internet disk".
  7. Disclaimer: I haven't thought through everything; it's just a quick idea. You'd have to hack into the component system and add a "virtual" gpu bound to a "virtual" screen. Both virtual components should be set to be the primary one. It involves a lot of writing code to support the basic functions of gpu and screen. Events have to be modified, too.
  8. Isn't there something like a speed upgrade for MAs in AE2? http://ae-mod.info/Acceleration-Card/ If you want to forward a crafting request to OC you can use an AE2 interface to a buffer robot. You could have one pair for compressing tasks and another pair for uncompressing tasks. I could imagine having two columns of robots. The rear column is distributing the items and the front column is doing the crafting. The two robot columns would be controlled by broadcast wireless signals. The two (or more) input buffers would limit themselves to something like 1000 crafting actions and would give w
  9. Sometimes it is helpful to write a small tool. To give you an example - it requires you to remove the blocks adding components and rebuilding them in the right order: pastebin get LCXQ9JH1 factory_companion.lua factory_companion test.cfg [enter number of different components] [enter a field name for every component type, can be nested (i.e. "inventory", "furnace.right" or even an empty string to add a list to the root table)] [add the stated component to the network; the program listens to "component_added" signals] [press enter to save config file] cat test.cfg It's just a quick and di
  10. Can you show the part of your code that does all that? That might help replicating the error.
  11. Did you use the given command? It works fine for me. What is your error message? (Does your OC computer have an internet card?)
  12. Finally a place to brag with my current project. It still needs some fine tuning but it is almost done. If you read the output carefully you get some hints about the features:
  13. You haven't seen the part about slavery, did you? For me it looks like a parody of real license agreements. PS: Nice UI, but I wished that it was fully translated... I just formatted the disk because I don't understand Russian at all. xD Do you already use a localization library? A well made one should make your live easier.
  14. Your program is nice. Processing the component documentation to make it more readable is a nice idea. I read through your code and noticed one thing: string.find(methodDoc, "[--]") When writing this you probably thought that this matches the two minus signs within a documentation string. But the square brackets indicate a set of possibilities for one character only. "%-%-" matches two minus signs. Since you adjusted the indices in the following string.sub calls there is no noticeable effect on your program. (So if you "correct" that string.find, you have to change the indices again.)
  15. Introduction Are you creating the secret underground base? A pyramid maze with all kinds of traps? Or just your high security door lock? Then it's very likely that you are using redstone. More complex designs require bigger circuits or computers. (redstone computers?) Programming with redstone cards or blocks is quite straightforward, but it can be quite annoying to always repeat yourself: local component = require("component") local sides = require("sides") local colors = require("colors") local rs = component.redstone rs.setBundledOutput(sides.north, colors.blue, true) --close entr
  16. Maybe you can use something like that: local event = require("event") local computer = require("computer") local TEST = tostring(...) local function move(...) print(TEST, ...) --your code end --This function removes the listener when the next program pushes the signal "update_listeners" local function removeListener() event.ignore("modem_message", move) --removes this function return false end --This function adds the listener. local function addListener() event.listen("modem_message", move) --The internal list of listeners is updated after all listeners have been executed.
  17. How many players are in your list "playerData.players"? You are using insertion sort to sort this list. This is quite slow for big lists. (time: n² with n as the size of the list, table.sort() uses a better sorting algorithm, n * log(n) ) But unless you have a very big list of users it probably isn't the reason Another performance hint: You can process the list returned by od.getPlayerList() before you continue using it: local function updatePlayerData(curTime) local isOnlinePlayer = {} --This table is the key for speed improvements. for _, onlinePlayer in ipairs(od.getPlayerList
  18. You can send an URL Categorization Change request: http://www.brightcloud.com/tools/change-request-url-categorization.php?endpoint=oc.cil.li
  19. mpmxyz

    OpenPrograms

    Is it possible to add existing repositories? I'd like to add mine: https://github.com/mpmxyz/ocprograms
  20. I actually wrote a program to make looking at components and libraries easier: http://oc.cil.li/index.php?/topic/576-cbrowse-inspecting-lua-components-and-other-objects/ You can navigate through everything using your mouse or the command line. You can go back via Ctrl+C. If you like to read a component method's documentation just input that: =tostring(method) To install the program you also need another program. (cbrowse is packed in a tar archive; this program creates and extracts them) http://oc.cil.li/index.php?/topic/421-tar-for-opencomputers/ To make it a bit easier for you, he
  21. Update (07.11.15) The API has changed a bit. pid.remove now expects a controller instead of an id. Use pid.removeID for the old behaviour. The command line interface of pid has been changed, too. It now has the strict format of: pid <action> id or file [other stuff] (Note: actions are no longer written with "--" in front of them.) This change has been introduced to allow changing controller properties: pid run /pids/turbine.pid p=10 i=0.4 d=1 f=4 target=900 --args bada4648-3559-4784-b3c7-06c146d9dc3b There also is a new program: gpid It has no options or parameters but ins
  22. You want to do it manually in the shell? /> mkdir myProgram #create a directory /> cd myProgram #move to the newly creaeted directory /myProgram> edit test.lua #edit a file in the directory #Attention: /test.lua would refer to a file at the root directory Was that your error? Or did you try to write lua code? Then it would be good to see what you have to help debugging.
  23. Your example library translation looks fine except for thisTable.1 = ... which should be thisTable[1] = ... You can add a custom location to the package searching path. You just have to modify the variable package.path. (i.e. by appending ";/myProgram/?.lua") But since this is looking more like a simple configuration file using the function dofile is another option. package.path = package.path .. ";/myProgram/?.lua" --This is just a quick and dirty example. You should only append this string once - i.e. when the computer is starting - and not every time you start your program. local ke
  24. Is this function called within an event handling function or do you handle events "manually" in your main loop? os.exit() internally works by throwing an error. Due to that it isn't working within event listeners. (Listener errors are just written to a file and not forwarded to the main code.) If you want it to work correctly you have to have some kind of variable like "keepRunning" that finishes your main loop when changed. By the way: Don't forget to event.ignore before stopping your program!
  25. Interesting idea... To make writing programs for that kind of system easier it would be a good idea to use a special table with an index and a newindex metamethod. They would interact with other computers if necessary. (e.g. when fetching a block of data) Internally they could use a weak table to allow for non permanent caching. (Attention: you would have to wrap non table values in tables to make that work. Tables don't shrink after "loosing" values.) For high memory efficiency you can store your data in e.g. 1 KiB strings. That is quite easy to include in the previously mentioned metamet
×
×
  • Create New...

Important Information

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