Blockland Forums > Modification Help

eggscript -- torquescript extension (v0.2)

(1/3) > >>

Gytyyhgfffff:

https://github.com/bansheerubber/eggscript

i've been working on making a torquescript tokenizer/lexer/whatever you want to call it and the vanilla torquescript part of it is finished. i was thinking that i could add a bunch of additional features that could polyfill down to normal torquescript. ideas include:

- vector operators, no more nested vectorAdd/vectorSub bullstuff. you might write:
%distance = `||%vector1 - %vector2||`;
%dot = `%vector1 . %vector2`;
not really sure how to do the syntax for operations like cross product, distance, unit vectors, etc. open to any ideas on this one

- arrays are treated as objects. this would be polyfilled down to something efficient, but in eggscript you might write:
%array = [];
for(%i = 0; %i < 50; %i++) {
     %array.append(getRandom(1, 5000));
}
%array.sort();
for(%number in %array) {
     echo(%number);
}

- inlining functions for optimization (no more 2-6 microsecond overhead for calling functions!)
- using a string table to shorten variable names (better performance, especially for large loops)

features already in eggscript include:
- string templates. i.e. %variable = $"Welcome to {%client.getPlayerName()}'s server!"; will polyfill to %variable = "Welcome to " @ %client.getPlayerName() @ "'s server!";
- minification https://bansheerubber.com/i/f/GeuGv.png
- de-minification aka pretty printing

willing to look into additional syntax to add to this, really looking forward to making a bunch of cool extensions

PhantOS:
server.egg

Gytyyhgfffff:
after some discussion with others on bcc i've come up with this vector syntax proposal:

%addition = `%vector1 + %vector2`;
%subtraction = `%vector1 - %vector2`;
%scale1 = `%vector * %scalar`;
%scale2 = `%vector / %scalar`;
%dot = `%vector1 . %vector2`;
%magnitude = `||%vector||`;
%distance = `||%point - %origin||`; // note: this pattern will specifically be polyfilled down to vectorDist(%point, %origin)
%normalize = `^%vector`; // aka the unit vector, hense the carrot character

any vector operations that you want to do will be surrounded by backticks so that the transpiler can recognize everything inside of them as vectors. i've left out vector crossing because there isn't really a good symbol to use for its operator, and i find myself using vector cross so infrequently that i don't think we would need an operator for it anyways.

an example like
%theta = mRadToDeg(mACos(vectorDot(%this.getForwardVector(), vectorNormalize(vectorSub(%targetPosition, %position)))));
could simplify down to
%theta = mRadToDeg(mACos(`%this.getForwardVector() . ^(%targetPosition - %position)`));

otto-san:
that's loving dope as hell, working with vectors has always been a pain in ts

makin me want to get back into modding this game

Gytyyhgfffff:
some more highlights from bcc so i don't forget them: supporting generator-like functions

this sounds a lot more amazing than it actually will be. as everyone knows, in torquescript you have stuff like findFirstFile, initContainerRadiusSearch, etc where you have to do some weird while/for loop to iterate through the contents you get back. instead, we were thinking of something along these lines:

for(%col in radius(%radius, %masks)) {
    ...
}

for(%fileName in file(%path)) {
    ...
}

for(%element in tokenize(%string, " ")) { // would be polyfilled to getWord/getTab/etc based on the token provided. otherwise, use nextToken
    ...
}

this for/in structure would be an addition to what i was already planning on doing, which is iterating through scriptgroups/simsets/arrays using the same syntax

not sure how much time i'll have to work on the project this week, so progress might be a little slow for a while. but i'm expecting it to pick back up once i get my first round of college homework out of the way.

one of my plans to counter the whole not being able to work on it thing is to clean up the code so people can start contributing themselves if they really want to, i think it would be really neat to build this language as a community and as stated in the op i am really looking forward to explore more syntax ideas. nothing is a bad idea here, since we can only go up from torquescript lol

Navigation

[0] Message Index

[#] Next page

Go to full version