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

Archived

This topic is now archived and is closed to further replies.

  • 0
The Simon

Trouble with Geolyzer and OpenGlasses addon

Question

 

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

 

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

iirc its something like

dot[1] = glasses.addDot()

which you have to move to the correct block position. http://minecraft.bymarcin.com/OpenGlasses/doku.php?id=position3d

you may also want to enable the visibility through objects/wall, which should be

dot[1].setVisibleThroughObjects(true)

check the wiki for more informations:

http://minecraft.bymarcin.com/OpenGlasses/doku.php?id=dotworld

Share this post


Link to post
Share on other sites

×

Important Information

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