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

Search the Community

Showing results for tags 'openglasses'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OpenComputers
    • Announcements
    • Feedback
    • IRC
  • Code Central
    • Support
    • Showcase
    • Tutorials
  • Addons & More
    • Addons Mods
    • Architectures
    • OpenEngineering Task Force
  • General
    • Lounge
    • Forum Games
    • Showcase
    • Servers
  • Archives
    • Public Archives

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Minecraft


GitHub


IRC


Fediverse ID


Location


Interests

Found 7 results

  1. Hello everyone! Direwo... eh, not quite right. Well, OpenGlasses for 1.12 is out! And I noticed there were no public button API for it, so I made one myself! I have a few functions built-in to make it easier to change stuff, but it was created with simplicity in mind. So if you simply just initialize a button and bind a function to it, it won't do any fancy stuff except for activating the function when you press it, so you have to add your own functionality to it: But with a little bit of extra code: Ok, not that big a difference, you guys are probably more creative than me! I also have a concept called "groups". When creating a button, you can specify what group it should be in. So if you want to change the color of all the buttons to the left side to pink, you can do that. Functions (in no particular order): --Needs to be called before creating any buttons, works as a reset also: gButtonAPI4.initialize() --Creating a new button element: gButtonAPI4.createNewButton(name,group,display,x,y,w,h,color: table,transparently,callback: function) --Has to be inside of your main loop: gButtonAPI4.update() --Prints all registered groups: gButtonAPI4.printGroups() --Change the visibility of the button/group: gButtonAPI4.visibility(button/group,boolean) --Change the color of the button/group: gButtonAPI4.Color(button/group[,color: table])--None for default color. --Same as color, but changes the label: gButtonAPI4.Label(button/group[,text])--None for default label. --Add a button to a group: gButtons.addToGroup(button,group) If you don't want to make a new function for each new button, you can then bind them all to the same function. And add a parameter to your function, the name of the button that was clicked will be returned: local function btniF(buttonx) gButtons.Color(buttonx,{0,255,0}) print("I am " .. buttonx .. "!") os.sleep(0.5) gButtons.Color(buttonx) end I added a Demo program that shows most of the library's functions. Oh, btw, I like the number 4. It's not like this is my fourth attempt creating this or anything! Write a reply if you have any questions, this was my first attempt to create a usable library. gButtonAPI4.lua gButtonsDemo.lua
  2. Hi! I have been working on a program for a few days on and off. But I kind of hit a wall on what I should do to make it work. It's supposed to be a program that scans the environment through a geolyzer installed inside a tablet, and thereafter sends the scan data through a linking card to a stationary computer with a OpenGlasses' terminal. It will then go through each entry and check its value to determine whenever or not it's an ore, a liquid or if it's indestructible.The tablet program will ask for the player's location and how a large area it should scan, then asks if the player wants to send this data to be processed. The tablet program will ask for the player's location and how a large area it should scan, then asks if the player wants to send this data to be processed. The stationary computer should just receive and process the data, then create 3D graphics at the player's location. I've got the collection and transmission part done, but I have problems with how I would go about to draw this on the glasses. Tablet program: local c = require("component") local geo = c.geolyzer local tunnel = c.tunnel local event = require("event") local ser = require("serialization") local coords = {} local rows = {} local radius local function isInt(n) n = pcall(function() return n==math.floor(n) end) return not n end local function readCoordinates(cor) local w = {} for word in string.gmatch(cor,"%S+") do table.insert(w,word) end coords = { x = w[1], y = w[2], z = w[3] } end io.write("Your coordinates: ") readCoordinates(io.read()) if coords.x == nil or coords.y == nil or coords.z == nil then print("You didn't type them in correctly.") coords = { x = -3042, y = 56, z = 3031, } end io.write("Radius: ") radius = io.read() if radius == "" or isInt(radius) then print("You didn't type it in correctly.") radius = 5 end tunnel.send("UserData",ser.serialize(coords),radius) os.sleep(1) for x=-radius,radius-1 do for z=-radius,radius-1 do print("Scanning: " .. x .. " " .. z) table.insert(rows,ser.serialize(geo.scan(x,z,false))) end end io.write("Scan Complete. Send data?[Y/n] ") if string.lower(io.read()) == "y" then tunnel.send("maxPack",#rows) os.sleep(0.2) for i=1,#rows,4 do tunnel.send("Data",rows[i],rows[i+1],rows[i+2],rows[i+3]) print("Sending package " .. i .. "/" .. #rows .. ".") os.sleep(0.2) end print("Sending package " .. #rows .. "/" .. #rows .. ".") print("Data sent.") end Stationary computer with Glasses terminal: local c = require("component") local event = require("event") local ser = require("serialization") local holo = c.hologram local glasses = c.glasses local radius local coords local localCoords = { x = -3051, y = 51, z = 3027 } local rows = {} local maxPack = 0 local isDone = false local function receive(evt,_,_,_,_,msg1,msg2,msg3,msg4,msg5) print("Received Message:") if msg1 == "maxPack" then maxPack = tonumber(msg2) print(msg2 .. " total packages.") end if msg1 == "UserData" then io.write("Coordinates are: ") coords = ser.unserialize(msg2) radius = msg3 io.write("X:" .. coords.x .. " Y:" .. coords.y .. " Z:" .. coords.z .. " Radius: " .. msg3 .. "\n") end if msg1 == "Data" then table.insert(rows,ser.unserialize(msg2)) table.insert(rows,ser.unserialize(msg3)) table.insert(rows,ser.unserialize(msg4)) table.insert(rows,ser.unserialize(msg5)) end print("Size: " .. #rows .. "/" .. maxPack) end local function cleanUp() print("Interrupted. Press [ctrl+alt+c] to exit.") event.ignore("modem_message",receive) event.ignore("interrupted",cleanUp) end local function toGlasses() local times = 1 while times < #rows do for i=-radius,radius do for d=-radius,radius do end end times=times+1 end end local function createDot(x,y,z,color) local dot = glasses.addDot3D() dot.set3DPos(x+0.5,y+0.5,z+0.5) dot.setColor(table.unpack(color)) end local function update() if #rows > 0 then toGlasses() end end event.listen("modem_message",receive) event.listen("interrupted",cleanUp) --createDot(0,5,0,{255,0,0}) while true do update() os.sleep(1/5) end
  3. Hi! I have some problems with getting this library to work that should add buttons to the hud of the mod OpenGlasses: I made it first as a program and then converted it to a library for better organization of the code (and for later use). It worked fine when it was a program that called it's own functions, but now it throws errors when it calls them from another program. It says it can't insert the value to the empty table "API.buttonsName". When it was a standalone table it worked fine to insert the value into it, but it keeps saying the that spot is "bad" (that it doesn't exist?). I did try as you guys can see another method to insert it, to no success. Here is the program that calls the library: --buttonTest1.lua local gButtons = require("gButtonAPI3") local function test1() print("Working.") end gButtons.createNewButton("box1","Box 1",2,8,45,15,255,0,0,test1) while true do gButtons.update() end And here is the whole library (better write too much than too little): --gButtonsAPI3.lua local component = require("component") local event = require("event") local API = {} local glasses = component.glasses API.buttons = {} API.buttonsNames = {} local xV, yV = -1,-1 function API.createNewButton(name,label,x,y,w,h,cR,cG,cB,callback) --API.buttonsNames[#buttonsNames+1] = name table.insert(API.buttonsNames, name) API.buttons[name] = { rect = glasses.addRect(), lbl = glasses.addTextLabel(), posRect = {x,y}, sizeRect = {w,h}, colo = {cR,cB,cG}, state = false, callbk = callback, posTxt = {x + (w / 2) - ((string.len(label) / 2) + (w / 4.5)),y + (h / 3)} } API.buttons[name]["rect"].setPosition(x,y) API.buttons[name]["rect"].setSize(w,h) API.buttons[name]["rect"].setColor(cR,cG,cB) API.buttons[name]["rect"].setAlpha(0.4) API.buttons[name]["lbl"].setPosition(API.buttons[name]["posTxt"][1],API.buttons[name]["posTxt"][2]) API.buttons[name]["lbl"].setText(label) API.buttons[name]["lbl"].setScale(1) API.buttons[name]["lbl"].setColor(255,255,255) end function clickEvent(id, device, user, x, y, button, maxX, maxY) fX = x * (512 / maxX) fY = y * (288 / maxY) xV = fX yV = fY end local function initialize() event.ignore("interact_overlay", clickEvent) event.listen("interact_overlay", clickEvent) end initialize() function API.update() os.sleep(1/20) for i in pairs(API.buttonsNames) do if xV >= API.buttons[API.buttonsNames[i]].posRect[1] and xV <= API.buttons[API.buttonsNames[i]].posRect[1]+API.buttons[API.buttonsNames[i]].sizeRect[1] and yV >= API.buttons[API.buttonsNames[i]].posRect[2] and yV <= API.buttons[API.buttonsNames[i]].posRect[2]+API.buttons[API.buttonsNames[i]].sizeRect[2] then API.buttons[API.buttonsNames[i]].callbk() xV = -1 yV = -1 end end end return API And the error log is attached to this post as a picture: If anyone got any idea what could be the error, I gladly accept any answer! If anyone has questions about the code just ask me and I'll try explaining what it does (or rather "should" do).
  4. Hi! I'm trying to do buttons in a OpenComputers addon OpenGlasses. But it seem to have problems with calling the element from the table. I am not very used to Lua and this is my first big project I'm working on in Lua. local component = require("component") local glasses = component.glasses local buttons = {} local function newButton(name,x,y,w,h,cR,cG,cB) buttons[name] = { rect = glasses.addRect(), pos = {x,y}, size = {w,h}, colo = {cR,cB,cG} } buttons[name][rect].setPosition(buttons[name][pos][1],buttons[name][pos][2]) --Here it says the value is null. buttons[name][rect].setSize(buttons[name][size][1],buttons[name][size][2]) buttons[name][rect].setColor(buttons[name][colo][1],buttons[name][colo][2],buttons[name][colo][3]) --And probably here too... end newButton("box1",2,2,10,10,255,0,0) It says the variable it's trying to reach is null for some reason. Any help would be appreciated.
  5. Hello everyone! This is Direwo... wait, no... But, since I've caught your attention now, I'd like to show you a mod that I've been creating for some time now. The Mod is called OpenGlasses ans is an extension to OpenComputers.It is analogous to glasses from the OpenPeripherals add-on for ComputerCraft, but adds a few more nifty features. Download: LINK Wiki: LINK Issues: LINK
  6. I have created a library for OpenGlasses that allows for sending push notifications. It can be installed using the following command: pastebin get huJePEwB /lib/ognotify.lua It (optionally) depends on another library that defines several color presets (one per Minecraft dye color) that must be installed using this command: pastebin get vVB06vMj /lib/ogcolor.lua The main library provides one function, used for (you guessed it) sending push notifications, the syntax of which is as follows: ognotify.send(title,desc,timeout,bcolor,balpha,tcolor,talpha,dcolor,dalpha) Each notification has three parts: the background rectangle (parameters prefixed with a b refer to this component), the title (related parameters are prefixed with a t), and the description (parameters are prefixed with a d). The first two parameters are the text for the title and description. The third is the time in seconds for which the notification will be displayed. The last six are the color values and opacities for each component, as demarcated by their respective prefix. The alpha values must be integers from 0 to one, representing percent opacity, with 0 being clear and 1 being completely opaque. The color values must be either: One of the following presets from the color library: ogcolor.red ogcolor.green ogcolor.lime ogcolor.blue ogcolor.orange ogcolor.yellow ogcolor.light_blue ogcolor.magenta ogcolor.pink ogcolor.white ogcolor.light_grey ogcolor.grey ogcolor.black ogcolor.cyan ogcolor.purple Or a table formatted like so: {Red RGB / 255, Blue RGB / 255, Green RGB / 255} Each RGB value must be represented as a decimal from 0 to 1, because of the way OG accepts colors. To convert a standard RGB value into the form OG requires, simply divide by 255 To do list: Support multiple line descriptions (it currently supports a single-line description of ~30 characters before the text protrudes from the bounding box) Done! Implement notification queue (currently, if multiple notifications are sent within a short period of time, they will overlap) Best left to a program implementing this library (Possibly) move color parser into separate library Done Changelog: V1.0: Tons of bugfixes (it would only run on my dev machine previously, for reasons unknown) Support for multiple line notifications V0.1: Initial release I hope this comes in handy to somebody.
  7. How might one go about creating a varying number of OpenGlasses widgets in a single block of code?
×
×
  • Create New...

Important Information

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