Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local monitor_number = "monitor_1"
- local found = fs.exists("config/monitor.cfg")
- if found == true then
- file = fs.open("config/monitor.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- monitor_number = fileData[1]
- end
- local mon = peripheral.wrap(monitor_number)
- --
- function getTime()
- local time_f
- time = os.time()
- time_f = textutils.formatTime(time, true)
- return time_f
- end
- --
- function numToSegCol(number)
- local color_set = colors.black
- if number == "1" then
- color_set = color_set + colors.white
- color_set = color_set + colors.orange
- end
- if number == "2" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.white
- color_set = color_set + colors.pink
- color_set = color_set + colors.lightBlue
- color_set = color_set + colors.magenta
- end
- if number == "3" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.white
- color_set = color_set + colors.pink
- color_set = color_set + colors.orange
- color_set = color_set + colors.magenta
- end
- if number == "4" then
- color_set = color_set + colors.yellow
- color_set = color_set + colors.white
- color_set = color_set + colors.pink
- color_set = color_set + colors.orange
- end
- if number == "5" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.yellow
- color_set = color_set + colors.pink
- color_set = color_set + colors.orange
- color_set = color_set + colors.magenta
- end
- if number == "6" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.yellow
- color_set = color_set + colors.pink
- color_set = color_set + colors.lightBlue
- color_set = color_set + colors.magenta
- color_set = color_set + colors.orange
- end
- if number == "7" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.white
- color_set = color_set + colors.orange
- end
- if number == "8" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.white
- color_set = color_set + colors.yellow
- color_set = color_set + colors.pink
- color_set = color_set + colors.lightBlue
- color_set = color_set + colors.orange
- color_set = color_set + colors.magenta
- end
- if number == "9" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.white
- color_set = color_set + colors.yellow
- color_set = color_set + colors.pink
- color_set = color_set + colors.orange
- color_set = color_set + colors.magenta
- end
- if number == "0" then
- color_set = color_set + colors.lime
- color_set = color_set + colors.white
- color_set = color_set + colors.yellow
- color_set = color_set + colors.lightBlue
- color_set = color_set + colors.orange
- color_set = color_set + colors.magenta
- end
- return color_set
- end
- --
- function chat(msg)
- local chB_mum = "chatBox_0"
- file = fs.open("config/per_plus_plus.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- if chB_num ~= "chat_box_off" then
- chB_num = fileData[2]
- local chB = peripheral.wrap(chB_num)
- chB.say(msg)
- end
- end
- --
- function speaker(msg)
- local sp_num = "speaker_0"
- file = fs.open("config/per_plus_plus.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- sp_num = fileData[1]
- if sp_num ~= "speaker_off" then
- local sp = peripheral.wrap(sp_num)
- sp.speak(msg)
- end
- end
- --
- function sound(inst,note)
- local no_num = "iron_noteblock_0"
- file = fs.open("config/per_plus_plus.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- no_num = fileData[3]
- if no_num ~= "iron_noteblock_off" then
- local no = peripheral.wrap(no_num)
- no.playNote(inst,note)
- end
- end
- --
- function lamp(color)
- local no_num = "colorful_lamp_0"
- file = fs.open("config/per_plus_plus.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- lam_num = fileData[4]
- if lam_num ~= "colorful_lamp_off" then
- local la = peripheral.wrap(lam_num)
- la.setLampColor(color)
- end
- end
- --
- function ini_peripheralPlusPlus()
- local sp_num = "speaker_0"
- local chB_mum = "chatBox_0"
- local found = fs.exists("config/per_plus_plus.cfg")
- if found == false then
- local file = fs.open("config/per_plus_plus.cfg","w")
- speaker_hw = get_hardware("speaker")
- chat_hw = get_hardware("chat_box")
- note_hw = get_hardware("iron_noteblock")
- lamp_hw = get_hardware("colorful_lamp")
- file.writeLine(speaker_hw)
- file.writeLine(chat_hw)
- file.writeLine(note_hw)
- file.writeLine(lamp_hw)
- file.close()
- end
- file = fs.open("config/per_plus_plus.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- sp_num = fileData[1]
- chB_num = fileData[2]
- if chB_num ~= "chat_box_off" then
- local sp = peripheral.wrap(sp_num)
- local chB = peripheral.wrap(chB_num)
- chB.say("Chatbox on")
- sleep(2)
- chB.say("Speaker on")
- end
- end
- --
- function detectDivice(DeviceName)
- DeviceSide="none"
- for k,v in pairs(redstone.getSides()) do
- if peripheral.getType(v)==DeviceName then
- DeviceSide = v
- break
- end
- end
- return(DeviceSide)
- end
- --
- function get_hardware(name)
- hw = "off"
- local periList = peripheral.getNames()
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == name then
- hw = periList[i]
- end
- end
- if hw == "off" then
- hw = name.."_"..hw
- end
- return(hw)
- end
- --
- function split(pString,pPattern)
- local Table = {}
- local fpat = "(.-)"..pPattern
- local last_end = 1
- local s,e,cap = pString:find(fpat,1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(Table,cap)
- end
- last_end = e+1
- s,e,cap = pString:find(fpat,last_end)
- end
- if last_end <= #pString then
- cap = pString:sub(last_end)
- table.insert(Table,cap)
- end
- return Table
- end
- --
- function icon(x,y)
- local monitor_number = "monitor_1"
- local found = fs.exists("config/monitor.cfg")
- if found == true then
- file = fs.open("config/monitor.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- monitor_number = fileData[1]
- end
- local mon = peripheral.wrap(monitor_number)
- icon = paintutils.loadImage("images/icon")
- paintutils.drawImage(icon, x, y)
- mon.setBackgroundColor(8)
- end
- --
- function in_table(table, element)
- for _, value in pairs(table) do
- if value == element then
- return true
- end
- end
- return false
- end
- --
- function toboolean(str)
- if str == "true" then
- return true
- else
- return false
- end
- end
- --
- function round(num, idp, pointless)
- if not pointless then pointless = false end
- local mult = 10^(idp or 0)
- local erg = math.floor(num * mult + 0.5) / mult
- if pointless then
- erg = string.sub(erg, 1)
- end
- return erg
- end
- --
- function loadFile(target)
- file = fs.open(target,"r")
- local IdData = {}
- local line = file.readLine()
- repeat
- table.insert(IdData,line)
- line = file.readLine()
- until line == nil
- file.close()
- return IdData
- end
- --
- function AtoB(search,dataList)
- back = search
- for MCid, MCdata in pairs(dataList) do
- idC = caAPI.split(MCdata,"=")
- if idC[1] == search then
- back = idC[2]
- end
- end
- return back
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement