Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
local component = require("component") local event = require("event") local fs = require("filesystem") local computer = require("computer") local gpu = component.gpu local items = { { "dwcity:Materia", 0 }, { "minecraft:iron_ingot", 0 }, { "IC2:itemIngot", 0 }, { "IC2:itemIngot", 1 }, { "minecraft:gold_ingot", 0 }, { "minecraft:redstone", 0 }, { "minecraft:coal", 0 }, { "dwcity:X32", 0 } } -------------------------------------------------------------- local colors = { blue = 0x05F5F0, black = 0x000000, bred = 0xFF2400, green = 0x99FF33, sun = 0xFFFF00, red = 0x0052A3, orange = 0xFFA500, mem = 0xFFFFFF, -- память gray = 0x939393, hex = 0xC522A9, pur = 0x00FF00, red1 = 0xFF2400, } ----------------------------------------------------------------------- local friendList = { "Skayrons", "Lovense", "Truncator", "Lovense1", } local players = { { "Skayrons", false }, { "Lovense", false }, { "Lovense1", false }, { "Truncator", false }, } local blackList = { "krissss", "combomaster", "AliceWay", "sima21", "SkyDrive_", "Phenomenoon", "jewiven", "_Desert_Eagle_", "Samaya", } -------------------------------------------------------------------- local chat_box, me, sensor, counter, bridge local euWorking, average, cb, me_a, s, bridgeCom, allow_mem = true, false, false, false, false, false, false -------------{OPTIONS}------------------ local TIME_ZONE = 3 local widthBox = 90 local transBox = 0.3 local timeConstant = 1 local getY = 24 --------------------------------------------- local TC, RO, RN, RD, TPS = 2, 0, 0, 0, 0 local strTPS = "" --------------------------------------------- local t_correction = TIME_ZONE * 3600 local chat_box_name = "§8[§4Малышка§8]" local adm = "Truncator" -- Ник админа компа local allow_mem = false -- Отображать на экране кол-во памяти или нет --------------------------------------------------ENERGY-PROXY----------------------------------------------------- local average_counter = { molecular = { proxy = component.proxy("1f86c069-deca-433e-960b-2c75fd811e0d"), icon = "AdvancedSolarPanel:BlockMolecularTransformer", use = true, coordinates = { x = 1, y = getY + 75 }, color = colors.orange } } --------------------------------------------------------------------------------------------------------------------------------- local localize = { join_in_game = " §7вошел в игру!", left_from_game = " §7покинул игру!", } ---------------------VISUAL----------------------------------------VISUAL------------------------------------------------------------- local function addBox(x, y, w, h, color, tran) return bridge.addBox(x, y, w, h, color, tran) end local function addText(x, y, text, color) return bridge.addText(x, y, text, color) end local function addIcon(x, y, name, meta) return bridge.addIcon(x, y, name, meta) end function gui() w, h = gpu.maxResolution() gpu.fill(1, 1, w, h, " ") end ------------------------------------------------------------CHECK-COM--------------------------------------------------- local function digital(n) local text = '' for f in string.gmatch(n, '%d') do text = text .. f end return text end function check() if component.isAvailable("average_counter") then average = true counter = component.average_counter end if component.isAvailable("chat_box") then cb = true chat_box = component.chat_box chat_box.setName(chat_box_name) end if component.isAvailable("me_interface") then me_a = true me = component.me_interface end if component.isAvailable("openperipheral_sensor") then s = true sensor = component.openperipheral_sensor end if component.isAvailable("openperipheral_bridge") then bridgeCom = true bridge = component.openperipheral_bridge end componentsOnScreen() return false end ------------------------------------------------------------TIME---------------------------------------------------------- local function getTime() local f = io.open("/tmp/TF", "w") f:write("test") f:close() return (fs.lastModified("/tmp/TF")) end local function drawTime() local time = getTime() local lastmod = tonumber(string.sub(time, 1, -4)) + TIME_ZONE * 3600 local dt = os.date('%H:%M', lastmod) local x = 1 local y = getY + 16 local width = widthBox local height = 17 local backgroundColor = colors.black local transparency = transBox addBox(x, y, width, height, backgroundColor, transparency) local textX = x + 10 local textY = y + 5 local textColor = colors.sun addText(textX, textY, "Время " .. dt, textColor) end -------------------------------------------- -------------------------------------------- function componentsOnScreen() gpu.set(1, 1, "TPS: " .. tostring(getAvgTPS())) gpu.set(1, 2, "Molecular AVG: " .. getMolecularAvg()) end function getSize(name, dmg) for _, item in ipairs(me.getItemsInNetwork()) do if item.name == name and item.damage == dmg then return item.size end end return 0 end local function string_number(num) local answer = "" local reverse_num = {} local num = tostring(num):gsub(".", function(c) table.insert(reverse_num, c) end) for index, _ in pairs(reverse_num) do answer = answer .. reverse_num[#reverse_num - index + 1] if index % 3 == 0 and index ~= #reverse_num then answer = answer .. " " end end return answer:reverse() end -------------------------------------------------------------------ITEMS------------------------------------------------------- local function formatNumber(num) if num >= 1000000 then return string.format("%.1fM", num / 1000000) elseif num >= 1000 then return string.format("%.fK", num / 1000) else return tostring(num) end end local function drawItems() if me_a then local y = getY + 100 local columnWidth = widthBox / 2 -- Ширина каждого столбца local itemsPerColumn = math.ceil(#items / 2) -- Количество элементов в каждом столбце addBox(1, y - 5, columnWidth, itemsPerColumn * 19, colors.black, transBox) -- Первый столбец addBox(columnWidth + 1, y - 5, columnWidth, itemsPerColumn * 19, colors.black, transBox) -- Второй столбец for i = 1, #items do local column = math.ceil(i / itemsPerColumn) -- Определение текущего столбца local offsetX = (column - 1) * columnWidth -- Смещение по горизонтали в зависимости от текущего столбца local itemIndex = i % itemsPerColumn -- Индекс элемента в текущем столбце if itemIndex == 0 then itemIndex = itemsPerColumn end local itemY = y + (itemIndex - 1) * 18 -- Рассчитываем позицию Y для текущего элемента addIcon(offsetX + 3, itemY - 4, items[i][1], items[i][2]) local formattedNumber = formatNumber(getSize(items[i][1], items[i][2])) addText(offsetX + 21, itemY, formattedNumber, colors.blue) end end end -------------------------------------------------------------MOLECULAR----------------------------------------------------------------- local function toggleMolecular2Energy() local molecular2_data = average_counter["molecular2"] if molecular2_data and molecular2_data.use then local averageEU = molecular2_data.proxy.getAverage() local currentRedstoneState = redstone.getOutput(redstoneSide) -- Если значение энергии равно нулю и Redstone включен, выключаем Redstone if averageEU == 0 and currentRedstoneState == 15 then redstone.setOutput(redstoneSide, 0) euWorking = true -- Если значение энергии больше нуля и Redstone выключен, включаем Redstone elseif averageEU > 0 and currentRedstoneState == 0 then redstone.setOutput(redstoneSide, 15) euWorking = false end end end ----------------------------------------------------------------TICK-PER-SECOND------------------------------------------------------- local function drawTPS() local avgTPS = getAvgTPS() local color if avgTPS > 18 then color = 0x00FF00 elseif avgTPS > 16 then color = 0xAAFF00 elseif avgTPS > 14 then color = 0xFFFF00 elseif avgTPS > 12 then color = 0xFFAA00 else color = 0xFF4400 end local x = 1 local y = getY - 3 local width = widthBox local height = 17 addBox(x, y, width, height, colors.black, transBox) local textOffsetX = 15 local textX = x + textOffsetX local textY = y + 5 addText(textX, textY, string.format("TPS: %.1f", avgTPS), color) return avgTPS end function getAvgTPS() local TPS = {} local avgTPS = 0 for tSlot = 1, 3 do TPS[tSlot] = 0 end for tSlot = 1, 3 do local realTimeOld = getTime() os.sleep(timeConstant) local realTimeNew = getTime() local realTimeDiff = realTimeNew - realTimeOld TPS[tSlot] = 20000 * timeConstant / realTimeDiff avgTPS = (TPS[1] + TPS[2] + TPS[3]) / 3 end return avgTPS end -------------------------------------------------------------DRAW-ENERGY--------------------------------------------------------- local function drawEnergy() local isMolecularActive = false -- Флаг, сигнализирующий об активности устройства "molecular" -- Первый проход - проверяем, активен ли "molecular" for device, counter in pairs(average_counter) do if device == "molecular" and counter.use and euWorking then isMolecularActive = true -- "molecular" активен и работает break -- Выходим из цикла, так как нашли активное устройство "molecular" end end -- Второй проход - рисуем информацию о энергии for device, counter in pairs(average_counter) do if device ~= "molecular2" or not isMolecularActive then -- Если устройство не "molecular2" или "molecular" не активно if counter.use then local averageEU = counter.proxy.getAverage() local av = "" -- Определение единиц для отображения мощности if averageEU / 1000 <= 1 then av = string.format("%.3f EU/t", averageEU) elseif averageEU / 1000000 >= 1 then av = string.format("%.3f M EU/t", averageEU / 1000000) else av = string.format("%.1f k EU/t", averageEU / 1000) end -- Рисуем прямоугольник и иконку для всех устройств, кроме "molecular2" if device ~= "molecular2" then addBox(counter.coordinates.x, counter.coordinates.y, widthBox, 18, colors.black, transBox) addIcon(counter.coordinates.x + 2, counter.coordinates.y + 1, counter.icon, 0) end -- Рисуем информацию об энергии if device == "molecular" then if euWorking then addText(counter.coordinates.x + 21, counter.coordinates.y + 5, av, counter.color) end else addText(counter.coordinates.x + 21, counter.coordinates.y + 5, av, counter.color) end end end end end function getMolecularAvg() local isMolecularActive = false -- Флаг, сигнализирующий об активности устройства "molecular" -- Первый проход - проверяем, активен ли "molecular" for device, counter in pairs(average_counter) do if device == "molecular" and counter.use and euWorking then isMolecularActive = true -- "molecular" активен и работает break -- Выходим из цикла, так как нашли активное устройство "molecular" end end -- Второй проход - рисуем информацию о энергии for device, counter in pairs(average_counter) do if device ~= "molecular2" or not isMolecularActive then -- Если устройство не "molecular2" или "molecular" не активно if counter.use then local averageEU = counter.proxy.getAverage() local av = "" -- Определение единиц для отображения мощности if averageEU / 1000 <= 1 then av = string.format("%.3f EU/t", averageEU) elseif averageEU / 1000000 >= 1 then av = string.format("%.3f M EU/t", averageEU / 1000000) else av = string.format("%.1f k EU/t", averageEU / 1000) end return av end end end end ----------------------------------------------------------------------------------------- local function updateEnergyStateAndDraw() -- Синхронизируем изменение энергии с отображением информации toggleMolecular2Energy() drawEnergy() end -----------------------------------------------------------CHECK-online-------------------------------------------------------- function checkOnline(n) computer.removeUser(adm) if computer.addUser(players[n][1]) then computer.removeUser(players[n][1]) if players[n][2] == false then if cb then chat_box.say("§a" .. players[n][1] .. localize.join_in_game) end players[n][2] = true end return true else if players[n][2] == true then if cb then chat_box.say("§c" .. players[n][1] .. localize.left_from_game) end players[n][2] = false end computer.removeUser(players[n][1]) return false end end ------------------------------------------------------------------- function freeMemory() if allow_mem then addText(0, 12, "MEM: " .. math.floor((computer.freeMemory() / 1000)) .. "mb" .. "/" .. math.floor((computer.totalMemory() / 1000)) .. "mb" .. " " .. math.floor(((computer.freeMemory() / computer.totalMemory()) * 100)) .. "%", colors.mem) end end -----------------------------------------------------------------------ONLINE------------------------------------------------- function drawOnline() local leftMargin = -19 -- Установите желаемый отступ от левого края экрана local yMargin = getY + 161 local onlineCount = 0 local offlineCount = 0 local y = getY + 210 -- Создаем отдельные списки для онлайн и оффлайн игроков local onlinePlayers = {} local offlinePlayers = {} for i = 1, #players do if checkOnline(i) then onlineCount = onlineCount + 1 table.insert(onlinePlayers, players[i][1]) -- Добавляем онлайн игроков в список else offlineCount = offlineCount + 1 table.insert(offlinePlayers, players[i][1]) -- Добавляем оффлайн игроков в список end end -- Сортируем список онлайн игроков table.sort(onlinePlayers) -- Показываем сортированный список онлайн игроков и количество оффлайн for _, playerName in ipairs(onlinePlayers) do y = y + 10 addText(leftMargin + 23, y, playerName, colors.green, 1) -- Показываем имя игрока с отступом end addBox(leftMargin + 20, yMargin + 13, widthBox, 18, colors.black, transBox) addText(leftMargin + 43, yMargin + 19, "Offline: " .. offlineCount, colors.gray, 1) addIcon(leftMargin + 23, yMargin + 14, "dwcity:Dark_spirit") -- Иконка для оффлайн addBox(leftMargin + 20, yMargin + 33, widthBox, 18, colors.black, transBox) addText(leftMargin + 43, yMargin + 39, "Online: " .. onlineCount, colors.hex, 1) addIcon(leftMargin + 23, yMargin + 34, "dwcity:Dark_spirit2") -- Иконка для онлайн end --------------------------------------------------------------------SENSOR------------------------------------------------------------ local function drawNearPlayers() if s then local y = getY - 3 local temp = sensor.getPlayers() local actualPlayersCount = 0 -- Переменная для подсчета реального количества игроков (не учитывая тех, кто в блэклисте) addBox(93, y, widthBox, 17, colors.black, transBox) for i = 1, #temp do local playerIsFriend = false local playerIsBlacklisted = false for j = 1, #blackList do if temp[i].name == blackList[j] then playerIsBlacklisted = true break end end for j = 1, #friendList do if temp[i].name == friendList[j] then playerIsFriend = true break end end if not playerIsBlacklisted then actualPlayersCount = actualPlayersCount + 1 if playerIsFriend then addText(96, y + 22 + (actualPlayersCount - 1) * 10, temp[i].name, colors.green) else addText(96, y + 22 + (actualPlayersCount - 1) * 10, temp[i].name, colors.red1) end end end addText(95, y + 5, "§b|| Игроки рядом: §a" .. actualPlayersCount, colors.red1) end return end ----------------------------------------------------------------------- check() bridge.clear() addText(10, 150, "Инициализация", colors.blue) bridge.sync() gui() while true do check() computer.addUser(adm) bridge.clear() updateEnergyStateAndDraw() drawItems() drawTPS() drawTime() drawOnline() drawNearPlayers() freeMemory() os.sleep(0.1) bridge.sync() end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
FED RESPONSE TEMPLATES: FED HTML Review Feedb...
8 hours ago | 0.79 KB
disable email per category (not fully tested)
11 hours ago | 0.82 KB
Neuromancer — The Construct Cut (Complete Una...
17 hours ago | 3.30 KB
GLUC6
17 hours ago | 1.56 KB
Mapscan v1.0 - Archeagus Grey Hack Series, Ep...
JavaScript | 22 hours ago | 3.33 KB
Untitled
23 hours ago | 17.15 KB
gpt2
Go | 1 day ago | 2.79 KB
gpt
GetText | 1 day ago | 1.07 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!