Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function find_peripheral(name, name2)
- sides = {[1] = "front", [2] = "back", [3] = "left", [4] = "right", [5] = "top", [6] = "bottom"}
- peripheral_found = false
- for num=1, 6 do
- type = peripheral.getType(sides[num])
- if type == name then
- peripheral_side = sides[num]
- peripheral_found = true
- end
- end
- if peripheral_found ~= true then
- error("No " .. t .. " attached to the computer", 0)
- end
- name2 = peripheral.wrap(peripheral_side)
- end
- function save(name, location)
- print("Saving: " .. name)
- filehandle = fs.open(location, 'w')
- filehandle.write(textutils.serialize(name))
- filehandle.close()
- end
- function load(name, location)
- print("Loading: " .. name)
- filehandle = fs.open(location, 'r')
- name = textutils.unserialize(filehandle.readAll())
- filehandle.close()
- end
- function change_colors(command, color_1, color_2)
- command.setTextColor(color_1 or colors.white)
- command.setBackgroundColor(color_2 or colors.black)
- end
- function mon_write(text, loc_x, loc_y, color_back, color_text)
- mon.setCursorPos(loc_x, loc_y)
- mon.setTextColor(color_text or colors.white)
- mon.setBackground(color_back or colors.black)
- mon.write(text:upper())
- end
- messages = {}
- function add_table(text)
- num = 1
- while names[num] ~= nil do
- num = num + 1
- end
- messages[num] = text
- end
- add_table("Savage: hey poke, just type name or p, enter, then type the meassage, enter")
- if fs.exists("msg") then
- load(messages, "messages")
- else
- save(messages, "messages")
- end
- find_peripheral("monitor", mon)
- oa_x, oa_y = mon.getSize()
- oa_y = oa_y - 4
- function monitor_draw()
- z = 1
- while messages[z] ~= nil do
- z = z + 1
- end
- z = z - 1
- x, y = 3, oa_y
- while y ~= 4 do
- mon_write(messages[z], x, y)
- z = z - 1
- y = y - 1
- end
- end
- monitor_draw()
- while true do
- user = read()
- user = user:lower()
- if user == "s" then
- user = "Savage"
- elseif user == "p" then
- user = "Pokefan710"
- end
- msg = read()
- text = (user .. ": " .. msg)
- add_table(text)
- save(messages, "messages")
- monitor_draw()
- end
Advertisement
Add Comment
Please, Sign In to add comment