Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- HOLO_MAPS minecraft-opencomputers-mod
- -- HOLOGRAMM MUST BE PLACED FACING TO Z- COORDINATE
- -- COPYRIGHT BY vitalik228. https://pastebin.com/u/vitalik228
- -- Green block - maybe diamonds/gold or coal
- -- Blue block - maybe water/lava
- -- More features - in the future
- local shell = require("shell")
- shell.execute("pastebin get iKzRve2g /lib/forms.lua -f")
- local component = require("component")
- local gpu = component.gpu
- local geolyzer = component.geolyzer
- local hologram = component.hologram
- local forms = require("forms")
- local showground = false
- gpu.setBackground(0x000000) gpu.fill(1,1, 160, 50, " ")
- sizex = 4
- sizez = 4
- sizey = 4
- sizeox = 0
- sizeoz = 0
- sizeoy = 0
- --GUI start
- hologram.clear()
- gpu.setResolution(160,50)
- forms=require("forms")
- forms.ignoreAll()
- Form1=forms.addForm()
- Form1.border=0
- MainForm=forms.addForm()
- MainForm.H=35
- MainForm.W=60
- MainForm.left=53
- MainForm.color=14792345
- MainForm.top=8
- ExitButton=MainForm:addButton(58,1,"", function() forms.stop() end)
- ExitButton.color=16711680
- ExitButton.W=3
- function startonClick(self, user)
- if sizeox == 0 or sizeoy == 0 or sizeoz == 0 then
- Label8.visible = true
- MainForm:redraw()
- StartButton.color = 0x606060
- StartButton:redraw()
- else
- Label8.visible = false
- MainForm:redraw()
- StartButton.color = 0xBDE000
- StartButton:redraw()
- hologram.clear()
- scan()
- end
- end
- StartButton=MainForm:addButton(22,27,"Scan", startonClick)
- StartButton.H=5
- StartButton.W=16
- StartButton.color = 0x606060
- MainText=MainForm:addLabel(2,1,"HoloMaps")
- MainText.fontColor=0
- MainText.centered=true
- MainText.W=7
- MainText.color=14792345
- Edit1=MainForm:addEdit(20,18, function() sizeoy = tonumber(Edit1.text) end)
- Edit1.fontColor=0
- Edit1.color=14792345
- Edit1.text="Max heigth(Y): 10"
- Edit2=MainForm:addEdit(20,12, function() sizeox = tonumber(Edit2.text) end)
- Edit2.fontColor=0
- Edit2.color=14792345
- Edit2.text="Max long(X): 10"
- Label2=MainForm:addLabel(21,17,"Height")
- Label2.fontColor=0
- Label2.centered=true
- Label2.W=6
- Label2.color=14792345
- Label6=MainForm:addLabel(21,11,"Long")
- Label6.fontColor=0
- Label6.centered=true
- Label6.W=4
- Label6.color=14792345
- Edit3=MainForm:addEdit(20,6, function() sizeoz = tonumber(Edit3.text) end)
- Edit3.fontColor=0
- Edit3.color=14792345
- Edit3.text="Max width(Z): 10"
- Label1=MainForm:addLabel(21,5,"Width")
- Label1.fontColor=0
- Label1.centered=true
- Label1.W=5
- Label1.color=14792345
- Label8=MainForm:addLabel(21,3,"Please select zone!")
- Label8.visible = false
- Label8.color=0xff0000
- function Button1Click(self, user)
- if Button1.color == 0x00ff00 then
- showground = false
- Button1.color = 0xff0000
- else
- showground = true
- Button1.color = 0x00ff00
- end
- Button1:redraw()
- end
- Label3=MainForm:addLabel(21,22,"Show Ground?:")
- Label3.fontColor=0
- Label3.centered=true
- Label3.W=13
- Label3.color=14792345
- Button1=MainForm:addButton(37,22,"", function() Button1Click() end)
- Button1.W=2
- Button1.color=0xFF0000
- --GUI END
- --Scan
- --print("Scanning...") --If GUI - off
- function scan()
- offsetz = -16
- offsetx = -16
- offsety = -36
- if sizeox ~= 0 or sizeoy ~= 0 or sizeoz ~= 0 then
- os.sleep(1)
- local map = {}
- --local scanData = {}
- local y = 0
- local x = 0
- local z = 0
- local i = 0
- for y = 1, sizeoy do
- --offset Offset)
- offsety = offsety + 4
- for x = 1, sizeox do
- --offset Offset)
- offsetx = offsetx + 4
- for z = 1, sizeoz do
- offsetz = offsetz + 4
- --print("Scan... ", "X: ", offsetx, "Y: ", offsety, "Z: ", offsetz) --If GUI - off
- --print("sizeox ", sizeox, " sizeoz ", sizeoz, " sizeoy", sizeoy, "X: ", x, "Y: ", y, "Z: ", z) --If GUI - off
- local scanData = geolyzer.scan(offsetx, offsetz, offsety, sizex, sizez, sizey)
- local i = 1
- for y = 0, sizey - 1 do
- for z = 0, sizez - 1 do
- for x = 0, sizex - 1 do
- map[i] = {posx = offsetx + x, posy = offsety + y, posz = offsetz + z, hardness = scanData[i]}
- i = i + 1
- end
- end
- end
- for i = 1, sizex*sizez*sizey do
- if(map[i].hardness > 0) then
- if(map[i].hardness > 3.5) then
- if (map[i].hardness > 10) then
- hologram.set(map[i].posx+20, map[i].posy+30, map[i].posz+20, 3)
- else
- hologram.set(map[i].posx+20, map[i].posy+30, map[i].posz+20, 2)
- end
- else
- hologram.set(map[i].posx+20, map[i].posy+30, map[i].posz+20, showground)
- end
- --print(map[i].posx, map[i].posy, map[i].posz, map[i].hardness) --If GUI - off
- --print("STEP") --If GUI - off
- end
- end
- --offset Offset)
- if z >= sizeoz then
- offsetz = -16
- end
- scanData = nil
- os.sleep(0.04)
- end
- if x >= sizeox then
- offsetx = -16
- end
- end
- end
- end
- StartButton.color = 0x40F70C
- StartButton:redraw()
- end
- forms.run(MainForm)
- gpu.setBackground(0x000000) gpu.fill(1,1, 160, 50, " ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement