Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --+= TERRACE MG =+--
- --+= Just Does Games =+--
- --+= Setup =+--
- local x,y = term.getSize()
- --if x ~= 51 or y ~= 19 or term.isColor() ~= true then print("51x19 Advanced Only") return end
- --+= Setup =+--
- --+= Variables & Menus =+--
- function data(option)
- if option == "save" then
- local file = fs.open("sv.lua","w")
- file.writeLine(balance)
- file.writeLine(gen)
- file.writeLine(cost)
- file.close()
- elseif option == "load" then
- if fs.exists("sv.lua") == true then
- local file = fs.open("sv.lua", "r")
- balance = tonumber(file.readLine())
- gen = tonumber(file.readLine())
- cost = tonumber(file.readLine())
- file.close()
- else
- balance = 0
- gen = 1
- cost = 2
- end
- end
- end
- data("load")
- running = true
- sel_0 = 1
- sel_1 = 1
- m_0 = {"Game", "Shop","Options"}
- m_1 = {"Generate $","-"}
- m_2 = {"Increase Value","-"}
- m_2_cost = {cost,0,0}
- m_3 = {"Save & Exit Game","Erase Data","-"}
- int_m_sel = {m_1,m_2,m_3}
- int_m = int_m_sel[1]
- --+= Variables & Menus =+--
- --+= Functions =+--
- function setBack(col) term.setBackgroundColor(colors[col]) end
- function setText(col) term.setBackgroundColor(colors[col]) end
- function clr(a) if a == true or a == 1 then shell.run("clear") else term.clear() end end
- function main()
- while running do
- if ref ~= false then clr(true) else ref = true term.setCursorPos(1,1) end
- if balance > 1000000 then
- print("Balance: $999999")
- else
- print("Balance: $"..balance)
- end
- if gen > 1000000 then
- print("$ Value: $999999")
- else
- print("$ Value: $"..gen)
- end
- term.setCursorPos(1,y)
- for i=1, #m_0 do
- if sel_0 == i then
- write("["..m_0[i].."]")
- else
- write(" "..m_0[i].." ")
- end
- end
- for i=1, #int_m do
- term.setCursorPos(2,3+i)
- if int_m == m_2 then
- if sel_1 == i and int_m[i] ~= "-" then
- print("[ "..int_m[i].." ] $"..m_2_cost[i])
- elseif sel_1 == i and int_m[i] == "-" then
- print("[ "..int_m[i].." ]")
- else
- print(int_m[i])
- end
- else
- if sel_1 == i then
- print("[ "..int_m[i].." ]")
- else
- print(int_m[i])
- end
- end
- end
- a,i = os.pullEvent("key")
- if i == keys.w or i == keys.up then
- if sel_1 ~= 1 then
- sel_1 = sel_1 - 1
- else
- ref = false
- end
- elseif i == keys.s or i == keys.down then
- if sel_1 ~= #int_m then
- sel_1 = sel_1 + 1
- else
- ref = false
- end
- elseif i == keys.a or i == keys.left then
- if sel_0 ~= 1 then
- sel_0 = sel_0 - 1
- sel_1 = 1
- int_m = int_m_sel[sel_0]
- end
- elseif i == keys.d or i == keys.right then
- if sel_0 ~= #m_0 then
- sel_0 = sel_0 + 1
- sel_1 = 1
- int_m = int_m_sel[sel_0]
- end
- elseif i == keys.e or i == keys.enter or i == keys.space then
- check()
- else
- ref = false
- end
- end
- end
- function check()
- if sel_0 == 1 then
- if sel_1 == 1 then
- balance = balance + gen
- ref = false
- end
- elseif sel_0 == 2 then
- if sel_1 == 1 then
- if balance >= cost then
- balance = balance - cost
- gen = gen + 1
- cost = cost * 2
- m_2_cost[1] = cost
- else
- ref = false
- end
- elseif sel_1 == 2 then
- elseif sel_1 == 3 then
- end
- elseif sel_0 == 3 then
- if sel_1 == 1 then
- clr(true)
- data("save")
- running = false
- elseif sel_1 == 2 then
- clr(true)
- balance = 0
- gen = 1
- cost = 2
- data("save")
- running = false
- end
- else
- running = false
- end
- end
- --+= Functions =+--
- main()
- print("=)")
- sleep(.1)
- clr(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement