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)
(http://www.byond.com/members/Drumersl/files/ Graph_101212S_r4.zip)
It is a cool thought though.