This is not an up-goer art! Brought to you by O'Really? Press.
Every job is done within TBASEXTN.lua
. If you don't have one, make new one, and enter these lines and save:
-- TBASIC extension
-- these are utilities. Do not delete these lines
local __assert = _TBASIC.__assert
local __assertlhand = _TBASIC.__assertlhand
local __assertrhand = _TBASIC.__assertrhand
local __checknumber = _TBASIC.__checknumber
local __checkstring = _TBASIC.__checkstring
local __readvar = _TBASIC.__readvar
local __resolvevararg = _TBASIC.__resolvevararg
-- end of utilities
To check if it's a number, you use __checknumber
. To check if it's letters, you use __checkstring
. To check the type you'll get, you use __assert
.
When it comes to name your words that explains orders to the computer, their name starts with _fn
, if it's about marks, their name starts with _op
.
<<if you want use function arguments or variables, they must be resolved using __readvar
>>
<<__resolvevararg
>>
You will be dealing with something called _TBASIC._FNCTION
and _TBASIC.LUAFN
. Add the name of your word to _TBASIC._FNCTION
, and add a computer word to _TBASIC.LUAFN
with your word name as a place-name. To make the computer actually understand your new words, is up to you.
Much the same as adding words, but there's some different parts. You will add your marks to _TBASIC._OPERATR
and opprecedence
. Watch that opprecedence
is ordered, and you should know the order of your new marks — which mark comes before yours and which comes after. Think hard that order and add your mark to its right place. If it's the "right-to-left" thing, also add yours to opassoc.rtl
.
Let's say you want to add a word UPGOER
. What it does is it takes a number, and say Up-goer number
goes up! If you tell computer UPGOER 5
, the computer will reply Up-goer 5 goes up!
Here's how it's done:
-
Open
TBASEXTN.lua
. -
Enter this:
local function _fnupgoer(n) print("Up-goer "..__checknumber(n).." goes up!") end
at the bottom.
-
Add
"UPGOER"
to_TBASIC._FNCTION
(enter this:table.insert(_TBASIC._FNCTION, "UPGOER")
to the next line) -
Add
{_fnupgoer, 1}
to_TBASIC.LUAFN.UPGOER
. Meaning of the wordUPGOER
should be obvious, number1
means that it will take that number of things to do something. (enter this:_TBASIC.LUAFN.UPGOER = {_fnupgoer, 1}
to the next line) -
Done!
-
__checknumber(number)
returns real numbernumber
if it can be written as a number. If not, computer will stop and say it didn't get a number. -
__checkstring(letters)
returns lettersletters
if it can be written as letters. -
__assert(thing, type)
will check the type ofthing
is atype
. If it is, computer will move on. If not, it will stop and say something. -
__readvar(varname)
will