ForthMinus
From OpenSimulator
(Difference between revisions)
(→LibCore) |
(→LibMath) |
||
Line 97: | Line 97: | ||
! style="background-color:#D2ECD2;" | Stack | ! style="background-color:#D2ECD2;" | Stack | ||
! style="background-color:#D2ECD2;" | Description | ! style="background-color:#D2ECD2;" | Description | ||
+ | |- | ||
+ | | + | ||
+ | | ( n1 n2 -- n ) | ||
+ | | Adds n1 and n2 together. If n1 or n2 are strings, result will be a combined string | ||
+ | |- | ||
+ | | - | ||
+ | | ( n1 n2 -- n) | ||
+ | | Pushes n1 - n2 | ||
+ | |- | ||
+ | | * | ||
+ | | ( n1 n2 -- n) | ||
+ | | Pushes n1 * n2 | ||
+ | |- | ||
+ | | / | ||
+ | | ( n1 n2 -- n ) | ||
+ | | Pushes n1 / n2 | ||
+ | |- | ||
+ | | round | ||
+ | | ( n -- n ) | ||
+ | | Rounds n to nearest integer | ||
+ | |- | ||
+ | | sin | ||
+ | | ( n -- n ) | ||
+ | | Pushes the sin of n | ||
+ | |- | ||
+ | | cos | ||
+ | | ( n -- n ) | ||
+ | | Pushes the cos of n | ||
+ | |- | ||
+ | | tan | ||
+ | | ( n -- n ) | ||
+ | | Pushes the tan of n | ||
+ | |- | ||
+ | | pi | ||
+ | | ( -- n ) | ||
+ | | Pushes PI | ||
+ | |- | ||
+ | | abs | ||
+ | | ( n -- n ) | ||
+ | | Pushes the absolute value of n | ||
+ | |- | ||
+ | | sqrt | ||
+ | | ( n -- n) | ||
+ | | Pushes the square root of n | ||
+ | |- | ||
+ | | pow | ||
+ | | ( n1 n2 -- n) | ||
+ | | Pushes n1 to the n2'th power | ||
+ | |- | ||
+ | | floor | ||
+ | | ( n -- n ) | ||
+ | | Floors n and pushes it | ||
+ | |- | ||
+ | | vecmag | ||
+ | | ( x y z -- n) | ||
+ | | Pushes the vecmag of vector <x, y, z> | ||
+ | |- | ||
+ | | vecnorm | ||
+ | | ( x y z -- x y z ) | ||
+ | | Pushes the normalized vector for <x, y, z> | ||
+ | |- | ||
+ | | vecdist | ||
+ | | ( x1 y1 z1 x2 y2 z2 -- n ) | ||
+ | | Pushes the distance between <x1, y1, z1> and <x2, y2, z2> | ||
|- | |- | ||
|} | |} |
Revision as of 10:38, 20 January 2008
LibCore
Word marked with "*" are primarily for testing purposes for sim owners and not end users.
Word | Stack | Description |
---|---|---|
dup | ( n -- n n ) | Duplicates the top item of the stack |
. * | ( n -- ) | Prints the top item of the stack in console |
dump * | ( -- ) | Dumps the VM's current status in console |
swap | ( n1 n2 -- n2 n1) | Swaps the order of the top two items in the stack |
savestate * | ( n -- ) | Saves the VM's state to file n.fmo |
words * | ( -- ) | Lists the primitive words loaded to console |
loadlib | ( n -- ) | Loads the words in n.dll |
: [;] | Special | Define a user word. The first word following the : in the estack is the name. All words following until ; is the definition of the word |
savestack | ( ... n -- ) | Pops the entire stack into variable n |
loadstack | ( n -- ... ) | Push's the stack saved in variable n |
clearstack | ( ... -- ) | Clears the entire stack |
if,[else],then | ( n -- ) | If n is true, execute words until else or then. If n is false, execute else to then |
not | ( n -- n ) | If n is true, push false, if n is false, push true |
> | ( n1 n2 -- n ) | If n1 > n2, push true else push false |
< | ( n1 n2 -- n) | If n1 < n2, push true else push false |
>= | ( n1 n2 -- n ) | If n1 >= n2, push true else push false |
<= | ( n1 n2 -- n) | If n1 <= n2, push true else push false |
= | ( n1 n2 -- n ) | If n1 == n2, push true else push false |
!= | ( n1 n2 -- n ) | If n1 != n2, push true else push false (technically pushes "= not" to estack) |
! | ( n1 n2 -- ) | Saves n1 to variable n2 |
@ | ( n -- n ) | Pushes variable n to stack |
LibMath
Word | Stack | Description |
---|---|---|
+ | ( n1 n2 -- n ) | Adds n1 and n2 together. If n1 or n2 are strings, result will be a combined string |
- | ( n1 n2 -- n) | Pushes n1 - n2 |
* | ( n1 n2 -- n) | Pushes n1 * n2 |
/ | ( n1 n2 -- n ) | Pushes n1 / n2 |
round | ( n -- n ) | Rounds n to nearest integer |
sin | ( n -- n ) | Pushes the sin of n |
cos | ( n -- n ) | Pushes the cos of n |
tan | ( n -- n ) | Pushes the tan of n |
pi | ( -- n ) | Pushes PI |
abs | ( n -- n ) | Pushes the absolute value of n |
sqrt | ( n -- n) | Pushes the square root of n |
pow | ( n1 n2 -- n) | Pushes n1 to the n2'th power |
floor | ( n -- n ) | Floors n and pushes it |
vecmag | ( x y z -- n) | Pushes the vecmag of vector <x, y, z> |
vecnorm | ( x y z -- x y z ) | Pushes the normalized vector for <x, y, z> |
vecdist | ( x1 y1 z1 x2 y2 z2 -- n ) | Pushes the distance between <x1, y1, z1> and <x2, y2, z2> |