Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Voting System Program]]-- Coded By:Firestorm002
- ---------------------------------------------------
- -- [Side Note]
- -- Do not touch any of the code which isn't labeled
- --"change this!", you might mess up the program.
- --You can change it if you know what you are doing.
- --Just maked sure to give me credit. - Fire
- ---------------------------------------------------
- --Peripherals--
- lmon = peripheral.wrap("left")
- rmon = peripheral.wrap("right")
- ---------------------------------------------
- --Startup Scripts--
- if fs.exists("votingdata") == false then
- fs.makeDir("votingdata")
- a = fs.open("votingdata/filea","w")
- a.write("0")
- b = fs.open("votingdata/fileb","w")
- b.write("0")
- c = fs.open("votingdata/titlea","w")
- c.write("title1")
- c.close()
- c = fs.open("votingdata/titlea","r")
- d = fs.open("votingdata/titleb","w")
- d.write("title2")
- d.close()
- d = fs.open("votingdata/titleb","r")
- a.close()
- b.close()
- else
- c = fs.open("votingdata/titlea","r")
- d = fs.open("votingdata/titleb","r")
- end
- if fs.exists("votinguserdata") == false then
- fs.makeDir("votinguserdata")
- end
- --------------------------------------------
- --Variables--
- filename1 = "votingdata/filea"
- filename2 = "votingdata/fileb"
- w,h = term.getSize()
- wml,hml = lmon.getSize()
- wmr,hmr = rmon.getSize()
- title = c.readAll()
- title2 = d.readAll()
- --------------------------------------------|
- --[Change this pass to whatever you like]---|
- overridepass = "baconbits"
- --------------------------------------------|
- txtscale = 2
- version = "1.0"
- modemside = "top" --(top,left,bottom,right,back)
- h = fs.open(filename1,"r")
- t = fs.open(filename2,"r")
- msga1 = h.readAll()
- msga2 = t.readAll()
- --Closes fs.open()'s--
- h.close()
- t.close()
- --
- ---------------------------------------------
- --[[Functions]]--
- --Monitor Functions--
- function clear()
- lmon.clear()
- rmon.clear()
- rmon.setCursorPos(1,1)
- lmon.setCursorPos(1,1)
- end
- function fillScrs()
- lmon.setTextScale(txtscale)
- rmon.setTextScale(txtscale)
- lmon.write(" ")
- lmon.setCursorPos(1,2)
- lmon.write(" ")
- lmon.setCursorPos(1,3)
- lmon.write(" ")
- lmon.setCursorPos(1,4)
- lmon.write(" ")
- lmon.setCursorPos(1,5)
- lmon.write(" ")
- lmon.setCursorPos(1,6)
- lmon.write(" ")
- --------------------------
- rmon.write(" ")
- rmon.setCursorPos(1,2)
- rmon.write(" ")
- rmon.setCursorPos(1,3)
- rmon.write(" ")
- rmon.setCursorPos(1,4)
- rmon.write(" ")
- rmon.setCursorPos(1,5)
- rmon.write(" ")
- rmon.setCursorPos(1,6)
- rmon.write(" ")
- end
- function mUpdate()
- clear()
- --Titles--
- rmon.setCursorPos(2,1)
- rmon.write(title2)
- lmon.setCursorPos(2,1)
- lmon.write(title)
- --Dividing Lines--
- rmon.setCursorPos(1,2)
- rmon.write(string.rep("-",w))
- lmon.setCursorPos(1,2)
- lmon.write(string.rep("-",w))
- --Voting Data--
- rmon.setCursorPos(2,4)
- lmon.setCursorPos(2,4)
- lmon.write(msg)
- rmon.write(msg2)
- end
- ----------------------
- --Terminal Functions--
- function tClear()
- term.clear()
- end
- function tWrite(str,xpos,ypos)
- term.setCursorPos(xpos,ypos)
- term.write(str)
- end
- function tCenter(str,ypos)
- term.setCursorPos(w/2 - #str/2,ypos)
- term.write(str)
- end
- function header(str)
- tCenter(string.rep("-",w),1)
- tCenter(str,3)
- tCenter(string.rep("-",w),5)
- end
- --[[Introduction Voice]]------
- rednet.open(modemside)
- clear()
- tClear()
- term.setTextColor(colors.red)
- lmon.setBackgroundColor(colors.blue)
- rmon.setBackgroundColor(colors.blue)
- fillScrs()
- term.setTextColor(colors.cyan)
- tCenter("<Coded By: Firestorm002>",2)
- tCenter("<Version 1.0>",4)
- term.setTextColor(colors.white)
- tCenter("<LOADING>",6)
- term.setTextColor(colors.red)
- tCenter("[ ]",7)
- sleep(1)
- term.setTextColor(colors.orange)
- tCenter("[==== ]",7)
- sleep(1)
- term.setTextColor(colors.yellow)
- tCenter("[======== ]",7)
- sleep(1)
- tCenter("[============ ]",7)
- sleep(1)
- term.setTextColor(colors.green)
- tCenter("[================ ]",7)
- sleep(1)
- term.setTextColor(colors.lime)
- tCenter("[==================== ]",7)
- sleep(1)
- tCenter("[=======================]",7)
- sleep(1.5)
- tClear()
- term.setTextColor(colors.white)
- tCenter("<LOADING COMPLETE>",6)
- term.setTextColor(colors.lime)
- tCenter("[=======================]",7)
- sleep(1.5)
- clear()
- tClear()
- lmon.setBackgroundColor(colors.black)
- rmon.setBackgroundColor(colors.black)
- lmon.setTextColor(colors.yellow)
- rmon.setTextColor(colors.yellow)
- clear()
- --Titles--
- rmon.setCursorPos(2,1)
- rmon.write(title2)
- lmon.setCursorPos(2,1)
- lmon.write(title)
- --Dividing Lines--
- rmon.setCursorPos(1,2)
- rmon.write(string.rep("-",w))
- lmon.setCursorPos(1,2)
- lmon.write(string.rep("-",w))
- --Voting Data--
- rmon.setCursorPos(2,4)
- lmon.setCursorPos(2,4)
- lmon.write(msga1)
- rmon.write(msga2)
- ------------------------------
- --Core Mechanics-[DO NOT TOUCH UNLESS EXPERIENCED]-
- while true do
- term.setTextColor(colors.yellow)
- header("<VOTING SOFTWARE 1.0>")
- term.setTextColor(colors.white)
- tCenter("ADMINS: Press 'o' to override this menu.",9)
- ev,p1,p2,p3 = os.pullEvent()
- if ev == "rednet_message" then
- if p2 == "vote1" then
- h = fs.open(filename1,"r")
- msg = h.readAll()
- msg = msg + 1
- h.close()
- h = fs.open(filename1,"w")
- h.write(msg)
- h.close()
- t = fs.open(filename2,"r")
- msg2 = t.readAll()
- t.close()
- clear()
- mUpdate()
- elseif p2 == "vote2" then
- h = fs.open(filename2,"r")
- msg2 = h.readAll()
- msg2 = msg2 + 1
- h.close()
- h = fs.open(filename2,"w")
- h.write(msg2)
- h.close()
- t = fs.open(filename1,"r")
- msg = t.readAll()
- t.close()
- clear()
- mUpdate()
- elseif p2 == "newvoter" then
- ev,p1,p2,p3 = os.pullEvent("rednet_message")
- h = fs.open("votinguserdata/"..p2,"w")
- h.close()
- elseif p2 == "needvoter" then
- ev,p1,p2,p3 = os.pullEvent("rednet_message")
- if fs.exists("votinguserdata/"..p2) then
- rednet.broadcast("yes")
- elseif fs.exists("votinguserdata/"..p2) == false then
- rednet.broadcast("no")
- end
- end
- elseif ev == "char" then
- if p1 == "o" then
- term.setTextColor(colors.lime)
- tClear()
- header("<OVERRIDE INITIATED>")
- term.setTextColor(colors.white)
- tWrite("PASSWORD: ",2,8)
- userinput = read("*")
- if userinput == overridepass then
- while true do
- term.setTextColor(colors.lime)
- tClear()
- header("<CONTROL PANEL>")
- term.setTextColor(colors.white)
- tWrite("rom/admin>",2,6)
- userinput2 = read()
- if userinput2 == "cleardata" then
- h = fs.open(filename1,"w")
- t = fs.open(filename2,"w")
- h.write("0.0")
- t.write("0.0")
- h.close()
- t.close()
- tCenter("<ALL VOTING DATA CLEARED>",9)
- sleep(2)
- elseif userinput2 == "exit" then
- tClear()
- term.setTextColor(colors.lime)
- header("<EXITING>")
- sleep(1.5)
- tClear()
- break
- elseif userinput2 == "renametitles" then
- term.setTextColor(colors.lime)
- header("<RENAME TITLES>")
- term.setTextColor(colors.white)
- tCenter("<Press '1' or '2' to rename them>",9)
- ev,p1,p2,p3 = os.pullEvent("char")
- if p1 == "1" then
- tClear()
- term.setTextColor(colors.lime)
- header("<RENAME TITLE #1>")
- term.setTextColor(colors.white)
- tWrite("New Name: ",2,9)
- newname1 = read()
- h = fs.open("votingdata/titlea","w")
- h.write(newname1)
- h.close()
- elseif p1 == "2" then
- tClear()
- term.setTextColor(colors.lime)
- header("<RENAME TITLE #2>")
- term.setTextColor(colors.white)
- tWrite("New Name: ",2,9)
- newname2 = read()
- h = fs.open("votingdata/titleb","w")
- h.write(newname2)
- h.close()
- tClear()
- end
- elseif userinput2 == "clearuserdata" then
- fs.delete("votinguserdata")
- tCenter("<ALL USER DATA CLEARED>",9)
- sleep(2)
- else
- shell.run(userinput2)
- end
- end
- else
- tClear()
- term.setTextColor(colors.red)
- header("<ACCESS DENIED>")
- sleep(5)
- tClear()
- end
- end
- end
- end
- tClear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement