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

Dustpuppy

Members
  • Content Count

    75
  • Joined

  • Last visited

  • Days Won

    19

Posts posted by Dustpuppy

  1. Have done some work on the gui. Most internal, but also put in a vertical slider, a chart and some other elements.

    Download link is the same as allways.

    Here's an overview of all functions. I will do a proper documentation, if i find the time, but i think my code is good enough to understand it.

     

    Quote

    Version 2.3

     

    ---------------------------------------------------------------------------
    Example:
    ---------------------------------------------------------------------------
    local component = require("component")
    local gpu = component.gpu
    local gui = require("gui")

    local prgName = "Test"
    local version = gui.Version()

    function buttonCallback(guiID, id)
      local result = gui.getYesNo("", "Do you really want to exit?", "")
      if result == true then
        gui.exit()
      end
      gui.displayGui(myGui)
    end

    myGui = gui.newGui(2, 2, 78, 23, true)
    button = gui.newButton(myGui, "center", 21, "exit", buttonCallback)

    gui.clearScreen()
    gui.setTop(prgName .. " " .. version)
    while true do
      gui.runGui(myGui)
    end
    ---------------------------------------------------------------------------

     


    ---------------------------------------------------------------------------
    Functions:
    ---------------------------------------------------------------------------
    gui.checkVersion(major, minor)
    gui.checkHardware(comp, msg)

    gui.clearScreen()
    gui.exit()
    gui.setTop(text)
    gui.setBottom(text)

    gui.runGui(guiID)

    gui.displayGui(myGui)

    gui.closeGui(guiID)

    gui.newGui(x, y, w, h, frame, text, bg, fg)
    gui.newCheckbox(guiID, x, y, status)
    gui.newRadio(guiID, x, y)
    gui.newLabel(guiID, x, y, text, bg, fg)
    gui.newMultiLineLabel(guiID, x, y, w, h, text, bg, fg)
    gui.newButton(guiID, x, y, text, func)
    gui.newText(guiID, x, y, lenght, text, func, fieldLenght, hide)
    gui.newProgress(guiID, x, y, lenght, maxValue, value, func, number)
    gui.newVProgress(guiID, x, y, lenght, width, maxValue, value, func, direction)
    gui.newVSlider(guiID, x, y, lenght, min, max, value, func)
    gui.newList(guiID, x, y, width, height, tab, func, text)
    gui.newFrame(guiID, x, y, width, height, text)
    gui.newHLine(guiID, x, y, width)
    gui.newChart(guiID, x, y, minValue, maxValue, data, lenght, height, bg, fg)

    gui.getSelected(guiID, listID)
    gui.setSelected(guiID, listID, selection)
    gui.setMax(guiID, widgetID, maxValue)
    gui.setChartData(guiID, chartID, data)
    gui.setValue(guiID, widgetID, value)
    gui.resetProgress(guiID, progressID)
    gui.setText(guiID, widgetID, text)
    gui.getText(guiID, widgetID)
    gui.getCheckboxStatus(guiID, widgetID)
    gui.setEnable(guiID, widgetID, state)
    gui.setVisible(guiID, widgetID, state)
    gui.setBackground(guiID, widgetID, color)
    gui.setForeground(guiID, widgetID, color)
    gui.clearList(guiID, listID)
    gui.insertList(guiID, listID, value)
    gui.getRadio(guiID)
    gui.setRadio(guiID, radioID)

    gui.showError(msg1, msg2, msg3)
    gui.showMsg(msg1, msg2, msg3)
    gui.getYesNo(msg1, msg2, msg3)

    gui.crypt(str, k, inv)
    gui.string2key(str)

    gui.saveTable(tbl,filename )
    gui.loadTable( sfile )

    gui.splitString(str, sep)
    gui.sepString(str)

     

     

  2. How do i access the player or the world object?

    If i do :

    local component = require("component")
    
    print(component.debug.getPlayer("Dusty"))
    

    all i get is li.cil.oc.server.component.DebugCard$WorldValue@329065a

    No Idea how to work with the debug card in the right way to get players coordinates.

     

  3. Hi,

    does anyone know, how i can locate a player?

    The problem (or challange) is, that the position of everything will change it self. It's for a Advance Rocketry warp ship and the absolute coordinates in the world (space) will change, as soon as the ship moves. That means, that really everything on the ship will change it's position. Also every scanner, sensor and the computers.

    Working with absolute coordinates is not possible.

     

  4. Here's the code of the screenshot.

    local component = require("component")
    local gpu = component.gpu
    local gui = require("gui")
    
    local prgName = "Gui-lib v"
    local version = gui.Version()
    
    function exitButtonCallback(guiID, id)
      local result = gui.getYesNo("", "Do you really want to exit?", "")
      if result == true then
        gui.exit()
      end
      gui.displayGui(myGui)
    end
    
    myGui = gui.newGui(2, 2, 78, 23, true)
    exitbutton = gui.newButton(myGui, "center", 21, "exit", exitButtonCallback)
    
    label1 = gui.newLabel(myGui, 2, 1, "A label")
    label2 = gui.newLabel(myGui, 2, 3, "A colored label", 0xFF0000, 0xFFFF00)
    
    frame = gui.newFrame(myGui, 2, 5, 40, 6, "A frame")
    
    checkbox1 = gui.newCheckbox(myGui, 3, 7, false)
    cbLabel1 = gui.newLabel(myGui, 7, 7, "Checkbox")
    
    checkbox2 = gui.newCheckbox(myGui, 3, 8, true)
    cbLabel2 = gui.newLabel(myGui, 7, 8, "Second checkbox")
    
    text = gui.newText(myGui, 2, 12, 25, "Text input")
    
    progress = gui.newProgress(myGui, 2, 16, 35, 100, 0, nil, true)
    
    list = gui.newList(myGui, 50, 3, 25, 10, {"Entry 1", "Entry two", "Number 3", "44444"}, nil, "A List")
    
    vprogress1 = gui.newVProgress(myGui, 44, 3, 10, 100, 0, nil)
    vprogress2 = gui.newVProgress(myGui, 46, 3, 10, 100, 0, nil, 1)
    
    radioframe = gui.newFrame(myGui, 48, 14, 25, 6)
    
    radio1 = gui.newRadio(myGui, 50, 15)
    radio2 = gui.newRadio(myGui, 50, 16)
    radio3 = gui.newRadio(myGui, 50, 17)
    radio4 = gui.newRadio(myGui, 50, 18)
    
    radioLabel1 = gui.newLabel(myGui, 54, 15, "Radio button 1")
    radioLabel2 = gui.newLabel(myGui, 54, 16, "Radio button 2")
    radioLabel3 = gui.newLabel(myGui, 54, 17, "Radio button 3")
    radioLabel4 = gui.newLabel(myGui, 54, 18, "Radio button 4")
    
    hline = gui.newHLine(myGui, 5, 20, 40)
    
    gui.clearScreen()
    gui.setTop(prgName .. version)
    
    local counter = 0
    while true do
      gui.runGui(myGui)
      counter = counter + 1
      if counter <= 100 then
        gui.setValue(myGui, progress, counter)
        gui.setValue(myGui, vprogress1, counter)
        gui.setValue(myGui, vprogress2, counter)
      end
      if counter > 110 then
        counter = 0
      end
    end
    
    
    
    
  5. Was not as complicated as i thought.
    TheCryptek, here is your request :-)

     

    Just replace the mag card reader with a rfid reader and use this script.

    local accessLevel = 2
    local cryptKey = {1, 2, 3, 4, 5}
    local modemPort = 199
    local scanRange = 4
    
    
    
    local component = require("component")
    local gpu = component.gpu
    local event = require("event")
    local ser = require("serialization")
    local term = require("term")
    
    local door = component.os_door
    local rfidreader = component.os_rfidreader
    
    local modem = component.modem 
    
    
    local function convert( chars, dist, inv )
      return string.char( ( string.byte( chars ) - 32 + ( inv and -dist or dist ) ) % 95 + 32 )
    end
    
    local function crypt(str,k,inv)
      local enc= "";
      for i=1,#str do
        if(#str-k[5] >= i or not inv)then
          for inc=0,3 do
    	if(i%4 == inc)then
    	  enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
    	  break;
    	end
          end
        end
      end
      if(not inv)then
        for i=1,k[5] do
          enc = enc .. string.char(math.random(32,126));
        end
      end
      return enc;
    end
    
    
    function splitString(str, sep)
            local sep, fields = sep or ":", {}
            local pattern = string.format("([^%s]+)", sep)
            str:gsub(pattern, function(c) fields[#fields+1] = c end)
            return fields
    end
    
    term.clear()
    print("Security door   Access level : " .. tostring(accessLevel))
    print("---------------------------------------------------------------------------")
    
    if modem.isOpen(modemPort) == false then
      modem.open(modemPort)
    end
    data = crypt(tostring(accessLevel), cryptKey)
    modem.broadcast(modemPort, "setlevel", data)
    
    while true do
      output = rfidreader.scan(scanRange)
      if output[1] ~= nil then
        local data = crypt(output[1].data, cryptKey, true)
          local tmpTable = splitString(data," ")
          term.write(tmpTable[3] .. ":")
          if modem.isOpen(modemPort) == false then
    	modem.open(modemPort)
          end
          data = crypt(tmpTable[3], cryptKey)
          modem.broadcast(modemPort, "checkuser", data)
          local e, _, from, port, _, msg = event.pull(1, "modem_message")
          if e then
    	data = crypt(msg, cryptKey, true)
      --    print(data)
    	if data == "true" then
    	  term.write("Access granted\n")
    	  door.toggle()
    	  os.sleep(2)
    	  door.toggle()
    	else
    	  term.write("Access denied\n")
    	end
          else
    	term.write("server timeout\n")
          end
          os.sleep(3)
      else
        os.sleep(0.5)
      end
    end
    
    
  6. Okay, after screwing around with your program, I thought of something. What if there was a log that was kept on the "Door" system, but unlike the output that is shown, it's a file that can be sent over the port other computers so that you (or whoever is Head Chief of Security) can read it on their own time.There should actually be two files in my opinion. One that is all successful attempts and one that is all failed. Both should be the same of course, showing the name of the player, the name of the card, the "password" on the card, and finally if it was locked when written or not.

    I made a little program thinking about it: http://pastebin.com/4pqh0L7J

     

    The problem is the fact that the data is everywhere. If you could figure out a way to fix it and incorporate it, I would be thankful.

     

    I am not sure, what you mean. You can see at the server screen all infos. If access is granted, or denied and why.

     

    Would you be willing to get this working with the RFID Chip and readers, I want the doors to automatically open when say a level 10 access person walks up to a level 10 access door :P

    I will have a look, when i find the time.

×
×
  • Create New...

Important Information

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