KaoSDlanor

NINJAAAH [incomplete]

Jul 14th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. local tInfo={curTime=os.time(),elapsed=0,startTime=os.time(),log={left=-1,right=-1},messages={}}
  2. local tBindings={a="left",d="right"}
  3.  
  4. local tMap={
  5.     scrolled={0,0},
  6.     player={
  7.         pos={3,2},
  8.         status="still",
  9.         hitbox={},
  10.         anim={
  11.             still={
  12.                 "o",
  13.                 "|",
  14.                 "|",
  15.                 relative={1,3},
  16.             },
  17.             runRight={
  18.                 {
  19.                     " o ",
  20.                     " \\.",
  21.                     "/  ",
  22.                     relative={2,3},
  23.                 },
  24.                 {
  25.                     " o .",
  26.                     "<.-/",
  27.                     "/ > ",
  28.                     relative={2,3},
  29.                 },
  30.             },
  31.             runLeft={
  32.                 {
  33.                     " o ",
  34.                     "./ ",
  35.                     "  \\",
  36.                     relative={2,3},
  37.                 },
  38.                 {
  39.                     ". o ",
  40.                     "\\-.>",
  41.                     " < \\",
  42.                     relative={3,3},
  43.                 },
  44.             },
  45.         }
  46.     }
  47. }
  48.  
  49.  
  50. local oFile=io.open("map","r")
  51. while true do
  52.     local sLine=oFile:read()
  53.     if not sLine then break end
  54.     table.insert(tMap,sLine)
  55. end
  56. oFile:close()
  57.  
  58. while true do
  59.     local tEvt={}
  60.     local timer=os.startTimer(0.1)
  61.     while true do
  62.         local evts={os.pullEvent()}
  63.         if evts[1]=="timer" and evts[2]==timer then
  64.             break
  65.         else
  66.             tEvt[evts[1]]=tEvt[evts[1]] or {}
  67.             table.insert(tEvt[table.remove(evts,1)],evts)
  68.         end
  69.     end
  70.     tInfo.elapsed=tInfo.elapsed+(os.time()-tInfo.curTime)%24
  71.     tInfo.curTime=os.time()
  72.     while tEvt.char and tEvt.char[1] do
  73.         local action=tBindings[table.remove(tEvt.char,1)[1]]
  74.         if action and tInfo.log[action] then
  75.             if tInfo.elapsed-tInfo.log[action]>0.02 then
  76.                 table.insert(tInfo.messages,{"pulse "..action,tInfo.elapsed,0.04})
  77.             else
  78.  
  79.             end
  80.             tInfo.log[action]=tInfo.elapsed
  81.         end
  82.     end
  83.     term.clear()
  84.     local size={term.getSize()}
  85.     for k,v in ipairs(tMap) do
  86.         term.setCursorPos(1,size[2]-#tMap+k-1)
  87.         write(v:sub(1+tMap.scrolled[1],size[1]+tMap.scrolled[1]))
  88.     end
  89.     local tCurrAnim=tMap.player.anim[tMap.player.status]
  90.     if type(tCurrAnim[1])=="string" then
  91.  
  92.     elseif type(tCurrAnim[1])=="table" then
  93.  
  94.     end
  95.     term.setCursorPos(1,1)
  96.     print(tInfo.elapsed)
  97.     local at=1
  98.     while tInfo.messages[at] do
  99.         print(tInfo.messages[at][1])
  100.         if tInfo.elapsed-tInfo.messages[at][2]>=tInfo.messages[at][3] then
  101.             table.remove(tInfo.messages,at)
  102.             at=at-1
  103.         end
  104.         at=at+1
  105.     end
  106. end
Advertisement
Add Comment
Please, Sign In to add comment