Scripting

by Nickr5
[Documentation] [Share] [Zip]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://Nickr5.n_Scripting##version=6

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://Nickr5.n_Scripting##version=6

257 downloads
Version 6
Date added: Oct 17 2009
Last updated: Jan 25 2011
3 fans
Allows for the use of scripting languages in BYOND games. [More]
Two scripting languages are built-in (although you can write your own), and can be easily used interchangeably.
NScript Example:
a=10;
if(a>0) {
    i=0;
    while(i<a) {
        i+=1;
        print(OddOrEven(i));
    }
}
def OddOrEven(x) {
    if(x%2) {
        return "Odd";
    } else {
        return "Even";
    }
}

Simple Script (uses recursion because loops are not currently implemented):
set a to 1
set b to 10
Loop a, b
func Loop start, end
    if start <= end
        print OddOrEven(start)
        Loop start + 1, end
    endif
endfunc

func OddOrEven x
    if x % 2
        return "Odd"
    else
        return "Even"
    endif
endfunc


Version History
  • v1
  • Initial Release
    v2
  • Extended SetProc() to be able to call objects' methods.
    v3
  • Implemented 'Simple Script'
  • Fixed a bug in the interpreter which wouldn't allow you to nest function calls within each other.
    v4
  • Simple Script can now interact with object instances exposed through the interpreter's SetVar() proc (or returned from an exposed proc). It can't yet call object methods, but it can read and write to objects' variables.
    v5
  • Minor change to /node/block
  • interpreter.SetProc() updated
  • Documentation updated
    v6
  • Changed the interpreter to use the new /scope object. This fixes recursion and possibly some other bugs. (Thanks, Toadfish)

Advertisement

Comments

Tafe: (Jul 4 2011, 6:20 pm)
sweet
Asielen: (Mar 24 2011, 3:12 pm)
Would love to use this with my graphing demo to basically create a byond graphing calculator but alas I haven't touched that in a couple years so I probably won't.
(http://www.byond.com/members/Drumersl/files/ Graph_101212S_r4.zip)

It is a cool thought though.