• Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Welcome to OpenComputers

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more!

This message will be removed once you have signed in.

  • Announcements

    • Lizzy Trickster

      Latest Stable OpenComputers Version   11/26/16

      The latest released version of OpenComputers is version 1.6.1 for MC 1.7.10, 1.8.9, 1.9.4 & 1.10.2. See more information here! Beta/Dev builds can be found at the Jenkins Build Server (ci.cil.li)
    • Lizzy Trickster

      README: FORUM DOWNTIME!   04/19/17

      These forums will be down from 2017-04-29 @ 1200 GMT for up-to 1 hour (1300 GMT). This is due to the host box needing a reboot to apply Kernel updates. I don't expect the update to take the full hour specified but I have allocated this timeframe in the event that stuff breaks.   Apologies for any inconvenience this causes


  • Content count

  • Joined

  • Last visited

  • Days Won


1 Follower

About Molinko

  • Rank
    Leading Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

227 profile views
  1. What you're looking for is a function. Specifically a 'for' or while loop in a function. Here is a crude one of the former that 'could' be made way better (features n stuff)... local robot = require 'robot' local function forward( times ) times = times or 1 local success, reason, moves = false, nil, 0 for move = 1, times do success, reason = robot.forward() if not success then break end moves = moves + 1 end return success, moves, reason end -- # USAGE -- # Let's say we're moving 3 forward, on a clear path. forward( 3 ) -- # // true, 3, nil (success, moves, reasonForFailure) -- # Now we try another 3 with and obstruction 2 blocks ahead of the robot. forward( 3 ) -- # // false, 1, "path obstructed... or something like this that component.robot.move(side) returns when it fails"
  2. Yes, functions are real... I'm not really sure what you meant by that.. But here's an example anyways.. -- # A named function local function sum( a, b ) return a + b end -- # An 'anonymous' function stored in the named variable 'mul' local mul = function( a, b ) return a * b end local pow -- # forward declaration allows us to reference the caller 'pow' inside of itself. pow = function( a, p ) if not p then -- # return a partial application return function( p2 ) -- # remember the initial number 'a' and take a power of p2 to apply return pow( a, p2 ) end end return a^p end --[[ # local val = pow( 3, 2 ) --> // 9 local f = pow( 3 ) --> // function( p2 ) return 3^p2 end local val2 = f( 2 ) --> // 9 ]]
  3. operating system

    Interesting OS. Small, simple, and to the point. I like it. BTW, what exactly is the point? It seems heavily network oriented as the title suggests... Base Control.. Sounds neat. I'm looking forward to a breakdown of what you intend this to be :)....
  4. I believe I see the problem.. You are sleeping past the responses from the server.. Try this out. It has some comments to try and explain... -- # Setting libraries local component = require("component") local term = require("term") local event = require("event") local modem = component.modem -- # Program code modem.open(111) term.clear() print(">") term.setCursor(2,1) input = io.read() if input == "server.status" then modem.send("address of the server", 123, input) -- # os.sleep(2) // HERE. We sleep beyond the response of the server, thus waiting forever. -- # event.pull is essentially coroutine.yield, which will wait for a loose match of an event id. i.e "modem" will match "modem_message" local _,_,_,_,_,status = event.pull("modem") -- # halt until any modem* event. This, ideally, should be "modem_massege" print("Server status: " .. status) -- we must have seen an event that at least started with the string "modem". else print("Illegal command") end
  5. Please post the formatted server code. Preferably in code tags formatted for lua. I'll take a crack at it.
  6. The port of the sender presumably.
  7. I believe the later version of oc has good support for enderio bundled cable. Also, I believe the delay between setting two colors at once is solved with bundled cable here. Just a thought
  8. Not sure if this will solve the delay between calls, but you can try using rs bundled cable and set the output simultaneously.. rsComponent.setBundledOutput(sides.back, colors.green, colors.red) I don't think you can specify ticks for delay.. Only seconds and a tenth I believe...
  9. Replace getOutput with getInput. getOutput checks if the computer itself is outputting a rs signal.
  10. It would be easier for myself and others to help if you were a bit more descriptive. Is there an error message? If so which file? Things like that.
  11. You could think about loading libraries remotely into memory from a network... As TYKUHN2 said.. With an extra step of requesting a file... require could be switched with a call to load or loadfile. -- # pseudo code.. this might work but isn't tested or even run... function require(module) -- # do some checks n shit.. local file, chunk = nil, "" modem.send(address, port, "get[file] " .. module) while true do local e, la, ra, p, d, ch, status = computer.pullSignal(2) if e == "modem_message" then if status:match("error") then -- # request failed somehow return nil, status elseif st == "chunk" or st == "start" then -- # first and subsequent chunks chunk = chunk .. ch elseif st == "done" then -- # we haz all the chunkz. time to load ze chunkz. file = chunk .. (#ch > 0 and ch or "") break end end end if file then local ret = {pcall(load, file, "=" .. module)} if not ret[1] then return nil, ret[2] end -- # ret[2] here is an error msg ret = {pcall(f)} return ret[1] and ret[2] or nil, ret[2] end return nil, "failed because reasons..." end
  12. Look up the function 'load' and or 'loadstring'. I'd post more but I'm on my phone at work
  13. https://www.lua.org/pil/2.4.html
  14. The backslash is above the the enter/return key(qwerty) below the backspace button..
  15. From what I understand file:seek is only a method available when reading files with io.open. The char you need it backslash n or '\n'. You can use the concatenation operator to join 2 strings into one. Looks like this '..' . I.e. s = 'line 1\n' .. 'line 2\n' .. 'More lines...' file:write(s)