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

Molinko

Members
  • Content Count

    451
  • Joined

  • Last visited

  • Days Won

    35

Posts posted by Molinko

  1. It seems like you have a test table of `items` and in your original script only the first element of an `item` is a string and the rest are numbers.. However in your test `items` table in the new script your seems to have a typo..

    items = {{"minecraft:coal,1,1,1"}} -- # Everything here is one string..
    
    items = {{"minecraft:coal",1,1,1}} -- # This is what I believe you've overlooked

     

  2. The error you received stems from the second variant of this function. You can call rs.setOutput like so..

    -- # with a number side[0-5] and a signal strength
    rs.setOutput(2, 15)
    
    -- # using the sides api but basically the same thing
    rs.setOutput(sides.east, 15)
    
    -- # or by setting multiple sides at the same time by passing a table
    rs.setOutput({
    	-- # [sides.west] evaluates to a number side
    	[sides.west] = 15,
    	[sides.south] = 10
    })

     

  3. Pretty sure you need to use the HTTP Request Object API that component.internet.request returns. It is a userdata table with methods. I broke my MC launcher so I cant test this but you can try something along these lines..

    Got a chance to test and the below code I have didn't quite work... I've updated it

    local success, response = pcall(web.request, "<your api call>")
    if not success then error("Something sucks here..") end
    
    local content = ""
    for chunk in response.read do -- # changed to response.read
      content = content .. chunk
    end
    
    doStuffWithData(content) -- # yay!?

     

  4. I would expect that you're somehow overwriting the string lib in your context.. I would recommend using a different variable name for your string value other than `string` as this will probably cause your error later when calling string.format on it.. The result of type(string) by default would normally result in "table" because `string` is a global Lua library.

  5. I think some form of navigation library and server would be great. Imagine a robot or drone wants to go somewhere in your base. You could write a server that calculates a path from point 'A' to point 'B' and serves a path string (like the one your library uses) back to the robot/drone. Maybe have the server update knowledge of the base layout with a robot / drone using a geolyzer so it can give clear paths to clients. It's a mouthful but could keep other programs very simple and would be very reusable.

  6. I love that you're posting OC videos on youtube! Definitely not enough content out there to enjoy . I would suggest a perhaps more simple handler for the list of movements though.

    -- # The almighty lookup table
    local actions = {
      f = robot.forward,
      b = robot.back,
      u = robot.up,
      d = robot.down,
      tl = robot.turnLeft,
      tr = robot.turnRight,
      ta = function() -- # turn around 
             local status, reason
             for i = 1, 2 do
               status, reason = robot.turnLeft()
               if not status then break end
             end
             return status, reason
           end,
      s = robot.swing,
      su = robot.swingUp,
      sd = robot.swingDown,
      ...
    }
    
    function move.act(act)
      if not actions[act] then return false, "Undefined act" end
      return actions[act]()
    end

     

  7. I'm not sure exactly but the leading slash may be throwing you off..

    Follow my instructions from your home dir so we can be sure to replicate what I just tested.

    On source computer:

    /home # cp ./main.lua /mnt/38d/test.lua

    /home # ls /mnt/38d  #this is to check we're not crazy and the file has been copied to the floppy

    On robot:

    /home # cp /mnt/38d/test.lua ./main.lua

    /home # ls . #list the current dir to check that we have copied our file successfully

     

    Run man cp to get a better grip on what the cp command can do.

  8. local function findInvs(ic) -- # ic: inventory_controller proxy
      local invs = {}
      
      -- # Loop over all sides for an inventory name.
      for side = 0, 5 do
      	local name = ic.getInventoryName(side)
        -- # If an inventory name is present then store the name/type and the side:number
        if name then table.insert(invs, {name = name, side = side}) end
      end
      
      return invs
    end

    Example:

    local component = require 'component'
    local sides = require 'sides'
    
    local ic = component.inventory_controller
    local inventories = findInvs(ic)
    
    for i, inv in ipairs(inventories) do
      local side, size = sides[inv.side], ic.getInventorySize(inv.side)
      print("inventory at side: '" .. side .. "' has " .. tostring(size) .. " slots")
    end

     

  9. I believe I see where you're trying to go with this but I think there is an easier way. Store the reactor proxies as values in a key/value table and then send method names and args to be executed.

    Here's a simple example..

    -- # Reactor server: Recieves commands from remote client to be run
    local component = require 'component'
    local event = require 'event'
    
    local modem = component.modem
    modem.open(1040)
    
    -- # List of reactors to call methods remotely upon
    local reactors = {
      r1 = component.proxy(component.get '0c60c'),
      r2 = component.proxy(component.get '0ef58'),
      r3 = component.proxy(component.get '255aa')
    }
    
    repeat
      -- # pack it all into a table
      local msg = table.pack(event.pull('modem_message'))
      -- # the droids we're looking for
      local reactor, method = msg[6], msg[7]
      -- # args to call with the remote method (if any)
      local args = #msg > 7 and table.pack(table.unpack(msg, 8)) or {}
      
      -- # if remote reactor id is present then...
      if reactors[reactor] then
        -- # execute the method call with args on a specific reactor. guarded for faulty messages with pcall so we dont crash.
        local result = table.pack(pcall(reactors[reactor][method], table.unpack(args)))
        print(sting.format("called %s on reactor id %s", method, reactor))
        -- # respond to client with result
        modem.send(msg[2], msg[3], table.unpack(result))
      end
      -- # client can send the message 'exit' to quit or hold Ctrl+C on the server
    until msg[6] == 'exit'
    -- # End of server
    -- # client: Send remote commands to be run on server components
    -- # A very simple client... Spruce it up as needed
    local component = require 'component'
    local event = require 'event'
    
    local modem = component.modem
    modem.open(1040)
    
    modem.send(server.address, server.port, 'r1', 'isProcessing') -- # exec 'isProcessing' on 'r1' at server
    print(event.pull('modem_message', modem.address, server.address, server.port)) -- # print and await server response
    
    -- # End of client

     

  10. Im trying to test it right now but Im not too good with Applied energistics... What component of the me network is your OC adapter touching? I have it touching the me_interface but I dont have the component method me_interface.getAvailableItems() just me_interface.getItemsInNetwork(). And the list doesnt appear to show the correct amount of items or any at all really... just an empty list "{n=0}"

    I updated to 1.12.2 and now the me_interface.getItemsInNetwork() method returns a populated list however I still dont have the me_interface.getAvailableItems() method.. Anything I need to know about how your ME network is setup or configured? Remember im an ME noob so help me help you :)

  11. centerT func looks fine.. I'd suspect the checkMe func, specifically the loop over the list, or the list length operator. Check that the list is actually reporting the proper length? Shove a few print calls in there to debug.. I can't test ATM but nothing is standing out as the culprit.

×
×
  • Create New...

Important Information

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