Oh baby. I spent a day playing Cards against Humanity, but I was secretly thinking about this and launched into it this morning. My trick here is I use a 3x5 font I stole from the dwarf fortress wiki, rather than the 8x8 font. So, sorry for everyone that has to squint while looking at my terminal window. The version in the love zip file I'm uploading isn't minified, in case anyone wants to try and improve on my methods. Here's the final minified version:
Edit: From here on out this is version 2 after ivan points out my bug.
Code: Select all
Z=[[Qa9^c&&NDEBYO.&McCQARQ:)9SLccXc\ccS?Y26FIQDO*@A@&?T@PJN<MQNN9=aaaSKBYA++[AY@a)6*94FFFUZE6FTX$JZU65&6LQ<?N68VZ*&464696IFZ9&EF6U<(QQ6646N6$6N66Q)O*MQUR?PQP^cccDacc5TJFcU=/.cD=)Q+.TJ6aPQSIZFNQQc$^K6c9a8X3._KZcM`)1c6\;Nc&\;9;NbPJMPMaQPM8ac]]T=table;F=math.floor;M=Z.gmatch;B=Z.byte;L=love;G=L.graphics;R=G.rectangle;O={}S={""}i=495;for a in M(Z,'.')do p,b=1,99-B(a)while p<64 do O[i]=F(b/p)%2>0;p,i=p*2,i+1 end end;A=function(a)S[1]=a and S[1]..a or S[1]:sub(1,#S[1]-1)end;L.draw=function()H=G.getHeight()/2;G.scale(2,2)A'_'for c=1,#S do X=0;for a in M(S[c],'.')do if a=='\t'then X=F(X/8)*8+8 else for i=0,14 do if O[B(a)*15+i]then R('fill',X*4+i%3,(F(H/6)-c)*6+F(i/3),1,1)end end;X=X+1 end end end;A()end;L.textinput=A;print=function(...)T.insert(S,1,T.concat({...},'\t'))end;L.keypressed=function(d)d=d:sub(1,3)if d=="ret"or d=="kpe"then o,r=pcall(loadstring,S[1])if o then o,r=pcall(r)end;print(r)print''elseif d=="bac"and#S[1]>0 then A()elseif d=="tab"then A'\t'end end
973 Bytes. (bumps right against 1024ish if you include the conf.lua file for resizable windows)
Here's the feature list I achieved:
- typed input via the keyboard
- execute commands by pressing enter
- delete characters via backspace
- embedded font string
- print command (with tabs between parameters in output)
- tab key works
- outputs errors on the screen (v2 fix shows both kinds of errors now)
- upper and lowercase, caps
- shift modifier (love.textinput gave me this one for free)
- numeric keypad (kp_enter)
- a cursor (underscore character to indicate your prompt on the bottom line)
Also my
drop the mic image, I'll leave the link but i think I lost to privilege of dropping the mic after picking it back up.
https://love2d.org/imgmirrur/lxLhfNl.gif