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

SpaceBeeGaming

Members
  • Content Count

    65
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by SpaceBeeGaming

  1. So, I have been working on an API which allows me to assign additional addresses to computers. And No I have a moment of confusion:

    function internal.dns.loadHosts()
      local HOST_FILE_LOC = os.getenv("HOST_FILE_LOC")
      print(HOST_FILE_LOC) --Prints /usr/misc/hosts.txt
      assert(HOST_FILE_LOC, "Missing environment variable: HOST_FILE_LOC pointing to a file used for storing dns mamppings ")
      if (filesystem.exists(HOST_FILE_LOC)) then
        local hostFile = io.open(HOST_FILE_LOC)
        print(serialization.unserialize(hostFile:read("*all"))) --prints a table
        local hosts
        hosts = serialization.unserialize(hostFile:read("*all"))
        print(hosts) -- prints nil
        hostFile:close()
        return hosts --Return a table of hosts, if successful
      else
        return nil --Return nil if hostfile doesnt exist
      end
    end

    Why is it that these two seemingly same calls return different values. one is table other is nil?

  2. Okay, now there is another crash:

    [promise 381e6912-539f-5825-cbad-a79499c3c4c9] too long without yielding
    stack traceback:
    	/usr/lib/promise.lua:37: in function 'on_failure'
        /usr/lib/promise.lua:52: in function </usr/lib/promise.lua:50>
        (...tail calls...)
        [C]: in function 'error'
        machine:11: in function <machine:4>
        /usr/lib/matrix.lua:76: in fuction 'get'
        /usr/lib/matrix.lua:127: in fuction 'mult'
        /usr/lib/polynomial_interpolator.lua:14: in function 'QRstep'
        /usr/lib/polynomial_interpolator.lua:56: in function 'interpolate'
        /usr/lib/brgc/reactor_passive.lua:137: in function </usr/lib/brgc/rector_passive.lua:134>
        [C]: in function 'xpcall'
        machine:751: in function 'xpcall'
        /usr/lib/promise.lua:50:in function </usr/lib/promise.lua:49>

     

  3. Steps to get a program to run when you restart the computer:

    1. reboot the computer.

    2. type 

    edit .shrc

    3. Add there the full path of the file, eg

    /home/login.lua

    Ask if you still have problems.

  4. Hi, I found your problem

     

    aufzu.lua:

    API = require("buttonAPI")
    local event = require("event")
    local computer = require("computer")
    local term = require("term")
    local component = require("component")
    local gpu = component.gpu
    
    local rs = component.redstone
    local colors = require("colors")
    local side = require("sides")
    
    function API.fillTable()
      API.setTable("Tor", tor, 10,20,3,5)     --You set then name of button 1 to "Tor"
      API.setTable("Bahn", bahn, 22,32,3,5)   --You set button 2 to "Bahn"
      API.setTable("Raus", test3, 10,20,8,10) --and so on...
      API.setTable("Rein", test4, 22,32,8,10)
      API.screen()
    end
    
    function getClick()
      local _, _, x, y = event.pull(1,touch) --EDIT: No this can be without quotes.
      if x == nil or y == nil then
        local h, w = gpu.getResolution()
        gpu.set(h, w, ".")
        gpu.set(h, w, " ")
      else 
        API.checkxy(x,y)
      end
    end
    
    function tor()
      API.flash("Flash",0.01)  --The problem lies here the API is trying to flash a button named "Flash" 
                               --<< on the original demo this button was named "Flash" FIX: chang thisto "Tor"
      rs.setBundledOutput(sides.back, colors.lime, 200)
      os.sleep(16)
      rs.setBundledOutput(sides.back, colors.lime, 0)
    end
    
    function bahn()
      API.toggleButton("Toggle") --Same as above
      if buttonStatus == true then
      rs.setBundledOutput(sides.back, colors.red, 0)
        else
         rs.setBundledOutput(sides.back, colors.red, 200)
      end
    end
    
    function test3()
      API.flash("Flash") --and same here as well
      term.setCursor(1,25)
      term.write("Free Memory: "..computer.freeMemory().." bytes")
    end
    
    function test4()
      computer.shutdown(true)
    end
    
    term.setCursorBlink(false)
    gpu.setResolution(80, 25)
    API.clear()
    API.fillTable()
    API.heading("Was soll getan werden?")
    
    while true do
      getClick()
    end

     

×
×
  • Create New...

Important Information

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