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


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by feldim2425

  1. Oh that can also happen, if somewhere the error, generated from os.sleep() or event.pull(), gets catched. In this case the program won't stop, at least not with the first try. Timers and Coroutines / Threads might also survive the Interrupt. To handle that you should check for the "interrupted" event (Fired by pressing Ctrl+C) and stop everything correctly.
  2. Programs usually won't just switch to background. You can try to kill it with CTRL+ALT+C .... this should throw an error and kill the program If you say that it keeps running in the background, how did you find that out? Just asking because it might be some other issue.
  3. I don't think this is possible and I also don't know why you want to pause the computer for that. I think its better if you enforce the limit by returning false or throw an error. But by pausing the computer it will not be able to handle other events like network or touch events. So this would not make much sense.
  4. 1. Require looks if the library has been loaded before and if so it just returns the cached version, otherwise it searches in some predefined paths (usually the current directory, /lib and /usr/lib) for the library, reads the content of the file and uses the load() function to parse and execute the lua code, it caches the returned value from the executed lua / library file (so it is faster if the library is required again) and returns it. You can find the OpenOS implementation in /lib/package.lua 2. You don't have to make any library for a custom filesystem. In theory you can do everything with the filesystem component. But many systems implement a object oriented filesystem api and also a way to mount other filesystem component (like /mnt in OpenOS). Again you can look at OpenOS implementation in /lib/filesystem.lua and /boot/90_filesystem.lua. If you want a custom directory structure you can also do that. OpenOS uses a unix like structure but you can also make your own. If you use Lua BIOS the only requirement is a init.lua in the root directory, but you can also change that by writing a custom BIOS, if you want. EDIT: You might want to add basic programs to list, copy, rename, delete and edit files and directories and also to go to another directory (like "cd").
  5. Some people told me they didn't get a confirmation mail. I tried to reset my passwort to test if the email system of the form is dead and the reset email also never got it into my mailbox. The spam folder is empty so I think oc.cil.li can't send emails.
  6. Hello. So you know how to make a program in ComputerCraft and you want to switch to OpenComputers or just want to know OC better, this tutorial shows you how to use OpenComputers. 0. Some concepts you have to know You can think of Components like Peripherals in CC. They are basically the same require is a function in Lua that returns a module. It can be compared to ComputerCrafts os.loadAPI. But require doen't load an API global like loadAPI, instead it returns the API and it doesn't return the _G table that the api defines. It returns what the loaded File returns like a function. More examples to that later in that Tutorial A computer from OC has no OS and no BIOS. So a computer can't start or load something without an Lua EEPROM and a typical OS, with a fancy Text terminal and some programs, is also not available without installing OpenOS first. That makes setting up a OC Computer a bit more complicated but it allows you to make a real OS for your Computer and not just a fancy UI or a Overlay to the predefined Operating System. An Address is used instead of the peripheral name and the ID in ComputerCraft. So your computer won't get the name "computer_0" or the id 0. The Address is a random UUID string and not a number that increments for every computer. So a Address looks more like "cd6c4e39-bbb6-491c-826d-48112912f44d". That can be a problem to remember, but components are usually uniquely identifiable by the first 3 characters of the UUID and later we will learn some other tricks to copy them. You can't shutdown a Computer with Ctrl+S or restart it with Ctrl+R. You have to type "reboot" or "shutdown" in the console or press the green button in the UI for the Computer Case. To interrupt a program in OpenComputers you press Ctrl+C or to forcefully kill it you can press Ctrl+Alt+C. In ComputerCraft you would press Ctrl+T and there is no way to forcefully kill a program in ComputerCraft other than restarting the computer. A Computer doesn't restart when you leave the world or the chunk unloads. Instead they keep the memory and the program running on it won't notice that the computer stopped for a moment. Some features are only available with cards. Like the Internet Card for HTTP and TCP (also Pastebin and Wget), Redstone Card for sending and receiving Redstone signals or a graphics card for connecting to a screen. Memory is limited and the amount you can use is determined by the Memory Items you put into the Case Your computer will use Power (If you didn't disable it in the config). Cases can convert RF and other electricity types into OC's own power system. There is also a Adapter that can convert power faster. Creative Cases generate their own power. 1. How to build a Computer If you play with ComputerCraft you just place one block and done. In OpenComputers however you need more. What you have to craft: ComputerCase .... Better Tier means that you can have more components and also components with better tier. CPU or APU ... The Tier of the CPU determines the amount of components that can be connected to your computer. The APU has the same features like a CPU but it can replace the Graphics Cards. OpenComputers allows you to have different Languages by default Lua 5.3 is selected. You can change that by shift+rightclicking the CPU or APU in your hand. Memory ... The memory determines the amount of RAM your program can use. Graphics Card (if you didn't craft a APU) .... This will determine the resolution and the color your screen can have. A Tier 1 Card can only display black and white (like a basic CC Computer) a Tier 2 can display colors (like an advanced Computer) and Tier 3 can display more colors. Screen ... The screen determines the resolution and color like a graphics card. The setup will only be as good as the weakest part. So if you have a Tier 1 Card and a Tier 2 screen you can't display colors and the resolution will only match a Tier 1 setup. So both GPU and Screen should have the same Tier. A Tier 2 or 3 Screen can also handle touch events like an Advanced Computer from ComputerCraft. Keyboard ... The keyboard doesn't really do anything other than enabling the GUI of the screen to type something. Without a keyboard you can only look at the screen and use it as a touchpad (if you have Tier 2 Screen or higher). Disk Drive ... A disk drive is similar to the disk drive in ComputerCraft. A tier 3 cases and a creative cases have a builtin Disk Drive, so you don't need one if you selected one of these cases. OpenOS Floppy ... This item contains the OpenOS ready for installation. This floppy won't get consumed so you only need one and as long as you don't lose it you never have to craft a new one. Hard Disk Drive ... This allows you to store data. The tier determines the amount of storage you have. (Lua BIOS) EEPROM ... This is the BIOS that loads our OS. It is required for the startup of our computer. If you have crafted one, you can copy the EEPROM by combining the Lua BIOS EEPROM in a crafting Table with an empty one. The setup: As you can see on the first image, the power cable can be connected directly to the case (no need for the adapter in this setup). The keyboard has to be a neighbor of the screen, but it doesn't have the be placed on the screen. So if you want to build a fancy table in from of the screen with the keyboard on top of it, you can do that. The Disk Drive and the screen is placed directly next to the case, you can also place the case somewere else and connect the screen and the drive via a cable, like in ComputerCraft. (except you don't need modems) In the second picture you see, how you have to put the components into the UI of the case. The tier of the component has to be the same or lower than the number shown in the slot. OpenComputers helps you by highlighting possible slots and items in your inventory and also in JEI if you have it installed, you just have to hover over the item to see possible slots or hover over the slot to see possible items. In the second picture you can also see, that items get an address. That would be the address of the component if the items acts as a component. Like a redstone card would give you the redstone component. If you have TOP (The One Probe) or WAILA installed the address of a component is also visible in there. You can see them on Cases, Screens, Redstone IO blocks, ... . If you don't have WAILA or TOP installed you can use an analyser from OpenComputers to get the address. If you hold Ctrl while rightclicking a block with the analyer you can copy the address of that component block. 2. Install OpenOS As I already mentioned, the OS is not preinstalled when you build the Computer. You can write your own OS, but that's not what we want to do here. So now its time to put the OpenOS disk into the Disk Drive. You can open the GUI and put it in the slot or you can shift rightclick the disk drive (doens't work on the integrated disk drive in Tier 3 cases). The disk drive block will show you the inserted disk. If you now start the computer by pressing the green button inside the gui or shift rightclicking the case with an empty hand, the light of the computercase will light up with a green color, and you should hear some floppy noise. You should see something like this if you open the UI of the screen. Sadly we are not done yet. If your try to type in " edit test.lua " you will see the error message "file system is read only", that's because the OpenOS disk doesn't store anything on your computer it is a fixed storage, if you craft an empty floppy you would be able to store files on it. But in our case we already installed a Hard Disk Drive we just have to boot from it. To do that we have to copy OpenOS onto it. To do that you simply type " install ". The program asks you if you want to install OpenOS. Now you have to type " y " and enter to start the process. This will take some time. After it is done the program will ask you if you want to reboot. So you can type "y" again. There shouldn't be much floppy sound and more sound from the hard drive. You can now take the floppy disk out and try " edit test.lua " again. It should now open the text editor. In the text editor you can press Ctrl + S to save and Ctrl + W to exit. 3. Troubleshooting So chapter 2. didn't work and your computer won't turn on. If the green light is on but you don't see anything on your screen. It's likely that the screen is not connected or you forgot the graphics card. If there is only a red blinking light you should see a error message in your chat, if that's not the case build an analyser and shift + rightclick the case. You should see the "Last Error". These error messages should tell you what went wrong. Somtimes you also get a blue screen with an error message. If you see the message "Too many components connected" it can means 2 things. One is that you exceeded the maximum amount of components that are allowed for your CPU Tier or you forgot the CPU. 4. Programming This is not a full Lua tutorial I will show you some basic programs and show you the difference to ComputerCraft. First we have to create the file. Simply type "edit test.lua" to open the editor and yes all lua Programms should end with ".lua". Since I want to work with redstone, I put a tier 1 redstone card in the second slot of my case. Since it is the only redstone component it is also the primary component. The primary component should be the first connected component of a type. In this example the redstone card is a "redstone" component. You will see why this is important in a second. --First thing we have to do is to load the component library. --Some libraries are loaded by default but "component" we have to load manualy --Thats the biggest difference from ComputerCraft, that APIs are not loaded from the beginning. local component = require("component") --OpenComputers defines sides as numbers and not as a string like ComputerCraft --But we don`t want to learn every number for every side so we can load a library that does that for us. local sides = require("sides") --Now we see what primary component means. OpenOS defines the primary component as a variable with the name of the type in component. --So we can access component.redstone and will get the redstone card. Later I will show you how to connect to multiple components of --the same type. local redstone = component.redstone while true do --Set the redstone output to 15 (maximum strength). The first argument defines the side. We use the sides api here to help us out --You can also put 3 instead of sides.front but as I sayed we don`t have to remember every number redstone.setOutput(sides.front, 15) --"os" is a library thats loaded by default. We use the sleep function to sleep for 500 milliseconds os.sleep(0.5) redstone.setOutput(sides.front, 0) os.sleep(0.5) end (Sorry it seems like the coloring is a bit off) INFO: You can paste ingame by pressing your mouseweel in the UI of the OpenComputers screen. This program has no exit condition so the only way to stop it is with Ctrl+Alt+C (or reboot the computer). So how can you load multiple components with the same type? We first have to get the Address. You can copy the address into the clipboard by holding Ctrl while clicking with the analyser on a component block. As I mentioned in most cases the first 3 characters in the address should be enough. Lets do the same thing with with a redstone component. --First thing we have to do is to load the component library. --Some libraries are loaded by default but "component" we have to load manualy --Thats the biggest difference from ComputerCraft, that APIs are not loaded from the beginning. local component = require("component") --OpenComputers defines sides as numbers and not as a string like ComputerCraft --But we don`t want to learn every number for every side so we can load a library that does that for us. local sides = require("sides") --This line now contains 2 functions. The proxy function is the same as peripheral.wrap in ComputerCraft but it needs an address and it doesn't work with --sides. To get the full address out of the 3 Characters we have to search for it. The component api has a builtin function called "get" for this purpose. --If you copy the full address with an analyser you can get rid of the component.get call and give the address directly to to proxy function --You should replace "a37" with the address of your redstone card or redstone IO Block local redstone = component.proxy(component.get("a37")) while true do --Set the redstone output to 15 (maximum strength). The first argument defines the side. We use the sides api here to help us out --You can also put 3 instead of sides.front but as I sayed we don`t have to remember every number redstone.setOutput(sides.front, 15) --"os" is a library thats loaded by default. We use the sleep function to sleep for 500 milliseconds os.sleep(0.5) redstone.setOutput(sides.front, 0) os.sleep(0.5) end You can find more information about the apis here: https://ocdoc.cil.li/api In the section "Standard libraries" you can find the libraries that are loaded by default and you don't have to require them In the section "Custom libraries" you can find the libraries that are offered by OpenOS and you have to call "require" in order to load them More information about the components can be found here: https://ocdoc.cil.li/component Many APIs that are built into ComputerCraft are moved to components in OpenComputers like "HTTP", "Redstone", "Rednet", "Disk", "Fs" (partially), "Turtle" (Robot in OC). Fs and Disk are mostly moved to the "filesystem" component, which allows you to get the empty space, rename the disk and basic File access. The "filesystem" api is a more abstract, which allows you to work with file "objects" and it has some more features. HTTP is the internet component in OpenComputers and it is provided by the internet card. The internet component also allows you to make raw TCP requests. The Rednet API in ComputerCraft is basically another way to access the modem peripheral in CC so you can find it in the modem component from OC, which is available if you add a network card or a wireless network card to your setup. Events work similar to the events from ComputerCraft but they have their own Api in OpenComputers called "event". You can find a list of signals (other name for event) here: https://ocdoc.cil.li/component:signals So lets make a example for a touch event: local event = require("event") while true do --This will wait an infinite amount of time for any event local ev, arg1, arg2, arg3, arg4, arg5 = event.pull() --"interrupted" event is fired when you press Ctrl+C if ev == "interrupted" then return --The "touch" event is fired by the screen and gives us: The Screen Address (1), X & Y - Coordinate (2 & 3), The Mouse Button (4) and the Player (5) elseif ev == "touch" then print("Player " .. arg5 .. " touched screen " .. arg1 .. " at X="..arg2.." Y="..arg3) end end You can also filter for one event / signal or give the "pull" function a timeout. If you want to filter for multiple events you can use event.pullMultiple(). More information here: https://ocdoc.cil.li/api:event If you want to handle Ctrl+Alt+C in your program you have to handle errors thrown by event.pull(). You can do that with pcall() but I won't go into details here (this is a normal lua function, so you can search it online). If you want to handle an unknown amount of return arguments from any lua function you can also do " local ev = { event.pull() } " this will create a array with all the arguments and you can access them with ev[1], ev[2], .... 5. Filesystem OpenComputers OpenOS has a more complex filesystem than the OS from ComputerCraft and it resembles the UNIX filesystem. If you bootup your computer you will start in /home. This is where you should write your own programs and store data. /bin ... Programs installed by OpenOS /lib ... Libraries installed by OpenOS ( This is one of the paths where "require" searches for libraries /usr/bin ... Programms installed by the user. Usually via a package manager like OPPM /usr/lib ... Libraries installed by the user. Usually via a package manager like OPPM /usr/man ... Manual pages for programms. You can type " man <command> " to open them /usr/misc ... Some miscellaneous data for some programms /etc ... Configs for programs. /boot ... Scripts that run during bootup /mnt ... This is where you can access other storage devices like floppy disks. OpenOS will create a directory inside mnt with the first letters taken from the address of the disk /tmp ... Temporary storage. Cleaded after a reboot. /init.lua ... File that gets executed by the BIOS /autorun.lua ... This File doesn't exist after a fresh installation. But you can create it to execute a program after startup. (Like the "startup" file in ComputerCraft) INFO: Not all of these directories exist after you install OpenOS. Some of them are created when they are needed by some program. I hope this tutorial helps you to learn how to use OpenComptuers. Maybe I will make a second part about the differences between a CC Turtle and a OC Robot.
  7. The error was a Nullpointer Exception in mods.ocminecart.common.inventory.ComponentInventory in the method getComponentSlot().
  8. I'm rewriting OC-Minecarts for 1.10.2. But the Carts won't boot. If I insert no BIOS it works as intended and tells me, that I have to insert a BIOS EEPROM, same if I insert a BIOS but no OpenOS, but if I insert a OpenOS disk and power the computer cart up. The Startup routine crashes with "Unrecoverable Error java.lang.NullPointerException" I don't know where this is coming from. The log doesn't tell me anything, even if I enable "logCallbackErrors" (and also some other options in debug category). Debugging with breakpoints also didn't help. Forcing LuaJ it printed "machine:1447: machine:631: java.lang.NullPointerException stacktrace traceback: [Java] in ?" OpenComputers: Source: https://github.com/feldim2425/OC-Minecarts/tree/master-1.10 EDIT: Didn't open a github issue because i'm pretty sure I did something wrong. EDIT2: After some testing I figured out, that a method in the /lib/core/boot.lua or below the loading of boot.lua in the init.lua file leads to that error. Didn't figured out what method or where.
  9. A very simple webbrowser might be possible but one that supports videos, chrome plugins, javascript and styles not. Remember: OpenComputers can't draw pixel per pixel, only characters. And supporting videos would mean that you have to implement flash and html5. Even if it is possible it might take month or years to implement all that and i think the limited memory of oc wouldn't allow that.
  10. First. You can use an analyzer to see the error message Second. if you open the gui of the rack (not of the server itself) you can connect the component network to one of the 5 sides (front not counted). You have to make sure the Screen is connected to the corresponding side. EDIT: You can open the Rack gui if you click anywhere except the places on the from where you can see a server. In my case the first slot / row
  11. If you read the Item Tooltip of the network debugger, it says that it debuggs the internal network of OC. And is made for Devs. The Network debugger is not even craftable and will only output messages to the log. EDIT: I think this is the wrong Forum section for this. This thread should be in "Support" and not in "Tutorials"
  12. Hi. If you use a Server make sure that you configured the rack correctly. As you see in the screenshot below a server with a network card has two connections. One for the Component network and one for the Network Card itself, while a server without network card only has one connection. Also make sure that the cable is connected to the correct side.
  13. A simpe API to connect to a Websocket Server / Endpoint Forgot to mention: This API requires a Internet Card and Lua 5.3 Example Code: local ws = require("websocket_client"); local event = require("event"); local cl = ws.create(function(ev ,var1) print(ev .. "->" .. var1) end); cl:connect("localhost", 12345, "/"); while true do local ev = {event.pull()}; if ev[1] == "interrupted" then cl:disconnect(); return; elseif ev[1] == "touch" then cl:send("HI"); end end Full API documentation here: https://github.com/feldim2425/OC-Programs/blob/master/websocket_client/API.md To download and install the API simply run this command: pastebin run xnXssAtH
  14. Yeah. The "require" method is part of OpenOS. But there are some ways around that. 1) I think the component-Library is native (At least for eeproms in a computer case) so you don't have to require it. 2) component.filesystem is a link to the first filesystem found by OpenOS when it starts. So you can find it yourself local fs = component.list("filesystem", true)(); 3) Instead of using the filesystem-Library you should use the filesystem-Component (link to the docs)
  15. You can't download directories. I checked the Pastebin API and it doesn't look like they added directories to the API. And 'wget' uses the same download as your browser does and this method doesn't support downloading folders.
  16. Yes. If you look in the Wiki about signals (ocdoc.cil.li/component:signals) you can see, that the "key_down" event and the "touch" event gives you the playername.
  17. You return null in createEnvironment() but you have the return a ManagedEnvironment. The ManagedEnvironment also needs a Network Node with a component. public class TeslaUpgrade extends li.cil.oc.api.prefab.ManagedEnvironment{ public TeslaUpgrade(){ this.setNode( Network.newNode(this, Visibility.Neighbors).withComponent("teslaUpgrade").create() ); } } I do not know if you have seen the example on GitHub If the upgrade is only for robots you should check in worksWith() if the host class is li.cil.oc.common.tileentity.Robot because there are also upgrade slots in drones, microcontrollers and in the adapter block
  18. You have to get the inventory controller component not the component of the Jabba barrel. local component = require("component") local inv = component.inventory_controller local stack = inv.getInventorySize(sides.west) print(stack)
  19. Hello everybody! This is the official forum thread for OC-Minecarts. This addon mod adds computer carts and more to OpenComputers. Some features in this mod: Computer carts with an build-in engine and a break. Remote module for railcraft locomotives Network rail to send network messages and power to a computer cart. Interaction with Railcraft: Computer carts can take energy from electric rails. Carts are linkable. Signal for cart lockdown (holding tracks). Linking Upgrade for Computer Carts You can put railcraft emblems on Computer Carts Screenshot: Download and more informations on Curse. Please report any issues. Github
  20. I think Plan9k is Multiscreen compatible. If you want to use OpenOS remove the lines 31 to 36 in init.lua and replace them with: local screen = "<SCREEN ADDRESS HERE>"
  21. local fs = require("filesystem") function os.dateRL(format) if not fs.get("/").isReadOnly() then local time = io.open("/tmp/.time", "w") time:write() time:close() os.sleep(0.01) return os.date(format, fs.lastModified("/tmp/.time") / 1002.7) else return os.date(format) end end It works. Just require filesystem and "only" in isReadOnly starts with an uppercase letter
  22. You have to import/require the event library. local event = require("event") function touchsig(_, x, y, _, _) print("Xcord: " .. x .. "Ycord: " .. y) end while true do event.listen("touch", touchsig) end
  23. feldim2425

    big reactor

    local component = require("component") local reactor = component.br_reactor local rods = reactor.getNumberOfControlRods() local level ={} for i=0,rods-1 do level = reactor.getControlRodLevel(i) end
  24. feldim2425

    Pressure-plate door

    local component = require("component") local sd = require("sides") local rs = component.redstone local event = require("event") local oldSignal = false local state = false while true do local signal = rs.getInput(sd.front) > 0 --check if we have a redstone signal if signal ~= oldSignal then --make sure we don't trigger twice when the plate was stepped on once ' oldSignal = signal if signal then state = not state --make it so we toggle if signal is true if state then print("Opening door") rs.setOutput(sd.right, 15) else print("Closing door") rs.setOutput(sd.right, 0) end end end event.pull("redstone_changed",rs.address,sd.front) --sleep until redstone input on our device's front changes ' end You need to check if the redstone input is true when you toggle the output. EDIT: Added ' local event = require("event") '.
  25. feldim2425

    Pressure-plate door

    You need a loop. Otherwise the program will return before you step on the plate. ` require("component.redstone") ` is wrong. "component" is the library with a variable called redstone. You have to write ` require("component").redstone ` local component = require("component") local sd = require("sides") local rs = require("component").redstone while true do if rs.getInput(sd.front) == 15 then print("Opening door") rs.setOutput(sd.right, 15) else print("Closing door") rs.setOutput(sd.right, 0) end end You can stop the programm with: Ctl + Alt + C (terminate)
  • Create New...

Important Information

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