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

dgelessus

Members
  • Content Count

    158
  • Joined

  • Last visited

  • Days Won

    17

Posts posted by dgelessus

  1. When I try this, pasted exactly into a new file, and run.

     

    It Prints 

    Rebinding... nil
    This should appear on the first screen.
    Rebinding... nil
    This should appear on the second screen.
    

    On ONE Screen, and is completey random as to which of the two screens it prints on.

    It turns out that gpu.bind requires a full address and doesn't automatically expand partial addresses. Instead you need to use component.get to expand the address:

    local SCREEN_ONE = component.get("d53")
    local SCREEN_TWO = component.get("c5d")
    

    This will store the full addresses of the two screens in SCREEN_ONE and SCREEN_TWO, which you can now use directly with gpu.bind.

  2. Nice, that reference image will probably come in handy at some point. I like what you did there with the heading sizes/layout, looks really fancy yet so simple. :)

    Would those palette changes actually be useful for anything? Color themes are a nice idea, but that's basically it. Most other things that I was thinking of, e. g. highlighting the currently selected text field in a GUI, would require assigning "objects" to the palette slots, and there could only be 16 of them.

  3. 2) The ratio for a character is of 1:2 afaik. But you can use half-block characters to make actual square pixels.

    ^ this. The exact size of normal characters is 8*16 points, and double-width ones (East Asian glyphs, certain other symbols and control character replacements) are 16*16. The font used by OC computers is the GNU Unifont, see its Wikipedia article for more technical details that you'll probably never need ;)

  4. 2. No. The colors are what they are. The only values that can change are the ones in the palette, and they only will when you explicitly change them yourself.

    Does that mean that palette changes are retrocative? e. g. if you write text in palette color 1 and later reassign that palette slot, will the previously displayed text change color? I never understood that part of the color palette mechanics.

  5. Try checking that the GPU/screen binding actually succeeds. Print some text before rebinding, then print the return value of gpu.bind (once, no need to put it in an infinite loop) and print some text again:

    local component = require("component")

    local gpu = component.gpu

    local SCREEN_ONE = "d53"

    local SCREEN_TWO = "c5d"

    print("Rebinding... " .. tostring(gpu.bind(SCREEN_ONE)))

    print("This should appear on the first screen.")

    print("Rebinding... " .. tostring(gpu.bind(SCREEN_TWO)))

    print("This should appear on the second screen.")

    If that succeeds, continue from there. Also note that there's no need to ever redraw the first screen if its contents shouldn't change. Unless you explicitly clear the screen its contents should stay until you break the screen block.

  6. 1. Unlike with CC, not all APIs are loaded by default. Instead you need to explicitly load them with require:

    local component = require("component")
    local fs = require("filesystem")

    For a full list of all APIs and components, see the wiki at http://ocdoc.cil.li/.

     

    2. Practically none - CC and OC have similar components and APIs, though of course they are used differently. And if you absolutely need to use a CC peripheral that has no OC counterpart, you can use the Adapter block to control it.

     

    3. OC monitors are character-based, so there is no way to directly control pixels as such. Scalable, yes - you can change a monitor's virtual resolution, which effectively changes the scale of all characters. Touch input is possible with tier 2+ screens, either by clicking on the GUI or by shift-clicking on the screen blocks. If there is no keyboard attached to the screen, right-clicking on the block also sends touch events rather than opening the GUI.

     

    4. Craft an internet card - it comes with a built-in wget program to download any file from the internet, and IIRC also a pastebin program. (And the corresponding API of course.) You can also "cheat" by copying text from your browser and pasting it into the editor using middle-click.

  7. This is a short boot/rc script that automatically mounts all new file systems under a mount point named after their label, in addition to the normal name assigned by the OS. Special characters in the label are replaced by an underscore and a conflicting name gets the start of its address appended, so the obvious tricky situations should not cause any problems.

     

    I wouldn't be surprised if someone else had already written this kind of thing or if it was integrated in some of the non-default operating systems, but I couldn't find anything on the forums or OpenPrograms, so here it is.

    (Yes, half of this is copied from OpenOS's automatic mounting code.)

    -- NamedMount, a short boot script that gives labelled file systems named mount
    -- points in /mnt. For example a floppy disk labelled "floppy" would get mounted
    -- at /mnt/floppy in addition to the normal mount point assigned by the OS.
    -- 
    -- All non-alphanumeric characters except the underscore are replaced with
    -- an underscore to ensure that the name is usable in a shell.
    -- If a conflicting mount point already exists, the start of the address is
    -- appended to the label to prevent overwriting other mount points.
    --------------------------------------------------------------------------------
    
    local component = require("component")
    local event = require("event")
    local fs = require("filesystem")
    
    local function doNamedMount(name, address, componentType)
      if componentType == "filesystem" then
        local proxy = component.proxy(address)
        if proxy and proxy:getLabel() then
          local path = fs.concat("/mnt", (proxy:getLabel():gsub("[^%w_]+", "_")))
          if fs.exists(path) then
            -- Mount point exists already, start appending address
            local addrlen = 3
            local path = path .. "-" .. address:sub(1, addrlen)
            while fs.exists(path)
              and addrlen < address:len() -- just to be on the safe side
            do
              path = path .. address:sub(addrlen, addrlen)
            end
          end
          fs.mount(proxy, path)
        end
      end
    end
    
    function start(...)
      event.listen("component_added", doNamedMount)
    end
    
    -- Uncomment when placing this in /boot instead of using rc
    -- start()
    

    Edit: Added start function for use as a rc script.

×
×
  • Create New...

Important Information

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