0 Members and 1 Guest are viewing this topic.
b2b={}b2b.version="0.1beta"b2b.menu = function (x, y, width, height, title, array, color1, color2) local x=x*18-18 local y=y*18-18 local continue=0 local selected=1 local max=height local j=1 while continue==0 do --handle keys if key==28 then if selected>1 then selected=selected-1 if selected<max-height+1 then max=selected+height-1 end else selected=#array max=#array end end if key==37 then if selected<#array then selected=selected+1 if selected>height then max=selected end else selected=1 max=height end end if key==31 then continue=1 end --draw menu zmg.drawRectFill(x+1, y+18, width*12, height*18, color2) zmg.drawText(x+1, y+1, title, color2, color1) j=1 for i=max-height+1, max, 1 do if selected==i then zmg.drawText(x+1, y+(j*18), array[i], color2, color1) else zmg.drawText(x+1, y+(j*18), array[i], color1, color2) end j=j+1 end --refresh screen zmg.fastCopy() --keyMenu if continue~=1 then key=zmg.keyMenu() end end return selectedendb2b.printText = function (string, colorfg, colorbg) local substring={} local k=1 --if string extends past screen end (x) if #string>31 then --split string into screen width sized portions for i=1, math.floor(#string/31)+1, 1 do substring[i] = string.sub(string, i*31-30, i*31) end end --display for j=1, math.floor(#substring/11)+1, 1 do k=1 --clear screen zmg.drawRectFill(0, 0, 384, 216, colorbg) for i=j*11-10, j*11, 1 do if substring[i] then zmg.drawText(1, k*18-18, substring[i], colorfg, colorbg) end k=k+1 end zmg.drawText(1, 198, "Press a key (Page " .. j .. "/" .. math.floor(#substring/11)+1 .. ")", colorbg, colorfg) --refresh zmg.fastCopy() --wait zmg.keyMenu() endend
run([[lib\b2b.lua]])zmg.clear()test = b2b.menu(1, 1, 15, 5, "Demo", {"display text","entry2","entry3","entry4","entry5","entry","entry","entry","entry"}, zmg.makeColor("blue"), zmg.makeColor("black"))print(test)teststring="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed porttitor, sapien quis sagittis sodales, metus felis faucibus sem, eget mollis erat dolor non elit. Cras id nibh vel massa auctor euismod. Fusce semper rutrum neque, ut faucibus lacus egestas at. Donec velit augue, pulvinar sit amet vulputate et, consectetur iaculis neque. Quisque eu enim eu est condimentum feugiat. Duis gravida ultrices elit ac malesuada. Sed dui sapien, hendrerit nec mattis in, viverra sit amet nibh. Donec vel sodales risus. Duis facilisis cursus placerat. Donec sed ligula sed odio mollis posuere. Integer ante sapien, cursus eu eleifend in, tristique vehicula arcu. Fusce vel erat nibh, non placerat quam. Vivamus quis nibh ut est rhoncus faucibus et vestibulum elit. Pellentesque vel dui eget leo varius faucibus a ac mi. Nulla a nulla non enim euismod ornare a non mauris. Proin ut sagittis turpis. Maecenas in sem tellus, sit amet placerat ligula. Praesent non augue tellus, a convallis lacus. Curabitur suscipit consectetur aliquet. Nunc vehicula lorem in odio accumsan a placerat neque aliquam. Etiam ultricies orci eu justo dapibus vel elementum libero fermentum. Donec et risus nisi, non pulvinar nunc. Duis quis sem neque. Ut eu dignissim nisl. Maecenas a nisl risus, sed consequat ante. Morbi vitae imperdiet erat. Suspendisse potenti. In urna est, viverra id hendrerit vel, pulvinar eget felis. Donec suscipit, dui ac molestie molestie, mi orci scelerisque mi, quis cursus mi metus eget nibh. Aliquam commodo mi at eros sagittis dictum. Nunc ultrices turpis eu urna luctus dictum. Cras sollicitudin ante quis metus aliquet rutrum. Nam vestibulum velit commodo risus ornare eu varius sem placerat. Maecenas egestas odio eu mi tincidunt in porttitor lorem consequat. Proin libero risus, venenatis ut suscipit et, varius non sapien. Suspendisse eget elementum dolor."if test==1 then b2b.printText(teststring, zmg.makeColor("blue"), zmg.makeColor("black")) end
"welcome to the world of computers, where everything seems to be based on random number generators"
This is interesting. I think that if the syntax is very similar to TI-BASIC or Casio BASIC, it might be popular eventually, because some people tend to dislike having to learn a totally new language. This would also be a great alternative to the insanely slow PRIZM drawing commands.
menu "TITLE","ENTRY1",1,"ENTRY2",2
var = menu(1, 1, 10, 5, "TITLE", {"Entry1", "Entry2"}, zmg.makeColor("blue"), zmg.makeColor("white"))
var = menu("TITLE",{"Entry1", "Entry2"})
... but some people tend to consider using Goto/Lbl as bad practice.
(even if not programming on-calc, people lose stuff due to hard drive failures )
Is printText like Disp on TI calcs (displaying text then moving to next line, scrolling if needed)?
I sadly have no clue about Lua since I never coded it, but does it feature floating points, the ability to copy a flash program to RAM and delete RAM programs?