Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Story ideas;
- you are a child, in a house you have no recollection of being sent to
- this person, the narrator, is unknown to you but they seem to be perfectly aquainted with you
- the narrator speaks often of the "master", who is presumably the owner of this house
- you attempt to get out, sometimes despite the narrators anger
- it is made apparent that the narrator cannot directly harm you though he is not willing to let you out
- you learn of your parents deaths and manage to escape the main house in to the basement
- you find your sister just before and she becomes the new dominant narrator
- she descrbies what happens and how these people were their relatives, looking for their wealth
- after you began trying to escape, and succeding, your sister overheard them and also escaped then hid
- because of their anger at losing them two their captors killed their parents
- your sister starts blaming herself/you for your parents death
- ]]
- local itemList = {
- ["name"] = {
- --item format ([item.colors], {item.info}, {info.image}, {item.size})
- },
- ["key"] = {
- ["info"] = "Standard Key",
- ["image"] = {
- "<+>",
- " | ",
- " :="
- },
- ["size"] = 3,
- },
- }
- --[[
- __ __ _____ __
- | \/ | |_ _| / _|
- | \ / | __ _ _ __ | | _ __ | |_ ___
- | |\/| |/ _` | '_ \ | | | '_ \| _/ _ \
- | | | | (_| | |_) | _| |_| | | | || (_) |
- |_| |_|\__,_| .__/ |_____|_| |_|_| \___/
- | |
- |_|
- ]]
- local map1 = {
- "---------------",
- "-++-+++++------",
- "-++++-+++*-@---",
- "-++-+------+---",
- "----++++++++---",
- "-:-----#---#---",
- "-++++++++-+++:-",
- "-+----+++-+++--",
- "-+++*--++------",
- "--------------"
- }
- map1.pos = {2,3}
- map1.vision = 4
- map1.convert = {
- ["-"] = 0,
- ["+"] = 1,
- ["#"] = 2,
- ["*"] = 3,
- [":"] = 4,
- ["@"] = 5,
- ["~"] = 6,
- ["0"] = 0,
- ["1"] = 1,
- ["2"] = 2,
- ["3"] = 3,
- ["4"] = 4,
- ["5"] = 5,
- ["~"] = 6
- }
- map1.texts = {
- {{4,3}, " Welcome to your new home! Hopefully you find it... comfortable. Please, do explore!"},
- }
- map1.keys = {
- {{10,3}, {8,6}, 1},
- }
- map1.ikeys = {
- {{5,9}, {12,6}, 1, itemList["key"].info},
- }
- map1.items = {
- {{12,3}, itemList["key"]},
- }
- local map2 = {
- "---------------",
- "-:+++--+++++---",
- "--++++-+-+++---",
- "-----+++-*++---",
- "--+--#--+------",
- "--+++++++++++--",
- "-----+-----*+--",
- "-+++++++-------",
- "-+++-++++++----",
- "---------------"
- }
- map2.pos = {11,9}
- map2.vision = 4
- map2.convert = {
- ["-"] = 0,
- ["+"] = 1,
- ["#"] = 2,
- ["*"] = 3,
- [":"] = 4,
- ["@"] = 5,
- ["~"] = 6,
- ["0"] = 0,
- ["1"] = 1,
- ["2"] = 2,
- ["3"] = 3,
- ["4"] = 4,
- ["5"] = 5,
- ["6"] = 6
- }
- map2.texts = {
- }
- map2.keys = {
- {{12,7}, {6,5}, 1},
- {{10,4}, {6,5}, 1}
- }
- map2.items = {
- }
- map2.tele = {
- {{2,2}, map1, {2,7}}
- }
- map1.tele = {
- {{2,6}, map2, {3,2}},
- }
- --[[
- _____ _____ _
- / ____| / ____| | |
- | | __ __ _ _ __ ___ ___ | | ___ __| | ___
- | | |_ |/ _` | '_ ` _ \ / _ \ | | / _ \ / _` |/ _ \
- | |__| | (_| | | | | | | __/ | |___| (_) | (_| | __/
- \_____|\__,_|_| |_| |_|\___| \_____\___/ \__,_|\___|
- ]]
- local function split(str, pat)
- local t = {} -- NOTE: use {n = 0} in Lua-5.0
- if str ~= nil then
- local fpat = "(.-)" .. pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- else
- print("##ERROR failed to split ["..str.."] by:"..pat)
- end
- return t
- end
- local function loadMap(maptab, o_pos)
- local map = {}
- for y=1,#maptab do
- local line = maptab[y]
- for x=1,string.len(line) do
- local char = string.sub(line, x, x)
- if map[x] == nil then map[x] = {} end
- map[x][y] = {maptab.convert[char]}
- if map[x][y][1] == nil then
- map[x][y] = {0}
- --map[x][y].textbox = nil
- end
- end
- end
- map.width = string.len(maptab[1])
- map.height = #maptab
- map.pos = maptab.pos
- if o_pos ~= nil then map.pos = o_pos end
- map.vision = maptab.vision
- map.template = maptab
- if maptab.texts ~= nil then
- for i=1,#maptab.texts do
- if maptab.texts[i] ~= nil then
- local info = maptab.texts[i]
- local pos = info[1]
- local text = info[2]
- if map[pos[1]] ~= nil then
- if map[pos[1]][pos[2]] ~= nil then
- local block = map[pos[1]][pos[2]]
- if block.textbox == nil then block.textbox = {{text, i}} else block.textbox[#block.textbox + 1] = {text, i} end
- print("Textbox created at "..pos[1]..","..pos[2].." which says:")
- print("'"..text.."'")
- sleep(0.5)
- end
- end
- --sleep(3)
- end
- end
- end
- if maptab.tele ~= nil then
- for i=1,#maptab.tele do
- if maptab.tele[i] ~= nil then
- local info = maptab.tele[i]
- local pos = info[1]
- local nmap = info[2]
- local npos = info[3]
- if map[pos[1]] ~= nil then
- if map[pos[1]][pos[2]] ~= nil then
- local block = map[pos[1]][pos[2]]
- if block.tele == nil then block.tele = {{nmap, npos}} else block.tele[#block.tele + 1] = {nmap, npos} end
- end
- end
- end
- end
- end
- if maptab.keys ~= nil then
- for i=1,#maptab.keys do
- if maptab.keys[i] ~= nil then
- local info = maptab.keys[i]
- local pos1 = info[1]
- local pos2 = info[2]
- local ntyp = info[3]
- if map[pos1[1]] ~= nil then
- if map[pos1[1]][pos1[2]] ~= nil then
- if map[pos2[1]] ~= nil then
- if map[pos2[1]][pos2[2]] ~= nil then
- local block = map[pos1[1]][pos1[2]]
- if block.key == nil then block.key = {{pos2, ntyp}} else block.key[#block.key + 1] = {pos2, ntyp} end
- end
- end
- end
- end
- end
- end
- end
- if maptab.ikeys ~= nil then
- for i=1,#maptab.ikeys do
- if maptab.keys[i] ~= nil then
- local info = maptab.ikeys[i]
- local pos1 = info[1]
- local pos2 = info[2]
- local ntyp = info[3]
- local item = info[4]
- if map[pos1[1]] ~= nil then
- if map[pos1[1]][pos1[2]] ~= nil then
- if map[pos2[1]] ~= nil then
- if map[pos2[1]][pos2[2]] ~= nil then
- local block = map[pos1[1]][pos1[2]]
- if block.ikey == nil then block.ikey = {{pos2, ntyp, item}} else block.ikey[#block.ikey + 1] = {pos2, ntyp, item} end
- end
- end
- end
- end
- end
- end
- end
- if maptab.items ~= nil then
- for i=1,#maptab.items do
- if maptab.items[i] ~= nil then
- local info = maptab.items[i]
- local pos = info[1]
- local item = info[2]
- if map[pos[1]] ~= nil then
- if map[pos[1]][pos[2]] ~= nil then
- local block = map[pos[1]][pos[2]]
- if block.item == nil then block.item = {{item}} else block.item[#block.item + 1] = {item} end
- end
- end
- end
- end
- end
- return map
- end
- --[[
- local function genMap(width, height, rooms, coris, size)
- local map = {}
- map.width = width
- map.height = height
- map.pos = nil
- for x=1,width do
- map[x] = {}
- for y=1,height do
- map[x][y] = {0}
- if y == 1 or y == height or x == 1 or x == width then map[x][y] = {1} end
- end
- end
- local pos = {math.random(width-2)+1, math.random(height-2)+1}
- local looping = true
- for i=1,rooms do
- if looping then
- local size = math.random(size)+1
- for x=pos[1]-size,pos[2]+size do
- for y=pos[2]-size,pos[2]+size do
- if x > 1 and x < width and y > 1 and y < height then
- map[x][y] = {1}
- if map.pos == nil then map.pos = {x, y} end
- end
- end
- end
- length = math.random(4)+(size*2)
- local dirs = { {0, -1}, {0, 1}, {-1, 0}, {1, 0} }
- local dir = nil
- for i=1,#dirs do
- if dir == nil then
- local n = math.random(#dirs)
- local cdir = dirs[n]
- --print("pos = "..type(pos))
- --print("cdir = "..type(cdir))
- local npos = {pos[1] + (cdir[1]*length), pos[2] + (cdir[2]*length)}
- if npos[1] > 1 and npos[1] < width and npos[2] > 1 and npos[2] < height then
- dir = cdir
- else
- ndirs = {}
- for i=1,#dirs do
- if i ~= n then ndirs[#ndirs + 1] = dirs[i] end
- end
- dirs = ndirs
- end
- end
- end
- if dir ~= nil then
- pos = {pos[1] + ((dir[1]*length)+size), pos[2] + ((dir[2]*length)+size)}
- else
- pos = {math.random(width-2)+1, math.random(height-2)+1}
- --looping = false
- end
- end
- end
- return map
- end
- ]]
- local function getVision(radius, map)
- local position = map.pos
- local vision = {}
- vision.min = {position[1]-radius, position[2]-radius}
- vision.max = {position[1]+radius, position[2]+radius}
- -- (x-a)^2 + (y-B)^2 = r^2 (formula, where r is radius, x and y are coordinates and a and b is center)
- local r2 = radius^2
- for x=position[1]-radius, position[1]+radius do
- for y=position[2]-radius, position[2]+radius do
- if x > 0 and x <= map.width and y > 0 and y <= map.height then
- local xa = x-position[1]
- local yb = y-position[2]
- xa = xa^2
- yb = yb^2
- local cr2 = xa + yb
- if cr2 <= r2 then
- if vision[x] == nil then vision[x] = {} end
- vision[x][y] = {map[x][y][1], false}
- if cr2 == r2 then vision[x][y][2] = true end
- end
- end
- end
- end
- local done = {}
- local temp = {{map.pos[1], map.pos[2], 0, false}}
- while #temp > 0 do
- local ntemp = {}
- for i=1,#temp do
- local x = temp[i][1]
- local y = temp[i][2]
- local n = temp[i][3]
- local sl = temp[i][4]
- local dtyp = map[x][y][1]
- if sl == false then
- for o=-1,1,2 do
- local nposs = {{x+o, y}, {x, y+o}}
- for j=1,#nposs do
- local npos = nposs[j]
- if map[npos[1]] ~= nil then
- if map[npos[1]][npos[2]] ~= nil then
- local typ = map[npos[1]][npos[2]][1]
- if typ == 1 or typ == 2 or typ == 3 or typ == 4 or typ == 5 or typ == 6 then
- local ok = false
- local stopLoop = false
- if typ == 6 then stopLoop = true end
- if done[npos[1]] == nil then
- ok = true
- else
- if done[npos[1]][npos[2]] == nil then
- ok = true
- end
- end
- if ok then
- if n+1 <= radius then
- ntemp[#ntemp + 1] = {npos[1], npos[2], n+1, stopLoop}
- end
- end
- end
- end
- end
- end
- end
- end
- if done[x] == nil then done[x] = {} end
- done[x][y] = {dtyp, false, n}
- end
- temp = ntemp
- end
- done.pos = map.pos
- done.min = {position[1]-radius, position[2]-radius}
- done.max = {position[1]+radius, position[2]+radius}
- done.radius = radius
- done.text = map.text
- return done
- end
- local function draw(vision, screen, pos)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print(pos[1]..", "..pos[2])
- for x=pos[1]-math.floor(screen[1]/2), pos[1]+math.floor(screen[1]/2) do
- for y=pos[2]-math.floor(screen[2]/2), pos[2]+math.floor(screen[2]/2) do
- --print("(TEST) x:"..x.." ("..pos[1]..") y:"..y.." ("..pos[2]..")")
- if vision[x] ~= nil then
- if vision[x][y] ~= nil then
- --print("x:"..x.." y:"..y)
- local i = vision[x][y][1]
- local nr = vision[x][y][3]
- local pColor = colors.white
- local sColor = colors.lightBlue
- local dColor = colors.brown
- local hdColor = colors.black
- if nr == 1 then
- hdColor = colors.black
- end
- if nr == vision.radius then
- pColor = colors.gray
- sColor = colors.blue
- dColor = colors.black
- end
- if nr == vision.radius-1 then
- pColor = colors.lightGray
- sColor = colors.blue
- end
- local text = " "
- if vision.pos[1] == x and vision.pos[2] == y then text = "+" end
- if i == 0 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.green)
- if text == " " then
- text = ","
- term.setTextColor(colors.white)
- end
- term.write(text)
- elseif i == 1 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(pColor)
- term.setTextColor(colors.green)
- term.write(text)
- elseif i == 2 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(pColor)
- term.setTextColor(colors.green)
- if text == " " then
- text = "#"
- term.setTextColor(sColor)
- end
- term.write(text)
- elseif i == 3 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(pColor)
- term.setTextColor(colors.green)
- if text == " " then
- text = "*"
- term.setTextColor(sColor)
- end
- term.write(text)
- elseif i == 4 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(pColor)
- term.setTextColor(colors.green)
- if text == " " then
- text = ":"
- term.setTextColor(dColor)
- end
- term.write(text)
- elseif i == 5 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(pColor)
- term.setTextColor(colors.green)
- if text == " " then
- text = "@"
- term.setTextColor(sColor)
- end
- term.write(text)
- elseif i == 6 then
- term.setCursorPos(x-(pos[1]-(screen[1]/2))+1, y-(pos[2]-(screen[2]/2))+1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.green)
- if text == " " then
- text = "."
- term.setTextColor(hdColor)
- end
- term.write(text)
- end
- end
- end
- end
- end
- term.setCursorPos(1, screen[2]-3)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.write(vision.text)
- end
- --hp, ad, attack_speed, dodge
- local stats = {
- ["zombie"] = {5, 2, 1, 5}
- }
- local mob_keys = {}
- local function genMobKey()
- local key = tostring(math.random(9999))
- while string.len(key) < 4 do
- key = "0"..key
- end
- local x = 0
- while mob_keys[key] == nil and x < 100 do
- local key = tostring(math.random(9999))
- while string.len(key) < 4 do
- key = "0"..key
- end
- x = x + 1
- end
- if x >= 100 then return nil else return key end
- end
- local function genLoc(map, rempty)
- local blocks = {}
- for x=1,#map.width do
- for y=1,#map.height do
- local block = map[x][y]
- if block[1] == 1 then
- if (rempty == true and block[2] == nil) or rempty == false then
- blocks[#blocks + 1] = {x, y}
- end
- end
- end
- end
- local block = blocks[math.random(#blocks)]
- return block
- end
- local function isValidMobType(mobtype)
- return stats[mobtype] ~= nil
- end
- local function createMob(mobtype, x, y)
- local mob = {}
- local stat = stats[mobtype]
- mob.health = stat[1]
- mob.attack = stat[2]
- mob.attack_speed = stat[3]
- mob.dodge = stat[4]
- mob.loc = {x, y}
- local key = genMobKey()
- mob.key = key
- if mob.key == nil then mob = nil end
- return mob
- end
- local function genMob(map, mobtype)
- if map.mob_n < map.max_mob_n and isValidMobType(mobtype) then
- local loc = genLoc(map, true)
- local mob = createMob(mobtype, loc[1], loc[2])
- map[loc[1]][loc[2]][2] = mob
- map.mob_n = map.mob.n + 1
- map.mobs[mob.key] = mob
- end
- end
- --[[
- colors:
- colors.nBack = normal background colour
- colors.nBackLit = normal background colour when item box is lit up
- colors.nText = normal text colour
- colors.nTextLit = normal text colour when lit
- colors.sBack = side (border of item box) background colour
- colors.sBackLit = side (border of item box) background colour when item box it lit up
- colors.sText = side text colour
- colors.sTextLit = side text colour when lit
- ]]
- dColorSch = {}
- dColorSch.nBack = colors.lightGray
- dColorSch.nBackLit = colors.white
- dColorSch.nText = colors.black
- dColorSch.nTextLit = colors.gray
- dColorSch.sBack = colors.gray
- dColorSch.sBackLit = colors.lightGray
- dColorSch.sText = colors.lightGray
- dColorSch.sTextLit = colors.white
- local function createItemBox(size, colors, pos, info)
- local itembox = {}
- for x=1,size do
- itembox[x] = {}
- for y=1,size do
- local tile = {}
- --[[if x == 1 or x == size or y == 1 or y == size then
- tile.background = colors.sBack
- tile.text = colors.sText
- tile.lit = colors.sBackLit
- tile.litText = colors.sTextLit
- else ]]
- tile.background = colors.nBack
- tile.text = colors.nText
- tile.lit = colors.nBackLit
- tile.litText = colors.nTextLit
- --end
- tile.char = " "
- itembox[x][y] = tile
- end
- end
- itembox.lit = false
- itembox.pos = pos
- itembox.size = size
- itembox.info = info
- itembox.colors = colors
- itembox.draw = function(self)
- for x=1,#self do
- local tab = self[x]
- for y=1,#tab do
- local tile = self[x][y]
- local bColor = tile.background
- local tColor = tile.text
- if self.lit == true then
- bColor = tile.lit
- tColor = tile.litText
- end
- term.setBackgroundColor(bColor)
- term.setTextColor(tColor)
- term.setCursorPos(self.pos[1]+x-1, self.pos[2]+y-1)
- term.write(tile.char)
- end
- end
- end
- itembox.setImage = function(self, image)
- for y=1,#image do
- local line = image[y]
- for x=1,string.len(line) do
- if self[x] ~= nil then
- if self[x][y] ~= nil then
- local char = line:sub(x, x)
- self[x][y].char = char
- end
- end
- end
- end
- end
- itembox.setItem = function(self, item)
- --item format ([item.colors], {item.info}, {info.image}, {item.size})
- self.colors = item.colors
- self.info = item.info
- self.size = item.size
- self:setImage(item.image)
- end
- return itembox
- end
- local function createTextBox(text, screen)
- local textbox = {}
- textbox.screen = screen
- local length = screen[1]
- local splt = split(text, " ")
- local lines = {}
- local cur = ""
- for i=1,#splt do
- if string.len(cur.." "..splt[i]) <= length then
- cur = cur.." "..splt[i]
- else
- lines[#lines + 1] = cur
- cur = splt[i]
- end
- end
- if cur ~= "" then lines[#lines + 1] = cur end
- textbox.lines = lines
- textbox.cur = 1
- textbox.draw = function(self)
- local empty = ""
- for i=1,self.screen[1] do empty = empty.." " end
- local line1 = self.lines[self.cur]
- local line2 = self.lines[self.cur+1]
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(1, self.screen[2]-1)
- term.write(empty)
- if line1 ~= nil then
- term.setCursorPos(1, self.screen[2]-1)
- term.write(line1)
- end
- term.setCursorPos(1, self.screen[2])
- term.write(empty)
- if line2 ~= nil then
- term.setCursorPos(1, self.screen[2])
- term.write(line2)
- end
- end
- return textbox
- end
- local sw, sh = term.getSize()
- local screen = {sw, sh}
- local function move(map, x, y)
- local pos = {map.pos[1], map.pos[2]}
- if pos[1] + x > 0 and pos[1] + x <= map.width and pos[2] + y > 0 and pos[2] + y <= map.height then
- if map[pos[1]+x][pos[2]+y][1] == 1 or map[pos[1]+x][pos[2]+y][1] == 3 or map[pos[1]+x][pos[2]+y][1] == 4 or map[pos[1]+x][pos[2]+y][1] == 5 or map[pos[1]+x][pos[2]+y][1] == 6 then
- map.pos = {pos[1]+x, pos[2]+y}
- local block = map[map.pos[1]][map.pos[2]]
- if block ~= nil then
- if block.textbox ~= nil then
- for i=1,#block.textbox do
- map.textbox = createTextBox(block.textbox[i][1], screen)
- --print("Textbox found at "..map.pos[1]..","..map.pos[2])
- if map.template.texts ~= nil then
- local i = block.textbox[i][2]
- local old_i = #map.template.texts
- --print("Template text index = "..i)
- local ntab = {}
- for j=1,#map.template.texts do
- if j ~= i then ntab[#ntab + 1] = map.template.texts[j] end
- end
- map.template.texts = ntab
- --print("There are now "..#map.template.texts.." template instances, down from "..old_i)
- end
- --sleep(3)
- end
- block.textbox = nil
- end
- if block.tele ~= nil then
- return true, block.tele[1]
- end
- if block.key ~= nil then
- for i=1,#block.key do
- local info = block.key[i]
- local opos = info[1]
- local ntyp = info[2]
- local block = map[opos[1]][opos[2]]
- block[1] = ntyp
- local line = map.template[opos[2]]
- local nline = line:sub(1, opos[1]-1)
- nline = nline..ntyp..line:sub(opos[1]+1)
- map.template[opos[2]] = nline
- end
- end
- if block.ikey ~= nil then
- for i=1,#block.ikey do
- local item = block.ikey[i][3]
- map.msg = item.info
- end
- end
- if block.item ~= nil then
- for i = 1,#block.item do
- local item = block.item[i][1]
- if item.colors == nil then item.colors = dColorSch end
- map.iboxs[3] = createItemBox(item.size, item.colors, {screen[1]-1-item.size, 2}, item.info)
- if item.image ~= nil then map.iboxs[3]:setImage(item.image) end
- map.iboxs[3].info = item.info
- map.iboxs[3].parent = block
- end
- end
- end
- return true
- else
- return false
- end
- end
- return false
- end
- local function useItem(map, slot, pos)
- local ibox = map.iboxs[slot]
- if map[pos[1]] ~= nil then
- if map[pos[1]][pos[2]] ~= nil then
- local block = map[pos[1]][pos[2]]
- if block.ikey ~= nil then
- for i=1,#block.ikey do
- local ikey = block.ikey[i]
- local item = ikey[3]
- if item.info == ibox.info then
- local ipos = ikey[1]
- local ityp = ikey[2]
- map[ipos[1]][ipos[2]][1] = ityp
- map.iboxs[slot] = createItemBox(ibox.size, ibox.colors, ibox.pos, "")
- local line = map.template[ipos[2]]
- local nline = line:sub(1, ipos[1]-1)
- nline = nline..ntyp..line:sub(ipos[1]+1)
- map.template[ipos[2]] = nline
- end
- end
- end
- end
- end
- return false
- end
- local map = loadMap(map1) --genMap(100, 100, 15, 15, 4)
- --if map[3][1].textbox ~= nil then print("Textbox found where it shouldn't be...") sleep(2) end
- map.screen = screen
- map.mob_n = 0
- map.max_mob_n = 8
- map.mobs = {}
- map.iboxs = {}
- map.iboxs[#map.iboxs + 1] = createItemBox(3, dColorSch, {2, 3}, "")
- map.iboxs[#map.iboxs + 1] = createItemBox(3, dColorSch, {6, 3}, "")
- map.iboxs[#map.iboxs].lit = true
- map.msg = ""
- map.iboxs[#map.iboxs]:setItem(itemList["key"])
- --map.textbox = createTextBox("text 1 text 2 text 3 text 4 text 5 text 6 text 7 text 8 text 9 text 10 text 11 text 12 text 13 text 14 text 15 text 16 text 17 text 18", screen)
- draw(getVision(map.vision, map), screen, map.pos)
- local on = true
- while on do
- local event, p1 = os.pullEvent()
- if event == "key" then
- local key = p1
- local cdr = false
- local dir = nil
- if key == 200 then --up
- dir = {0, -1}
- dcr = true
- elseif key == 203 then --left
- dir = {-1, 0}
- dcr = true
- elseif key == 208 then --down
- dir = {0, 1}
- dcr = true
- elseif key == 205 then --right
- dir = {1, 0}
- dcr = true
- elseif key == 29 then
- on = false
- elseif key == 16 then --q
- if map.textbox ~= nil then
- if map.textbox.cur < #map.textbox.lines then
- map.textbox.cur = map.textbox.cur + 1
- dcr = true
- end
- end
- elseif key == 17 then --w
- if map.textbox ~= nil then
- if map.textbox.cur > 1 then
- map.textbox.cur = map.textbox.cur - 1
- dcr = true
- end
- end
- elseif key == 18 then --e
- map.textbox = nil
- dcr = true
- elseif key == 44 then --z
- local pos = map.pos
- useItem(map, 1, pos)
- elseif key == 45 then --x
- local pos = map.pos
- useItem(map, 2, pos)
- end
- if dcr == true then
- if dir ~= nil then
- local result, extra = move(map, dir[1], dir[2])
- if result == true and extra ~= nil then
- map = loadMap(extra[1], extra[2])
- end
- end
- draw(getVision(map.vision, map), screen, map.pos)
- if map.textbox ~= nil then map.textbox:draw() end
- if map.iboxs ~= nil then for i=1,#map.iboxs do
- map.iboxs[i]:draw()
- end end
- end
- end
- end
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement