a library for LuaZM
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


1. What it is
Back2BASIC is a library that allows you to have all the functions you loved in BASIC. This will help BASIC programmers switch to lua, as well as making it more straightforward to port BASIC programs to lua.

2. Already implemented
- b2b.menu (a prefabricated menu function)
- b2b.printText (like "HELLO" in BASIC, but with LESS-style page breaks)
- b2b.locate (like locate in BASIC)
- b2b.ygraph (Y= graph) 
- b2b.inputString (get user input)

3. To be implemented

4. Usage
Make a folder called "lib" in your root directory. Put b2b.lua in this folder.
In the program you wish to use the library, put run([[lib\b2b.lua]]) at the top.

5. Function syntax
NOTE: all width, height, x, and y values are not pixels, but characters.

Set whether b2b commands should auto refresh the screen on completion.
- option: 1 or 0. 1 means it will automatically refresh the display, 0 means its will not.

b2b.menu(x, y, width, height, title, array, colorfg (optional), colorbg (optional))
a menu function. returns number of selected item.
- x: integer
- y: integer
- width: integer
- height: integer. if smaller than number of items, menu will automatically scroll.
- title: string. title to be displayed above menu.
- array: array. menu options. ex. {"entry1", "entry2"}
- colorfg, colorbg: color. defaults to b&w

b2b.printText(string, colorfg (optional), colorbg (optional))
displays text with LESS-style page breaks
- string: string to be printed
- colorfg, colorbg: color. defaults to b&w

b2b.locate(x, y, string, colorfg (optional), colorbg (optional))
like the Locate command in BASIC.
- x: integer
- y: integer
- string: string to be displayed
- colorfg, colorbg: color. defaults to b&w

b2b.ygraph(f, vwin (optional), type (optional), colorfg (optional), colorbg (optional))
Graphs a Y= graph.
- f: function of x to display. ex. function (x) return math.sin(x) end
- vwin: array. ex. {xmin=-6, xmax=6, ymin=-3, ymax=3, step=.1}
- colorfg, colorbg: color. defaults to b&w

b2b.inputString(prompt, colorfg (optional), colorbg (optional), blinkspeed (optional))
Returns user input.
- prompt: string. Is displayed above the input block.
- colorfg, colorbg: color. defaults to b&w
- blinkspeed: integer. speed cursor should blink at. defaults to 60.

b2b.fline(x1, y1, x2, y2, color (optional))
- x1 y1 x2 y2: integer. measurement in pixels.
- color: color. defaults to b&w