ÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÀ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌÀ¬ÀÀÀ¬ÀÀÀ¬ÀÀÎÌÌÌ̈ˆˆ¬ªªª¬ˆˆˆ¬ÌÌ̬ÌÌ̬ÌÀ̬ÌÀÌÌÌìÌÀÀî̬ÀÌ̬ÀÀÀ¬ÀÀÀ¬ÀÀ2Tv˜ºÜþ¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî¬ÌÌ̬ªªª¬ª¬ª¬ªÊ̬ªªªŒˆˆˆÌÀÌÎÌÌÎ̬̪ªÀ쬪ÀÀÀÌîÀìîÌÌîî2Tv˜ºÜþ2Tv˜ºÜþ2Tv˜ºÜþ  !"#$%&'()*+,- 0123456789:;<=@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ €     ` ` @QQt?ððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððððÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌ ððð ÀÀÀ ÀÀ ÀÀÀ ÀÀÀ ÀÌ À ÀÀüððð ððÀÌÌÀüÌÀ ððÀðððððððð ÀüÏÀÌÿÀ üððððððððððððððððððððððð À ÀðÌ ðÌ Àðððððððððððð ððÿÿð   ÀÀÀÀÀÀÀ ð ÀÀÀÀÀÌ ÀÌ ÀÀ ÏððÀÌÌÀüÏÀüÏððððððððððððð ð ÀÌÌÀ ÀÀ ðððððððððððððððððððððððð ÏÀüÌðÌüÀ ðððððððððððð ððÿÿð   ÀÀÀÀ ÌÀ ÀÀÀ  ð ÀÀÀ ÌÌÀ ÀÀÀ  ÏððÀ ÀÿÌÀ ðððððððððððððð ð À ÀÌðÀ ððððððððððððððððððððððð ÏðÌ ðÌÌÀ ð ðððððððððððð ðÿÿÿðÀ ð  ÀÀÀÀ ÀÀÀ üÀÀÌ À ÀÀð  ÀððÀüÏÀ ððÏððððððððððð üÀ ÀÀ ð ððððððððððððððððððððððð ÀðÌüðÌ Ïðððððððððððð ðÿÿðüÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿîîîî îîîî îîîî îîîî îîîîððððððððððð ðððððððîàîðððððððððððððððððððððð ðððððððîàîððððððððððð îîîî ððððððððððð ðððððððððððððððððððððððððððððð ððððððððððððððððððð ððððððððððð ðððððððððððððððððððððððððððððð ððððððððððððððððððð ððððððððððð ðððððððððððððððððððððððððððððð ððððððððððððððððððð ððððððððððð ðððððððððððððððððððððððððððððð ððððððððððððððððððð ððððððððððð ðððððððððððððððððððððððððððððð ððððððððððððððððððð ððððððððððð ðððððððððððððððððððððððððððððð ððððððððððððððððððð C3-- title: fishpond / ><>pond -- author: chartuch -- desc: interpereter for the esolang "><>" (a.k.a. "fish") -- site: i have a neocities but its unfinished -- license: have it idk -- version: 1.0.2 -- script: lua --wawa chars = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","-","=","[","]","\\",";","'" ,"`",",",".","/"," "} capchars = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",")","!","@","#","$","%","^","&","*","(","_","+","{","}","|" ,":","\"","~","<",">","?"," "} mode = "edit" step = 300 --ms world = {} w=0 h=0 stacks = {{r=nil}} fakes = {} inp = "" inp_p = 1 out = "" x=0 xv=0 y=0 yv=0 cx=-1 cy=-1 px=-1 py=-1 lmc = false rmc = false mx,my,lm,_,rm = mouse() hldx = nil hldy = nil tooltip = nil tttimer = -1 ttht = 0 function stackadd(val) table.insert(stacks[#stacks], 1, {v=val,x=240,y=0,w=print(val)}) end function stackset(val) if #stacks[#stacks] < 1 then fishy = true return 0 end stacks[#stacks][1].v = val stacks[#stacks][1].w = print(val) end function stackget() if #stacks[#stacks] < 1 then fishy = true return 0 end return stacks[#stacks][1].v end function stackrm() if #stacks[#stacks] < 1 then fishy = true return 0 end local val = (stacks[#stacks])[1] table.remove(stacks[#stacks], 1) table.insert(fakes, val) return val.v end function stackswap(a,b) if #stacks[#stacks] < math.max(a,b) then fishy = true return 0 end local temp = stacks[#stacks][a] stacks[#stacks][a] = stacks[#stacks][b] stacks[#stacks][b] = temp end function resize(nw, nh) local nwl = {} for x=0,nw-1 do nwl[x] = {} for y=0,nh-1 do if iiw(x,y) then nwl[x][y]=world[x][y] else nwl[x][y]=" " end end end w=nw h=nh world = nwl end function edit(x,y,val) if x<0 or y<0 then return end if x>=w or y>=h then resize(math.max(w,x+1),math.max(h,y+1)) end world[x][y] = val if val == " " then local px = w-1 while true do local check = true for py=0,h-1 do check = check and (world[px][py] == " ") end if check then resize(w-1,h) px=px-1 if w == 0 then break end else break end end local py = h-1 while true do local check = true for px=0,w-1 do check = check and (world[px][py] == " ") end if check then resize(w,h-1) py=py-1 if h == 0 then break end else break end end end end function load(str) local p = 1 local px,py = 0,0 resize(0,0) while p<#str+1 do local char = string.sub(str, p, p) if char == "\n" then px=0 py=py+1 else edit(px,py,char) px=px+1 end p=p+1 end end function save() local exp1 = "" local exp2 = "" for y=0,h-1 do exp1 = exp1.."\n" if y>0 then exp2 = exp2.."\\n" end for x=0,w-1 do exp1 = exp1..world[x][y] exp2 = exp2..world[x][y] end end trace("><>pond load compatible format:",4) trace(exp2.."\n",12) trace("regular ><> format:",4) trace(exp1.."\n",12) trace("don't forget to copy it!") end function iiw(x,y) if world[x] then if world[x][y] then return true end end return false end function effect(x,y) local t = world[x][y] if strmode then if t == strmode then strmode = false return end stackadd(string.byte(t)) return end if t == "^" then dir = 0 end if t == "v" then dir = 1 end if t == "<" then dir = 2 end if t == ">" then dir = 3 end if t == "\\" then dir = (dir+2)%4 end if t == "/" then dir = 3-dir end if t == "|" then dir = (dir<2 and dir or 5-dir) end if t == "_" then dir = (dir<2 and 1-dir or dir) end if t == "#" then dir = (dir<2 and 1-dir or 5-dir) end if t == "x" then dir = math.random(4)-1 end if t == "!" then local dirx = (dir==2 and -1 or dir==3 and 1 or 0) local diry = (dir==0 and -1 or dir==1 and 1 or 0) px=px+dirx py=py+diry end if t == "?" then if stackrm() == 0 then local dirx = (dir==2 and -1 or dir==3 and 1 or 0) local diry = (dir==0 and -1 or dir==1 and 1 or 0) px=px+dirx py=py+diry end end if t == "." then py=stackrm() px=stackrm() end if string.byte(t)>=48 and string.byte(t)<=57 then stackadd(math.floor(t)) end if string.byte(t)>=97 and string.byte(t)<=102 then stackadd(math.floor(string.byte(t)-87)) end if t == "+" then local x = stackrm() local y = stackget() stackset(y + x) end if t == "-" then local x = stackrm() local y = stackget() stackset(y - x) end if t == "*" then local x = stackrm() local y = stackget() stackset(y * x) end if t == "," then local x = stackrm() local y = stackget() if x==0 then fishy=true return end stackset(y / x) end if t == "%" then local x = stackrm() local y = stackget() stackset(y%x) end if t == "=" then local x = stackrm() local y = stackrm() stackadd(y==x and 1 or 0) end if t == ")" then local x = stackrm() local y = stackrm() stackadd(y>x and 1 or 0) end if t == "(" then local x = stackrm() local y = stackrm() stackadd(y=1 do x=x-1 table.insert(stacks[#stacks], #(stacks[#stacks])+1, s[1]) table.remove(s, 1) end end if t == "]" then if #stacks == 1 then stacks = {{}} return end local s = stacks[#stacks] table.remove(stacks, #stacks) while #s>=1 do table.insert(stacks[#stacks], 1, s[#s]) table.remove(s, #s) end end if t == "o" then local x = stackrm() out = out .. string.char(x) if x == string.byte("\n") then outnlc = outnlc+1 end end if t == "n" then testout = stackrm() out = out .. testout end if t == "i" then if inp_p > #inp then stackadd(-1) else stackadd(string.byte(inp, inp_p)) end inp_p = inp_p+1 end if t == "&" then if stacks[#stacks].r then stackadd(stacks[#stacks].r) stacks[#stacks].r = nil else stacks[#stacks].r = stackrm() end end if t == "g" then local y = stackrm() local x = stackrm() if iiw(x,y) then if world[x][y] == " " then stackadd(0) else stackadd(string.byte(world[x][y])) end else stackadd(0) end end if t == "p" then local y = stackrm() local x = stackrm() local v = stackrm() if iiw(x,y) then edit(x,y,string.char(v)) end end if t == ";" then halt = true end end load([[ 0voa ~/?=0:\ voa oooo'Buzz'~< / >1+:aa*1+=?;::5%:{3%:@*?\?/'zziF'oooo/ ^oa n:~~/ ]]) function TIC() lmc = lm rmc = rm mx,my,lm,_,rm = mouse() lmc = lm and not lmc --click check rmc = rm and not rmc if cx==-1 and cy==-1 then if btn(0) then yv=-1 end if btn(1) then yv=1 end if btn(2) then xv=-1 end if btn(3) then xv=1 end else if btnp(0) then cy=cy-1 end if btnp(1) then cy=cy+1 end if btnp(2) then cx=cx-1 end if btnp(3) then cx=cx+1 end end if rm then if hldx == nil and hldy == nil then hldx = x+mx hldy = y+my end xv = hldx - (x+mx) yv = hldy - (y+my) else hldx = nil hldy = nil end x=x+xv y=y+yv xv=xv/1.1 yv=yv/1.1 if mode == "edit" then if lmc then cx = (mx+x//1)//8 cy = (my+y//1)//8 end if rmc then cx = -1 cy = -1 end if not (cx == -1 and cy == -1) and keyp() then for i=1,65 do if keyp(i) and not key(63) then if i <= 48 then edit(cx,cy,(key(64) and capchars or chars)[i]) end if i == 51 or i == 52 then edit(cx,cy," ") end if i == 49 then cx = cx+(key(64) and -1 or 1) end if i == 50 then cy = cy+(key(64) and -1 or 1) end end end end if key(63) and keyp(12) then --ctrl+L trace("\n\n\n\n\n\n\n\n\n\n\n", 12) trace("------------------------", 12) trace("to load ><> script, enter the following:", 4) trace("eval load(\" ... \")", 12) trace("with lines separated by \"\\n\"", 14) trace("e.g.", 14) trace("eval load(\"v<\\n>^\")", 14) trace(" ", 14) trace("then enter \"resume\"", 4) trace("------------------------\n\n\n\n\n", 12) tooltip = "loading instructions are in console" tttimer = 120 end if key(63) and keyp(11) then --ctrl+K save() tooltip = "saved program to console. don't forget it!" tttimer = 180 end if key(63) and keyp(16) then --ctrl+P cx,cy = -1,-1 mode = "run" stacks = {{}} out = "" outnlc = 0 inp_p = 1 px,py = 0,0 dir = 3 strmode = false effect(px,py) tim = time() tooltip = "press P to halt program" tttimer = 120 halt = false fishy = false end if key(57) then --end exit() end elseif mode == "run" then if fishy then halt = true end if keyp(16) then px,py = -1,-1 mode = "edit" fishy = false return end if keyp(20) then trace(out) tooltip = "output string in console" tttimer = 120 return end if key(39) then step = step*(key(63) and 1.2 or 1.03) tooltip = string.format("step: %.4f ms", (step>1 and step//1 or step)) tttimer = 20 end if key(40) then step = step/(key(63) and 1.2 or 1.03) tooltip = string.format("step: %.4f ms", (step>1 and step//1 or step)) tttimer = 20 end local stime = time() for i=0,1000 do if halt then break end if time()-tim < step or time()-stime > 166 then break end tim = tim+step local dirx = (dir==2 and -1 or dir==3 and 1 or 0) local diry = (dir==0 and -1 or dir==1 and 1 or 0) px=px+dirx py=py+diry px=px%w py=py%h effect(px,py) if fishy then return end end end draw() end function draw() local x,y = x//1, y//1 cls() for xx=x//8,(x+240)//8 do for yy=y//8,(y+136)//8 do local dx,dy = 3+xx*8-x,2+yy*8-y if iiw(xx,yy) then print(world[xx][yy],dx,dy+1,15) print(world[xx][yy],dx,dy,12) elseif yy == 0 and xx < 0 and xx > -4 then print((xx==-2 and "<" or ">"),dx,dy,15) else print(".",dx,dy,15) end end end line(w*8-x,h*8-y,-x,h*8-y,15) line(w*8-x,h*8-y,w*8-x,-y,15) line(-x,-y,-x,136,12) line(-x,-y,240,-y,12) if cx>=0 and cy>=0 then rect(cx*8-x,cy*8-y,8,8,14) if iiw(cx,cy) then print(world[cx][cy],3+cx*8-x,2+cy*8-y,0) else print(".",2+cx*8-x,2+cy*8-y,0, true) end end if mode == "run" then if not stbh then stbh = 0 end if not scrl then scrl = 100 end if not wnbx then wnbx = 0 end stbh = (stbh*9 + 50)/10 scrl = (scrl*9 + math.max(#stacks*8 - 44,0))/10 rect(px*8-x,py*8-y,8,8,15) print(world[px][py],3+px*8-x,2+py*8-y,0) else if stbh then stbh = (stbh*9 + 0)/10 end end if wnbx then --warning box if fishy then wnbx = (wnbx*9 + 134)/10 else wnbx = (wnbx*9 + 0)/10 end rect( wnbx-134,(ttht//1)-1,133,12,1) rectb( wnbx-134,(ttht//1)-1,133,12,12) print("something smells fishy...",wnbx-131,(ttht//1)+2,12) end if stbh then --output box rect( 240-12-print(out,240,-16),136-stbh-12*(stbh/50)-outnlc*6,240,136+outnlc*6,15) rectb( 240-12-print(out,240,-16),136-stbh-12*(stbh/50)-outnlc*6,240,136+outnlc*6,12) print(out,240-4- print(out,240,-16),138-stbh-12*(stbh/50)-outnlc*6,12) --stack display box rectb(0,136-stbh,240,stbh,12) clip(1,137-stbh,238,stbh) cls() for i=#stacks,math.max(#stacks-15,1),-1 do local stk = stacks[i] local ws = 0 local totl = 0 for j=#stk,1,-1 do totl = totl + stk[j].w + 8 end for j=#stk,1,-1 do local val = stk[j] val.x = (val.x*9 + 240-totl+(ws-10))/10 val.y = (val.y*9 + (i*8-scrl))/10 ws = ws + val.w + 8 print(val.v, val.x, 132-stbh+math.ceil(val.y+0.1), 12) end end for _,v in pairs(fakes) do v.yv = (v.yv and v.yv or 0) v.yv = v.yv + 1 v.y = v.y+v.yv if v.y > 300 then v.kill = true end print(v.v, v.x, 132-stbh+math.ceil(v.y+0.1), 12) end for k=#fakes,1,-1 do if fakes[k].kill then table.remove(fakes, k) end end clip() end --tooltip box if tooltip and ttht > 0.2 then rect(-1,-1,print(tooltip,0,-8)+8,(ttht//1),15) rectb(-1,-1,print(tooltip,0,-8)+8,(ttht//1),13) print(tooltip,4,(ttht//1)-9,12) end if tttimer > 0 then ttht = (ttht*9 + 12)/10 tttimer = tttimer - 1 else ttht = (ttht*9 + 0)/10 end end