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

Gorzoid

Members
  • Content Count

    111
  • Joined

  • Last visited

  • Days Won

    22

Posts posted by Gorzoid

  1. getBundledOutput does not return a table, sadly there is no way to get the entire bundled output in 1 call.

    However that doesn't mean this is impossible, it's actually way easier than you think, you are just using the alternate version of setBundledOutput.
    According to the docs the first version of setBundledOutput takes side, color, value. So you really don't need functions to do this, but if you're still unsure here is the fixed version.

    local component = require("component")
    local rs = component.redstone
    
    function addcol(sid, col)
      rs.setBundledOutput(sid, col, 15)
    end
    
    function remcol(sid, col)
      rs.setBundledOutput(sid, col, 0)
    end

    Also while I was able to understand the attempt in your code, it was both syntactically and logically wrong. You tried to reference your variables by prepending the table which contains the type, and the function arguments were completely wrong. I'd suggest you watch/read a few Lua and OC tutorials, and most importantly read the docs.

  2. My method mimics the general method used in computercraft which would allow easier conversion, many of the oc users used cc before hand or still do so it isn't crazy to believe op might be converting old cc code.

    pcall method does however fit the op's description while also seeming like less of a hackish method. But just saying pcall will fix it may confuse newer users. It's different to the first method as instead of blocking the interrupt, it just catches it and returns early, causing some of the code not to run.

    The method of overriding an os function is not ideal and I'd rather the way to cause the interrupt to be passed as an event instead of an error.

  3. As in locate any player anywhere in the map? You can't, atleast not without a debug card i believe. Motion sensor can detect movement in a small radius and navigation card can get your position relative to a map or waypoint.

  4. Since you have probably done arrays in your C/C++ tables can be explained like this: there are 2 types of tables, numerically indexed table which is like an array (except you start at array[1] rather than array[0]) and there is the hash table which contains 2 values, the key which is used to look up the value, this can be a a number, a string, any type except another table I think. Luckily for you getItemsInNetwork returns this type, so you can just loop from 1 to #essentiatable to get essentiatable. The itemstack values inside the array are hash tables though, you can think of them like structs/classes in C/C++ in this case. They have a specific format and the easiest way to find that format is just by doing what Fingercomp stated above:

    =component.me_controller.getItemsInNetwork()[1]

    I'm pretty sure it has a field named "name" so as an example if you wanted to check if the item is cobblestone then you'd do

    for i = 1,#essentiatable do
      local item = essentiatable[i]
      if item.name == "minecraft:cobblestone" then
        print(serialization.serialize(item)
      end
    end

     

  5. So there's quite a bit wrong with this, for a start the for loop can't be used that way, not in Lua atleast. I'd recomend a while loop which would look something like this.

    while true do
    	local gis = tp.getItemInSlot(sides,east,i) --store item that is being read to recall later
    	if not gis then break end
      	
      	-- Rest of code
      
    end

    With your list, you first need to create a table before you can reference  gp like that. So at the top of your code you would need something like "local gp = {}". Then when adding to it the simplest way is to use

    gp[slot] = gis
    -- or if you want to copy it
    gp[slot] = {}
    gp[slot].label = gis.label
    gp[slot].size  = gis.size

    In above code I also fixed some other issues where you used the calling syntax "(" and ")" instead of indexing syntax "[" and "]". Also "==" is the equality operator, what you meant to have was "=" the assignment operator.

    For the last bit of code the easiest way to do it correctly is using the same indexing you saw in above code (gp[slot].label) and replace slot with #gp

  6. Just so you know, event.pull calls coroutine.yield so really modifying event.pull is unnecessary, just coroutine.resume the task with each signal and event lib will do the rest of the work.

    Not exactly correct, looks like machine.lua also messes with coroutine table in order to correctly sandbox it. Shame, it'd be so simple otherwise.

  7. 1. According to the wiki 

    • Important*: it is generally recommended to use io.open instead of this function, to get a buffered wrapper for the file stream.

    When opening files directly via the file system API you will get a file stream, a table with four functions. These functions are thin wrappers to the file system proxy's callbacks, which also means that read/write operations are not buffered, and can therefore be slow when reading few bytes often. You'll usually want to use io.open instead.

    So yeah use io.

    2. Text files are basically large strings of characters with a special newline character to indicate the text editor to display the rest of the string below the previous. Using the "\n" character you go down to the next line. So if you wanted to write to the 10th line you would need 9 \n's. Files don't work like the screen so you can't just set your cursor anywhere, instead you got to use a combination of spaces and newlines to get to that point. 

  8. So I have very slowly been making a DCPU Architecture for OpenComputers. If you don't know what DCPU is, it's a fake CPU architecture designed by notch for his discontinued game 0x10c. While all work on the game has come to a halt, there is still alot of interest for the CPU spec which he released.

    My idea was to make an emulator that completely follows the spec, including all or most of the devices. This would mean that existing software would work perfectly.

    Development is slow as my motivation disappears and returns very briefly. One of my problems is that I can never keep working on one project for long, my interest change sporadically. But I have mostly finished the CPU itself, I haven't tested all the instructions so it's not bugfree. Currently I am working on the devices, specifically the lem1802 (the screen) and the keyboard. The screen works but currently I can't change the colour pallette or change the font(which I don't think will be possible in oc currently). The keyboard is alot more buggy, keys are sometimes doublepressed, not pressed at all, and sometimes just completely break the buffer.

    It's not on github atm but if people are interested in the code I'll post the source.

  9. 3 hours ago, Lizzy Trickster said:

    We have a system where you need 3 approved posts before you can post freely. It's done this way because of spammers in the past.

    Because of the little activity on this forum, that 3 post system may deter any new users, or force them to basically shitpost on other threads. Maybe instead just make sure they have confirmed their email address? It's not like there is much spam anyway.

×
×
  • Create New...

Important Information

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