Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Variables --
- ver = "1.0"
- author = "Mackan90096"
- w, h = term.getSize()
- -- Level Tables --
- 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}
- -- End Level Tables --
- char = "@"
- charX = 2
- charY = 10
- maxX = w-1
- maxY = h-1
- lvl = 1
- xp = 0
- hp = lvlHPTable[lvl]
- money = 100
- inv = false
- shop = false
- pause = false
- player = "Steve"
- wep = "Fists"
- -- Tables --
- playerTable = { }
- playerTable.charX = charX
- playerTable.charY = charY
- playerTable.lvl = lvl
- playerTable.xp = xp
- playerTable.money = money
- playerTable.hp = hp
- --[[Items Declare as:
- name
- lvlNeeded
- atkPoints
- Type
- cost
- ID ]]--
- item1 = {"Wooden Sword", 1, 1, "Sword", 100, 1}
- -- End Items --
- -- End Levels --
- -- Mobs --
- mob_Villager = {x, y}
- spawnedVillager = 0
- villager = "!"
- villagerHP = 5
- villagerXP = 2
- villagerMoney = 5
- villagerCol = colors.brown
- maxVillager = 5
- quest1X = 10
- quest1Y = h-10
- questChar1 = "?"
- quest1Col = colors.orange
- -- End Mobs --
- -- End Tables --
- -- Keys --
- up = 200
- down = 208
- left = 203
- right = 205
- enter = 28
- space = 57
- i = 23
- p = 25
- f4 = 62
- q = 16
- e = 18
- -- 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 drawVillager()
- if spawnedVillager < maxVillager then
- term.setBackgroundColor(colors.black)
- sleep(0.5)
- local randX = math.random(2, w-1)
- local randY = math.random(2, h-1)
- term.setTextColor(villagerCol)
- term.setCursorPos(randX, randY)
- local mob = {randX, randY}
- table.insert(mob_Villager, mob)
- print(villager)
- spawnedVillager = spawnedVillager + 1
- drawVillager()
- end
- end
- function quest1()
- term.setBackgroundColor(colors.black)
- term.setTextColor(quest1Col)
- term.setCursorPos(quest1X, quest1Y)
- print(questChar1)
- end
- function Pause()
- term.clear()
- centerPrint("Paused",2,2)
- end
- function Shop()
- term.setBackgroundColor(colors.black)
- 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("Shop", 2,1)
- end
- function inventory()
- term.setBackgroundColor(colors.black)
- 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)
- term.setCursorPos(2, 3)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- centerPrint(" Level: "..lvl.." Money: "..money.." Health: "..hp.." XP: "..xp ,2, 3)
- centerPrint("Current weapon: "..wep, 2,4)
- end
- function desktop()
- function frame()
- term.clear()
- 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()
- drawVillager()
- quest1()
- 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 inv == false and shop == false and pause == false then
- if charY > 2 then
- Up()
- end
- end
- elseif p1 == down then
- if inv == false and shop == false and pause == false then
- if charY < h-1 then
- Down()
- end
- end
- elseif p1 == left then
- if inv == false and shop == false and pause == false then
- if charX > 2 then
- Left()
- end
- end
- elseif p1 == right then
- if inv == false and shop == false and pause == false then
- if charX < w-1 then
- Right()
- end
- end
- elseif p1 == i then
- if inv == false and shop == false and pause == false then
- inv = true
- inventory()
- else
- inv = false
- desktop()
- end
- elseif p1 == p then
- if shop == false and inv == false and pause == false then
- shop = true
- Shop()
- else
- shop = false
- desktop()
- end
- elseif p1 == f4 then
- if pause == false then
- pause = true
- Pause()
- else
- pause = false
- desktop()
- end
- end
- end
- end
- end
- desktop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement