Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --NanoGlasses V4.0
- sensor=peripheral.wrap("left")
- glasses=peripheral.wrap("back")
- glassesController="NanoBob_"
- local pc={
- x=272,
- y=51,
- z=380,
- }
- local guiScale="normal"
- local screenSizes={
- ['normal']={['x']=950,['y']=500,},
- }
- weaponIDs={}
- weaponNames={"sword","rapier","bow","paxel","cleaver","hammer"}
- local screenx=screenSizes[guiScale].x
- local screeny=screenSizes[guiScale].y
- local distances={}
- local locating={}
- function drawPositions()
- local currentPlayers={}
- local players=sensor.getPlayers()
- for _,data in pairs(players) do
- currentPlayers[data.name]=true
- end
- local funcs=sensor.getPlayerByName(glassesController)
- local data=funcs.select("player")
- if data~=nil then
- local playerX=data.position.x+pc.x
- local playerZ=data.position.z+pc.z
- local playerY=data.position.y+pc.y
- for name,__ in pairs(locating) do
- if currentPlayers[name]==true then
- local funcs=sensor.getPlayerByName(name)
- local data=funcs.select("player")
- if data~=nil then
- local pos=data.position
- local x=pos.x
- local z=pos.z
- local y=pos.y
- distances[name]={
- health=funcs.single("living").health,
- x=math.floor(pc.x+x+0.5),
- z=math.floor(pc.z+z+0.5),
- y=math.floor(pc.y+y+0.5),
- distance=math.floor(math.sqrt((x-playerX)^2+(z-playerZ)^2)+0.5),
- }
- end
- end
- end
- local nameIndex=1
- glasses.clear()
- for name,info in pairs(distances) do
- local x=info.x
- local z=info.z
- local height=info.y
- local distance=info.distance
- local health=info.health
- --print(name..":"..x..","..z.." Height :"..height.." Distance :"..distance.." Health:"..health)
- if whiteList[name] then
- glasses.addText(5,nameIndex*10-5,name..":"..x..","..z.." Height :"..height.." Distance :"..distance.." Health:"..health,50000)
- elseif blackList[name] then
- glasses.addText(5,nameIndex*10-5,name..":"..x..","..z.." Height :"..height.." Distance :"..distance.." Health:"..health,8000000)
- end
- --stringLength=glasses.getStringWidth(name..": "..x..","..z.." Distance :"..distance)
- glasses.addBox(0,nameIndex*10-5,400,10,10000000,0.2)
- name=string.sub(name,1,6)
- nameIndex=nameIndex+1
- glasses.sync()
- end
- end
- end
- function getPlayerInventory(playerName)
- local returnTable={}
- local playerFuncs=sensor.getPlayerByName(playerName)
- local all=playerFuncs.all()
- local inventory=all.player.inventory
- for i=1,37 do
- if inventory[i]~=nil then
- returnTable[i]=inventory[i].all()
- else
- returnTable[i]="empty"
- end
- end
- return returnTable
- end
- function getWeapons(playerName)
- local playerFuncs=sensor.getPlayerByName(playerName)
- local playerData=playerFuncs.single("living")
- allSlots=getPlayerInventory(playerName)
- weapons={}
- for id,data in pairs(allSlots) do
- if data~="empty" then
- if weaponIDs[data['id']] then
- weapons[data['id']]=true
- else
- loweredString=string.lower(data['name'])
- for id,name in pairs(weaponNames) do
- if string.find(loweredString,name)~=nil then
- weapons[data['id']]=true
- end
- end
- end
- end
- end
- return weapons
- end
- function drawWeapons(message)
- local playerFunctions=sensor.getPlayerByName(message)
- local playerData=playerFunctions.single("living")
- print(message)
- armorIndex=0
- if playerData~=nil then
- armor=playerData['armor']
- glasses.clear()
- for armorSlot,data in pairs(armor) do
- glasses.addIcon(10,armorIndex*40+20,data['id'],0)
- armorIndex=armorIndex+1
- end
- weaponIndex=0
- collumnIndex=0
- weapons=getWeapons(message)
- for id,data in pairs(weapons) do
- print(id)
- glasses.addIcon(30+collumnIndex*20,weaponIndex*40+20,id,0)
- weaponIndex=weaponIndex+1
- if weaponIndex==4 then
- collumnIndex=collumnIndex+1
- weaponIndex=0
- end
- end
- glasses.sync()
- sleep(5)
- end
- end
- function drawInventory(message)
- message=string.gsub(message,"inventory ","")
- message=string.gsub(message,"inventory","")
- local inventory=getPlayerInventory(message)
- print(message)
- if inventory~=nil then
- inventoryIndex=0
- collumnIndex=0
- for slot,data in pairs(inventory) do
- if slot<37 and data~="empty" then
- glasses.addIcon(100+collumnIndex*20+100,inventoryIndex*40+20,data['id'],0)
- if data~="empty" then
- inventoryIndex=inventoryIndex+1
- if inventoryIndex==4 then
- collumnIndex=collumnIndex+1
- inventoryIndex=0
- end
- end
- end
- end
- glasses.sync()
- sleep(10)
- end
- end
- function handleEvents()
- event,side,player,UUID,message=os.pullEvent()
- if event=="glasses_chat_command" then
- print(message)
- --[[if string.find(message,"whitelist")~=nil then
- local message=string.gsub(message,"whitelist ","")
- message=string.gsub(message,"whitelist","")
- whiteList[message]= not whiteList[message] or true
- elseif string.find(message,"blacklist")~=nil then
- local message=string.gsub(message,"blacklist ","")
- message=string.gsub(message,"blacklist","")
- blackList[message]= not blackList[message] or true
- else]]if string.find(message,"locate")~=nil then
- local message=string.gsub(message,"locate ","")
- message=string.gsub(message,"locate","")
- locating[message]= not locating[message] or true
- elseif string.find(message,"weapons")~=nil then
- local message=string.gsub(message,"weapons ","")
- message=string.gsub(message,"weapons","")
- drawWeapons(message)
- elseif string.find(message,"inventory")~=nil then
- drawInventory(message)
- end
- end
- end
- while true do
- drawPositions()
- --drawPlayers()
- handleEvents()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement