Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Nifty Sensor Attributes v.03a
- --Comprehensive player stat monitoring program.
- --Designed to give the most important information, typically to track a player or give an upper hand in PVP.
- --Requires the "OpenPeripherals" sensor, Terminal Glasses, and an Advanced Monitor.
- m = peripheral.wrap("right")
- -- m for monitor, must be adjusted on an individual basis.
- s = peripheral.wrap("top")
- -- s for sensor
- g = peripheral.wrap("left")
- -- g for glasses
- sensorPositionX = -306
- -- X coordinate in the world, used for calibration
- sensorPositionY = 29
- -- Y coordinate in the world, used for calibration
- sensorPositionZ = 570
- -- Z coordinate in the world, used for calibration
- playername = nil
- -- set playername nil to start
- function updateScreen()
- while true do
- sleep(0.1)
- tempPlayerName = playername
- if tempPlayerName == nil then
- g.clear()
- print("cleared")
- elseif tempPlayerName ~= nil then
- if s.getPlayerData(tempPlayerName) == nil then
- repeat
- g.clear()
- g.addText(10,10,"Invalid name")
- print("Invalid name")
- tempPlayerName = playername
- if tempPlayerName == nil then
- break
- end
- until s.getPlayerData(tempPlayerName) ~= nil
- break
- end
- print(s.getPlayerData(tempPlayerName)["health"])
- a = math.floor(sensorPositionX+s.getPlayerData(tempPlayerName)["position"]["x"])
- b = math.floor(sensorPositionY+s.getPlayerData(tempPlayerName)["position"]["y"])
- c = math.floor(sensorPositionZ+s.getPlayerData(tempPlayerName)["position"]["z"])
- print(a)
- print(b)
- print(c)
- g.clear()
- g.addText(10,10,a)
- g.addText(10,20,b)
- g.addText(10,30,c)
- sleep(0.1)
- end
- end
- end
- function startup()
- term.redirect(m)
- term.clear()
- term.setCursorPos(1,1)
- print("ready")
- end
- function eventHandle()
- while true do
- sleep(0.1)
- evt,command = os.pullEvent("chat_command")
- if command == "stop" then
- print("command stopped")
- break
- elseif command == "clear" then
- playername = nil
- print("command cleared")
- --g.clear()
- elseif command ~= "clear" then
- playername = command
- print("got name")
- --print("Current health:")
- --g.addIcon(30,10,2421,2)
- --Inventory = playerData.inventory
- --"Weapon" = playerData.heldItem
- --do print("Current weapon:") end
- --for key,value in pairs(playerData.heldItem) do print(key,value)
- end
- end
- end
- startup()
- while true do
- parallel.waitForAny(eventHandle, updateScreen)
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement