Scripting

by Nickr5
Allows for the use of scripting languages in BYOND games.
ID:111142
 
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)
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.
sweet