Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables --
- ver = "1.0"
- author = "Mackan90096"
- w, h = term.getSize()
- char = "@"
- charX = 2
- charY = 10
- maxX = w-1
- maxY = h-1
- lvl = 1
- money = 100
- inv = false
- player = "player"
- -- Tables --
- -- Levels --
- xpTable = {
- [1] = 100,
- [2] = 200,
- [3] = 500,
- [4] = 1000,
- [5] = 2500,
- [6] = 4000,
- [7] = 5000,
- [8] = 7500,
- [9] = 10000,
- [10] = 11500}
- lvlHPTable= {
- [1] = 10,
- [2] = 20,
- [3] = 40,
- [4] = 50,
- [5] = 100,
- [6] = 200,
- [7] = 400,
- [8] = 500,
- [9] = 750,
- [10] = 1000}
- --[[Items Declare as:
- name
- lvlNeeded
- atkPoints
- Type
- cost
- ID ]]--
- item1 = {"Wooden Sword", 1, 1, "Sword", 100, 1}
- -- End Items --
- -- End Levels --
- -- End Tables --
- -- Keys --
- up = 200
- down = 208
- left = 203
- right = 205
- enter = 28
- space = 57
- i = 23
- -- End Keys --
- -- End Variables --
- -- Functions --
- -- Text Functions --
- function centerPrint(string, X, Y)
- term.setCursorPos(math.floor(w-string.len(string))/X, Y)
- print(string)
- end
- -- End Text Functions --
- -- Moving Functions --
- function Up()
- term.setCursorPos(charX, charY)
- print(" ")
- charY = charY - 1
- term.setTextColor(colors.yellow)
- term.setCursorPos(charX, charY)
- print(char)
- end
- function Down()
- term.setCursorPos(charX, charY)
- print(" ")
- charY = charY + 1
- term.setTextColor(colors.yellow)
- term.setCursorPos(charX, charY)
- print(char)
- end
- function Left()
- term.setCursorPos(charX, charY)
- print(" ")
- charX = charX - 1
- term.setTextColor(colors.yellow)
- term.setCursorPos(charX, charY)
- print(char)
- end
- function Right()
- term.setCursorPos(charX, charY)
- print(" ")
- charX = charX + 1
- term.setTextColor(colors.yellow)
- term.setCursorPos(charX, charY)
- print(char)
- end
- -- End Moving Functions --
- function inventory()
- term.clear()
- width = 1
- term.clear()
- term.setBackgroundColor(colors.white)
- for x = 1, width do term.setCursorPos(1, x) term.clearLine() end
- for x = h - width + 1, h do term.setCursorPos(1, x) term.clearLine() end
- for i = 1, width do
- for x = 1, h do term.setCursorPos(i, x) term.write(" ") end
- for x = 1, h do term.setCursorPos(w - i + 1, x) term.write(" ") end
- end
- centerPrint("Inventory of "..player,2,1)
- end
- function desktop()
- function frame()
- term.setBackgroundColor(colors.black)
- width = 1
- term.clear()
- term.setBackgroundColor(colors.red)
- for x = 1, width do term.setCursorPos(1, x) term.clearLine() end
- for x = h - width + 1, h do term.setCursorPos(1, x) term.clearLine() end
- for i = 1, width do
- for x = 1, h do term.setCursorPos(i, x) term.write(" ") end
- for x = 1, h do term.setCursorPos(w - i + 1, x) term.write(" ") end
- end
- end
- frame()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.yellow)
- term.setCursorPos(charX, charY)
- print(char)
- while true do
- e, p1, p2, p3 = os.pullEvent()
- if e == "key" then
- if p1 == up then
- if charY > 2 then
- Up()
- end
- elseif p1 == down then
- if charY < h-1 then
- Down()
- end
- elseif p1 == left then
- if charX > 2 then
- Left()
- end
- elseif p1 == right then
- if charX < w-1 then
- Right()
- end
- elseif p1 == i then
- if inv == false then
- inv = true
- inventory()
- else
- inv = false
- desktop()
- end
- end
- end
- end
- end
- desktop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement